@@ -6,136 +6,6 @@ Set Implicit Arguments.
6
6
Unset Strict Implicit .
7
7
Unset Printing Implicit Defensive.
8
8
9
- (******************** *)
10
- (* package ssreflect *)
11
- (******************** *)
12
-
13
- (********** *)
14
- (* ssrbool *)
15
- (********** *)
16
-
17
- Lemma classicPT (P : Type) : classically P <-> ((P -> False) -> False).
18
- Proof .
19
- split; first by move=>/(_ false) PFF PF; suff: false by []; apply: PFF => /PF.
20
- by move=> PFF []// Pf; suff: False by []; apply: PFF => /Pf.
21
- Qed .
22
-
23
- Lemma classic_sigW T (P : T -> Prop ) :
24
- classically (exists x, P x) <-> classically (sig P).
25
- Proof . by split; apply: classic_bind => -[x Px]; apply/classicW; exists x. Qed .
26
-
27
- Lemma classic_ex T (P : T -> Prop ) :
28
- ~ (forall x, ~ P x) -> classically (ex P).
29
- Proof .
30
- move=> NfNP; apply/classicPT => exPF; apply: NfNP => x Px.
31
- by apply: exPF; exists x.
32
- Qed .
33
-
34
- (****** *)
35
- (* seq *)
36
- (****** *)
37
-
38
- Lemma subset_mapP (X Y : eqType) (f : X -> Y) (s : seq X) (s' : seq Y) :
39
- {subset s' <= map f s} <-> exists2 t, all (mem s) t & s' = map f t.
40
- Proof .
41
- split => [|[r /allP/= rE ->] _ /mapP[x xr ->]]; last by rewrite map_f ?rE.
42
- elim: s' => [|x s' IHs'] subss'; first by exists [::].
43
- have /mapP[y ys ->] := subss' _ (mem_head _ _).
44
- have [x' x's'|t st ->] := IHs'; first by rewrite subss'// inE x's' orbT.
45
- by exists (y :: t); rewrite //= ys st.
46
- Qed .
47
- Arguments subset_mapP {X Y}.
48
-
49
- (******** *)
50
- (* bigop *)
51
- (******** *)
52
-
53
- Lemma big_rcons_idx (R : Type ) (idx : R) (op : R -> R -> R) (I : Type )
54
- (i : I) (r : seq I) (P : pred I) (F : I -> R)
55
- (idx' := if P i then op (F i) idx else idx) :
56
- \big[op/idx]_(j <- rcons r i | P j) F j = \big[op/idx']_(j <- r | P j) F j.
57
- Proof . by elim: r => /= [|j r]; rewrite ?(big_nil, big_cons)// => ->. Qed .
58
-
59
- Lemma big_change_idx (R : Type) (idx : R) (op : Monoid.law idx) (I : Type )
60
- (x : R) (r : seq I) (P : pred I) (F : I -> R) :
61
- op (\big[op/idx]_(j <- r | P j) F j) x = \big[op/x]_(j <- r | P j) F j.
62
- Proof .
63
- elim: r => [|i r]; rewrite ?(big_nil, big_cons, Monoid.mul1m)// => <-.
64
- by case: ifP => // Pi; rewrite Monoid.mulmA.
65
- Qed .
66
- Lemma big_rcons (R : Type) (idx : R) (op : Monoid.law idx) (I : Type )
67
- i r (P : pred I) F :
68
- \big[op/idx]_(j <- rcons r i | P j) F j =
69
- op (\big[op/idx]_(j <- r | P j) F j) (if P i then F i else idx).
70
- Proof . by rewrite big_rcons_idx -big_change_idx Monoid.mulm1. Qed .
71
-
72
- (******* *)
73
- (* path *)
74
- (******* *)
75
-
76
- Lemma sortedP T x (s : seq T) (r : rel T) :
77
- reflect (forall i, i.+1 < size s -> r (nth x s i) (nth x s i.+1)) (sorted r s).
78
- Proof .
79
- elim: s => [|y [|z s]//= IHs]/=; do ?by constructor.
80
- apply: (iffP andP) => [[ryz rzs] [|i]// /IHs->//|rS].
81
- by rewrite (rS 0); split=> //; apply/IHs => i /(rS i.+1).
82
- Qed .
83
-
84
- (******** *)
85
- (* tuple *)
86
- (******** *)
87
-
88
- Section tnth_shift.
89
- Context {T : Type} {n1 n2} (t1 : n1.-tuple T) (t2 : n2.-tuple T).
90
-
91
- Lemma tnth_lshift i : tnth [tuple of t1 ++ t2] (lshift n2 i) = tnth t1 i.
92
- Proof .
93
- have x0 := tnth_default t1 i; rewrite !(tnth_nth x0).
94
- by rewrite nth_cat size_tuple /= ltn_ord.
95
- Qed .
96
-
97
- Lemma tnth_rshift j : tnth [tuple of t1 ++ t2] (rshift n1 j) = tnth t2 j.
98
- Proof .
99
- have x0 := tnth_default t2 j; rewrite !(tnth_nth x0).
100
- by rewrite nth_cat size_tuple ltnNge leq_addr /= addKn.
101
- Qed .
102
- End tnth_shift.
103
-
104
- (******** *)
105
- (* prime *)
106
- (******** *)
107
-
108
- Lemma primeNsig (n : nat) : ~~ prime n -> (2 <= n)%N ->
109
- { d : nat | (1 < d < n)%N & (d %| n)%N }.
110
- Proof .
111
- move=> primeN_n le2n; case/pdivP: {+}le2n => d /primeP[lt1d prime_d] dvd_dn.
112
- exists d => //; rewrite lt1d /= ltn_neqAle dvdn_leq 1?andbT //; last first.
113
- by apply: (leq_trans _ le2n).
114
- by apply: contra primeN_n => /eqP <-; apply/primeP.
115
- Qed .
116
-
117
- Lemma totient_gt1 n : (totient n > 1)%N = (n > 2)%N.
118
- Proof .
119
- case: n => [|[|[|[|n']]]]//=; set n := n'.+4; rewrite [RHS]isT.
120
- have [pn2|/allPn[p]] := altP (@allP _ (eq_op^~ 2%N) (primes n)); last first.
121
- rewrite mem_primes/=; move: p => [|[|[|p']]]//; set p := p'.+3.
122
- move=> /andP[p_prime dvdkn].
123
- have [//|[|k]// cpk ->] := (@pfactor_coprime _ n p_prime).
124
- rewrite totient_coprime ?coprimeXr 1?coprime_sym//.
125
- rewrite totient_pfactor ?logn_gt0 ?mem_primes ?p_prime// mulnCA.
126
- by rewrite (@leq_trans p.-1) ?leq_pmulr ?muln_gt0 ?expn_gt0 ?totient_gt0.
127
- have pnNnil : primes n != [::].
128
- apply: contraTneq isT => pn0.
129
- by have := @prod_prime_decomp n isT; rewrite prime_decompE pn0/= big_nil.
130
- have := @prod_prime_decomp n isT; rewrite prime_decompE.
131
- case: (primes n) pnNnil pn2 (primes_uniq n) => [|p [|p' r]]//=; last first.
132
- move=> _ eq2; rewrite !inE [p](eqP (eq2 _ _)) ?inE ?eqxx//.
133
- by rewrite [p'](eqP (eq2 _ _)) ?inE ?eqxx// orbT.
134
- move=> _ /(_ _ (mem_head _ _))/eqP-> _; rewrite big_cons big_nil muln1/=.
135
- case: (logn 2 n) => [|[|k]]// ->.
136
- by rewrite totient_pfactor//= expnS mul1n leq_pmulr ?expn_gt0.
137
- Qed .
138
-
139
9
(******************* *)
140
10
(* package fingroup *)
141
11
(******************* *)
0 commit comments