Skip to content

Commit c3672b9

Browse files
committed
Import commit
0 parents  commit c3672b9

23 files changed

+23095
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/set_lectures/

Makefile

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
COQC = coqc
3+
COQDOC = coqdoc
4+
DOCFLAGS = -g -d doc/ --html --utf8
5+
6+
#NB: qtemp takes a while to compile, avoid making changes in preceding files
7+
8+
VFILES = tactics.v\
9+
axioms.v\
10+
functions.v\
11+
ordinals.v\
12+
lci.v\
13+
aac.v\
14+
ring.v\
15+
cardinal.v\
16+
ordinal_arith.v\
17+
nnum_base.v\
18+
quotient.v\
19+
utils1.v
20+
21+
# ztemp.v\
22+
# qtemp.v\
23+
# qfrac.v\
24+
25+
# raxioms.v\
26+
# zorn.v\
27+
# dedekind.v\
28+
29+
VOFILES = $(VFILES:.v=.vo)
30+
GLOBFILES = $(VFILES:.v=.glob)
31+
DOCFILES = $(patsubst %.v,doc/%.html,$(VFILES))
32+
33+
all: $(VOFILES) document
34+
35+
compile: $(VOFILES)
36+
37+
tactics.vo: tactics.v
38+
$(COQC) $<
39+
40+
axioms.vo: axioms.v tactics.vo
41+
$(COQC) $<
42+
43+
functions.vo: functions.v axioms.vo
44+
45+
ordinals.vo: ordinals.v functions.vo
46+
$(COQC) $<
47+
48+
lci.vo: lci.v ordinals.vo
49+
$(COQC) $<
50+
51+
aac.vo: aac.v lci.vo
52+
$(COQC) $<
53+
54+
ring.vo: ring.v lci.vo aac.vo
55+
$(COQC) $<
56+
57+
cardinal.vo: cardinal.v ordinals.vo
58+
$(COQC) $<
59+
60+
ordinal_arith.vo: ordinal_arith.v lci.vo cardinal.vo ring.vo
61+
$(COQC) $<
62+
63+
nnum_base.vo: nnum_base.v ordinal_arith.vo
64+
$(COQC) $<
65+
66+
quotient.vo: quotient.v nnum_base.vo
67+
$(COQC) $<
68+
69+
utils1.vo: utils1.v nnum_base.vo
70+
$(COQC) $<
71+
72+
%.vo %.glob: %.v
73+
$(COQC) $<
74+
75+
document: doc/index.html
76+
77+
doc/index.html: $(VFILES) $(GLOBFILES)
78+
$(COQDOC) $(DOCFLAGS) $(VFILES)
79+
80+
clean:
81+
rm -f *.v.d *.crashcoqide
82+
83+
new: clean
84+
rm *.glob *.vo doc/*.html
85+
86+

aac.v

Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
2+
Set Implicit Arguments.
3+
Unset Strict Implicit.
4+
5+
Require Export lci.
6+
7+
Require Import List.
8+
Require Import Permutation.
9+
10+
Module AAC_tools.
11+
12+
Inductive list_sub : (list E) -> E -> Prop :=
13+
| sub_nil : forall x, list_sub nil x
14+
| sub_cons : forall x a t, inc a x -> list_sub t x -> list_sub (a::t) x
15+
.
16+
17+
18+
Fixpoint list_iter (op:E2) (def:E) (l: list E) := match l with
19+
| nil => def
20+
| x::nil => x
21+
| x::t => op x (list_iter op def t)
22+
end.
23+
24+
25+
Lemma lci_list_inc : forall op x, is_lci op x -> forall def, inc def x ->
26+
forall l, list_sub l x -> inc (list_iter op def l) x.
27+
Proof.
28+
ir. nin H1.
29+
simpl. am.
30+
simpl. destruct t.
31+
am.
32+
ap H. am. ap IHlist_sub.
33+
am. am.
34+
Qed.
35+
36+
Lemma lci_list_nonempty_inc : forall op x, is_lci op x -> forall def l, list_sub l x -> l<>nil -> inc (list_iter op def l) x.
37+
Proof.
38+
ir. nin H0.
39+
ap False_rect;au.
40+
41+
nin H2.
42+
simpl. am.
43+
change (inc (op a (list_iter op def (a0::t))) x).
44+
ap H. am.
45+
ap IHlist_sub. am. uhg;ir. inversion H4.
46+
Qed.
47+
48+
Lemma list_sub_concat : forall x l l', list_sub l x -> list_sub l' x -> list_sub (l++l') x.
49+
Proof.
50+
ir. nin H. simpl;am.
51+
simpl. constructor. am.
52+
au.
53+
Qed.
54+
55+
Lemma concat_list_sub : forall x l l', list_sub (l ++ l') x -> A (list_sub l x) (list_sub l' x).
56+
Proof.
57+
intros x.
58+
assert (forall l0, list_sub l0 x -> forall l l', l0 = l ++ l' ->
59+
A (list_sub l x) (list_sub l' x)).
60+
61+
intros l0 H. nin H;ir.
62+
destruct l;destruct l';simpl in H;try inversion H;simpl.
63+
ee;constructor.
64+
65+
destruct l. simpl;ee. constructor.
66+
simpl in H1. wr H1. constructor;am.
67+
68+
simpl in H1. inversion H1;subst.
69+
cp (IHlist_sub l l' (eq_refl (l ++ l'))).
70+
ee;au. constructor;am.
71+
72+
ir. eapply H. ap H0. tv.
73+
Qed.
74+
75+
Definition force_nil : forall T:Type, list T.
76+
ir. exact nil.
77+
Defined.
78+
79+
Lemma Permutation_sub : forall x l, list_sub l x -> forall l', Permutation l l' -> list_sub l' x.
80+
Proof.
81+
ir. nin H0.
82+
constructor.
83+
84+
inversion H;subst;constructor;au.
85+
86+
inversion H;subst. inversion H4;subst.
87+
constructor;try am;constructor;am.
88+
89+
au.
90+
Qed.
91+
92+
Ltac mk_iter_aux op a b l l' := match a with
93+
| op ?x ?a' => mk_iter_aux op a' b (x::l) l'
94+
| _ => match b with
95+
| op ?y ?b' => mk_iter_aux op a b' l (y::l')
96+
| _ => change (eq (list_iter op emptyset (rev (a::l))) (list_iter op emptyset (rev (b::l'))))
97+
end
98+
end.
99+
100+
Ltac mk_iter op := match goal with
101+
| |- eq ?a ?b => mk_iter_aux op a b (force_nil E) (force_nil E)
102+
| _ => assert True
103+
end.
104+
105+
(*step in solving Permutation (a::t) (l1++l1') by attempting to find an instance of a in l1'
106+
and changing goal to (a::t) (l1 ++ a::l1')*)
107+
Ltac Permchange a t l1 l1' := match l1' with
108+
| cons a ?t' => change (Permutation (a::t) (l1 ++ a::t'))
109+
| cons ?b ?t' => Permchange a t (l1 ++ (b::nil)) t'
110+
end.
111+
112+
(*assumes lists are syntactic permutations, pre-simplified ! may fail if List.app terms present*)
113+
Ltac solve_list_perm := match goal with
114+
| |- Permutation ?l ?l' => try ap Permutation_refl;try (constructor;solve_list_perm);
115+
match l with
116+
| cons ?a ?t => Permchange a t (force_nil E) l';ap Permutation_cons_app;simpl;solve_list_perm
117+
end
118+
end.
119+
120+
End AAC_tools.
121+
122+
Module AAC_all.
123+
Export AAC_tools.
124+
125+
Lemma aac_perm_eq : forall op, (forall x y z, op x (op y z) = op (op x y) z) ->
126+
(forall x y, op x y = op y x) ->
127+
forall l l', Permutation l l' ->
128+
forall e, list_iter op e l = list_iter op e l'.
129+
Proof.
130+
ir. nin H1.
131+
tv.
132+
destruct l.
133+
assert (l' = nil).
134+
ap Permutation_nil. am. subst. tv.
135+
destruct l'.
136+
assert (e0::l = nil). ap Permutation_nil.
137+
ap Permutation_sym. am.
138+
inversion H2.
139+
transitivity (op x (list_iter op e (e0::l))).
140+
tv. rw IHPermutation. tv.
141+
destruct l. simpl.
142+
au.
143+
transitivity (op y (op x (list_iter op e (e0::l)))).
144+
tv. rw H. rw (H0 y). wr H. tv.
145+
etransitivity;au.
146+
Qed.
147+
148+
Ltac aa_normb_all Ha := repeat wr Ha.
149+
150+
Ltac aac_to_perm_all Ha Hc := try reflexivity;
151+
match type of Hc with
152+
| (forall x y, ?op x y = ?op y x) => aa_normb_all Ha; mk_iter op; ap (aac_perm_eq Ha Hc);simpl
153+
end.
154+
155+
Ltac aac_solve_all Ha Hc := aac_to_perm_all Ha Hc; solve_list_perm.
156+
157+
End AAC_all.
158+
159+
Module AAC_lci.
160+
Export AAC_tools.
161+
162+
163+
Lemma aac_perm_eq : forall op x, is_lci op x -> associative op x -> commutative op x ->
164+
forall l l', list_sub l x -> Permutation l l' -> forall e,
165+
list_iter op e l = list_iter op e l'.
166+
Proof.
167+
ir. cp (Permutation_sub H2 H3). nin H3.
168+
tv.
169+
170+
destruct l as [nil | x1 t].
171+
apply Permutation_nil in H3. subst.
172+
tv.
173+
destruct l' as [nil | x1' t'].
174+
symmetry in H3. apply Permutation_nil in H3. inversion H3.
175+
176+
change (op x0 (list_iter op e (x1::t)) = op x0 (list_iter op e (x1'::t'))).
177+
rw IHPermutation.
178+
tv. inversion H2;subst;au.
179+
inversion H4;subst;au.
180+
181+
destruct l.
182+
simpl. inversion H2;subst. inversion H8;subst. ap H1;au.
183+
184+
transitivity (op y (op x0 (list_iter op e (e0::l)))).
185+
simpl;tv.
186+
transitivity (op x0 (op y (list_iter op e (e0::l)))).
187+
assert (inc x0 x). inversion H4;subst;au.
188+
assert (inc y x). inversion H4;subst;au.
189+
inversion H2;au.
190+
assert (inc (list_iter op e (e0::l)) x).
191+
ap lci_list_nonempty_inc. am. inversion H2;subst;inversion H10;subst;au.
192+
uhg;ir. inversion H6.
193+
194+
transitivity (op (op y x0) (list_iter op e (e0::l))).
195+
rw H0;au.
196+
rw (H1 y H5 x0 H3). rw H0;au.
197+
198+
simpl. tv.
199+
200+
cp (Permutation_sub H2 H3_).
201+
rw IHPermutation1. ap IHPermutation2.
202+
am. am. am. am.
203+
Qed.
204+
205+
Ltac solve_lci_inc Hlci := first [ ap Hlci; solve_lci_inc Hlci | am | tv].
206+
207+
Ltac aa_normb_lci Hlci Ha := try (wr Ha;[aa_normb_lci Hlci Ha | solve_lci_inc Hlci | solve_lci_inc Hlci | solve_lci_inc Hlci]).
208+
209+
Ltac uf_list_sub := simpl;match goal with
210+
| |- list_sub nil _ => constructor
211+
| |- list_sub _ _ => constructor;[idtac | uf_list_sub]
212+
end.
213+
214+
Ltac aac_to_perm_lci op Hlci Ha Hc := try reflexivity;
215+
aa_normb_lci Hlci Ha; mk_iter op; ap (aac_perm_eq Hlci Ha Hc);simpl;[uf_list_sub | idtac]
216+
.
217+
218+
Ltac aac_solve_lci op Hlci Ha Hc := aac_to_perm_lci op Hlci Ha Hc; simpl;try solve_list_perm
219+
.
220+
221+
Ltac aac_solve_monoid Hmon Hc := match type of Hmon with
222+
| is_monoid ?op _ _ => aac_solve_lci op (and_P Hmon) (and_Q (and_Q Hmon)) Hc
223+
| is_group ?op _ _ => aac_solve_lci op (and_P Hmon) (and_P (and_Q (and_Q Hmon))) Hc
224+
end.
225+
226+
End AAC_lci.
227+
228+
229+

0 commit comments

Comments
 (0)