@@ -3,19 +3,13 @@ require import AllCore List IntDiv Binomial Ring StdOrder.
33(*---*) import IntID IntOrder.
44
55(* -------------------------------------------------------------------- *)
6- op allperms_r (n : unit list) (s : ' a list) : ' a list list.
7-
8- axiom allperms_r0 (s : ' a list) :
9- allperms_r [] s = [[]].
10-
11- axiom allperms_rS (x : unit) (n : unit list) (s : ' a list) :
12- allperms_r (x :: n) s = flatten (
6+ op allperms_r (n : unit list) (s : ' a list) : ' a list list =
7+ with n = [] => [[]]
8+ with n = x::n => flatten (
139 map (fun x => map ((::) x) (allperms_r n (rem x s))) (undup s)).
1410
1511op allperms (s : ' a list) = allperms_r (nseq (size s) tt) s.
1612
17- hint rewrite ap_r : allperms_r0 allperms_rS.
18-
1913(* -------------------------------------------------------------------- *)
2014lemma allperms_rP n (s t : ' a list) : size s = size n =>
2115 (mem (allperms_r n s) t) <=> (perm_eq s t).
5145(* -------------------------------------------------------------------- *)
5246lemma uniq_allperms_r n (s : ' a list) : uniq (allperms_r n s).
5347proof.
54- elim: n s => [|? n ih] s; rewrite ?ap_r //.
48+ elim: n s => [|? n ih] s; rewrite ?ap_r //= .
5549apply/uniq_flatten_map/undup_uniq.
5650 by move=> x /=; apply/map_inj_in_uniq/ih => a b _ _ [].
5751move=> x y; rewrite !mem_undup => sx sy /= /hasP[t].
@@ -79,7 +73,7 @@ require import StdBigop.
7973lemma size_allperms_uniq_r n (s : ' a list) : size s = size n => uniq s =>
8074 size (allperms_r n s) = fact (size s).
8175proof.
82- elim: n s => /= [|? n ih] s; rewrite ?ap_r /= .
76+ elim: n s => /= [s| n ih s] .
8377 by move/size_eq0=> -> /=; rewrite fact0.
8478case: s=> [|x s]; first by rewrite addz_neq0 ?size_ge0.
8579(pose s' := undup _)=> /=; move/addrI=> eq_sz [Nsz uqs].
0 commit comments