-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPermutationHelpers.v
More file actions
34 lines (32 loc) · 980 Bytes
/
Copy pathPermutationHelpers.v
File metadata and controls
34 lines (32 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(** From the Coq manual, updated to work with the current (8.4)
standard library *)
From Stdlib Require Import List.
From Stdlib Require Import Permutation.
Ltac permutAux n :=
match goal with
| |- (Permutation ?l ?l) => reflexivity
| |- (Permutation (?a :: ?l1) (?a :: ?l2)) =>
let newn := eval compute in (length l1) in
(apply perm_skip; permutAux newn)
| |- (Permutation (?a :: ?l1) ?l2) =>
match eval compute in n with
| 1 => fail
| _ =>
let l1' := constr:(l1 ++ a :: nil) in
(apply (@perm_trans _ (a :: l1) l1' l2);
[ apply Permutation_cons_append | compute; permutAux (pred n) ])
end
end.
(** Permutation solver *)
Ltac permut :=
match goal with
| |- (Permutation ?l1 ?l2) =>
match eval compute in (length l1 = length l2) with
| (?n = ?n) => permutAux n
end
end.
(*
Notation "[ x , .. , y ]" := (x :: .. (y :: nil) ..) : list_scope.
Lemma fu : Permutation [1,2,3] [3,1,2].
Proof. permut. Qed.
*)