author | Christian Urban <urbanc@in.tum.de> |
Thu, 03 Dec 2009 11:33:24 +0100 | |
changeset 493 | 672b94510e7d |
parent 455 | 9cb45d022524 |
permissions | -rw-r--r-- |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
1 |
theory QuotMainNew |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports QuotScript QuotList Prove |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
uses ("quotient_info.ML") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
("quotient.ML") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
("quotient_def.ML") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
begin |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
locale QUOT_TYPE = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
fixes R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
and Abs :: "('a \<Rightarrow> bool) \<Rightarrow> 'b" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
and Rep :: "'b \<Rightarrow> ('a \<Rightarrow> bool)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
assumes equiv: "EQUIV R" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
and rep_prop: "\<And>y. \<exists>x. Rep y = R x" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
and rep_inverse: "\<And>x. Abs (Rep x) = x" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
and abs_inverse: "\<And>x. (Rep (Abs (R x))) = (R x)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
and rep_inject: "\<And>x y. (Rep x = Rep y) = (x = y)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
begin |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
definition |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
ABS::"'a \<Rightarrow> 'b" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
21 |
where |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
22 |
"ABS x \<equiv> Abs (R x)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
definition |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
25 |
REP::"'b \<Rightarrow> 'a" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
where |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
27 |
"REP a = Eps (Rep a)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
lemma lem9: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
30 |
shows "R (Eps (R x)) = R x" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
proof - |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
have a: "R x x" using equiv by (simp add: EQUIV_REFL_SYM_TRANS REFL_def) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
33 |
then have "R x (Eps (R x))" by (rule someI) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
then show "R (Eps (R x)) = R x" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
35 |
using equiv unfolding EQUIV_def by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
36 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
theorem thm10: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
39 |
shows "ABS (REP a) \<equiv> a" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
apply (rule eq_reflection) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
unfolding ABS_def REP_def |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
proof - |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
from rep_prop |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
obtain x where eq: "Rep a = R x" by auto |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
have "Abs (R (Eps (Rep a))) = Abs (R (Eps (R x)))" using eq by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
also have "\<dots> = Abs (R x)" using lem9 by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
also have "\<dots> = Abs (Rep a)" using eq by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
also have "\<dots> = a" using rep_inverse by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
49 |
finally |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
50 |
show "Abs (R (Eps (Rep a))) = a" by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
51 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
52 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
lemma REP_refl: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
54 |
shows "R (REP a) (REP a)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
unfolding REP_def |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
by (simp add: equiv[simplified EQUIV_def]) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
lemma lem7: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
shows "(R x = R y) = (Abs (R x) = Abs (R y))" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
apply(rule iffI) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
apply(simp) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
apply(drule rep_inject[THEN iffD2]) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
apply(simp add: abs_inverse) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
done |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
theorem thm11: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
shows "R r r' = (ABS r = ABS r')" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
unfolding ABS_def |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
by (simp only: equiv[simplified EQUIV_def] lem7) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
lemma REP_ABS_rsp: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
shows "R f (REP (ABS g)) = R f g" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
and "R (REP (ABS g)) f = R g f" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
by (simp_all add: thm10 thm11) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
76 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
lemma QUOTIENT: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
"QUOTIENT R ABS REP" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
apply(unfold QUOTIENT_def) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
apply(simp add: thm10) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
apply(simp add: REP_refl) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
apply(subst thm11[symmetric]) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
83 |
apply(simp add: equiv[simplified EQUIV_def]) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
84 |
done |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
lemma R_trans: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
assumes ab: "R a b" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
and bc: "R b c" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
shows "R a c" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
proof - |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
have tr: "TRANS R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
moreover have ab: "R a b" by fact |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
moreover have bc: "R b c" by fact |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
ultimately show "R a c" unfolding TRANS_def by blast |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
lemma R_sym: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
assumes ab: "R a b" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
shows "R b a" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
proof - |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
have re: "SYM R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
then show "R b a" using ab unfolding SYM_def by blast |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
103 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
lemma R_trans2: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
106 |
assumes ac: "R a c" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
and bd: "R b d" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
shows "R a b = R c d" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
using ac bd |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
by (blast intro: R_trans R_sym) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
lemma REPS_same: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
shows "R (REP a) (REP b) \<equiv> (a = b)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
proof - |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
have "R (REP a) (REP b) = (a = b)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
proof |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
assume as: "R (REP a) (REP b)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
from rep_prop |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
obtain x y |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
where eqs: "Rep a = R x" "Rep b = R y" by blast |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
from eqs have "R (Eps (R x)) (Eps (R y))" using as unfolding REP_def by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
then have "R x (Eps (R y))" using lem9 by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
then have "R (Eps (R y)) x" using R_sym by blast |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
124 |
then have "R y x" using lem9 by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
125 |
then have "R x y" using R_sym by blast |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
then have "ABS x = ABS y" using thm11 by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
then have "Abs (Rep a) = Abs (Rep b)" using eqs unfolding ABS_def by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
then show "a = b" using rep_inverse by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
next |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
130 |
assume ab: "a = b" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
have "REFL R" using equiv EQUIV_REFL_SYM_TRANS[of R] by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
then show "R (REP a) (REP b)" unfolding REFL_def using ab by auto |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
then show "R (REP a) (REP b) \<equiv> (a = b)" by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
135 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
136 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
138 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
139 |
lemma equiv_trans2: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
assumes e: "EQUIV R" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
and ac: "R a c" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
142 |
and bd: "R b d" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
143 |
shows "R a b = R c d" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
144 |
using ac bd e |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
145 |
unfolding EQUIV_REFL_SYM_TRANS TRANS_def SYM_def |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
146 |
by (blast) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
147 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
148 |
section {* type definition for the quotient type *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
149 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
150 |
(* the auxiliary data for the quotient types *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
151 |
use "quotient_info.ML" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
152 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
153 |
declare [[map list = (map, LIST_REL)]] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
154 |
declare [[map * = (prod_fun, prod_rel)]] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
declare [[map "fun" = (fun_map, FUN_REL)]] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
ML {* maps_lookup @{theory} "List.list" *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
158 |
ML {* maps_lookup @{theory} "*" *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
159 |
ML {* maps_lookup @{theory} "fun" *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
(* definition of the quotient types *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
(* FIXME: should be called quotient_typ.ML *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
use "quotient.ML" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
(* lifting of constants *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
use "quotient_def.ML" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
(* TODO: Consider defining it with an "if"; sth like: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
Babs p m = \<lambda>x. if x \<in> p then m x else undefined |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
*) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
definition |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
Babs :: "('a \<Rightarrow> bool) \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> 'a \<Rightarrow> 'b" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
175 |
where |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
"(x \<in> p) \<Longrightarrow> (Babs p m x = m x)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
section {* ATOMIZE *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
lemma atomize_eqv[atomize]: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
181 |
shows "(Trueprop A \<equiv> Trueprop B) \<equiv> (A \<equiv> B)" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
proof |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
assume "A \<equiv> B" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
then show "Trueprop A \<equiv> Trueprop B" by unfold |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
next |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
186 |
assume *: "Trueprop A \<equiv> Trueprop B" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
187 |
have "A = B" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
188 |
proof (cases A) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
case True |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
have "A" by fact |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
then show "A = B" using * by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
next |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
case False |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
have "\<not>A" by fact |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
then show "A = B" using * by auto |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
then show "A \<equiv> B" by (rule eq_reflection) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
qed |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
fun atomize_thm thm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
202 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
203 |
val thm' = Thm.freezeT (forall_intr_vars thm) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
204 |
val thm'' = ObjectLogic.atomize (cprop_of thm') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
@{thm equal_elim_rule1} OF [thm'', thm'] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
section {* infrastructure about id *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
lemma prod_fun_id: "prod_fun id id \<equiv> id" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
by (rule eq_reflection) (simp add: prod_fun_def) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
lemma map_id: "map id \<equiv> id" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
apply (rule eq_reflection) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
apply (rule ext) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
218 |
apply (rule_tac list="x" in list.induct) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
apply (simp_all) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
done |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
lemmas id_simps = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
FUN_MAP_I[THEN eq_reflection] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
id_apply[THEN eq_reflection] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
id_def[THEN eq_reflection,symmetric] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
prod_fun_id map_id |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
227 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
fun simp_ids thm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
MetaSimplifier.rewrite_rule @{thms id_simps} thm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
232 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
section {* Debugging infrastructure for testing tactics *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
235 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
fun my_print_tac ctxt s i thm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
val prem_str = nth (prems_of thm) (i - 1) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
|> Syntax.string_of_term ctxt |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
handle Subscript => "no subgoal" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
val _ = tracing (s ^ "\n" ^ prem_str) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
Seq.single thm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
244 |
end *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
fun DT ctxt s tac i thm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
250 |
val before_goal = nth (prems_of thm) (i - 1) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
251 |
|> Syntax.string_of_term ctxt |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
val before_msg = ["before: " ^ s, before_goal, "after: " ^ s] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
|> cat_lines |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
EVERY [tac i, my_print_tac ctxt before_msg i] thm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
fun NDT ctxt s tac thm = tac thm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
261 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
262 |
section {* Infrastructure for special quotient identity *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
263 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
definition |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
"qid TYPE('a) TYPE('b) x \<equiv> x" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
266 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
fun get_typ_aux (Type ("itself", [T])) = T |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
fun get_typ (Const ("TYPE", T)) = get_typ_aux T |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
fun get_tys (Const (@{const_name "qid"},_) $ ty1 $ ty2) = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
(get_typ ty1, get_typ ty2) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
fun is_qid (Const (@{const_name "qid"},_) $ _ $ _) = true |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
| is_qid _ = false |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
fun mk_itself ty = Type ("itself", [ty]) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
fun mk_TYPE ty = Const ("TYPE", mk_itself ty) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
fun mk_qid (rty, qty, trm) = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
Const (@{const_name "qid"}, [mk_itself rty, mk_itself qty, dummyT] ---> dummyT) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
281 |
$ mk_TYPE rty $ mk_TYPE qty $ trm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
ML {* |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
285 |
fun insertion_aux (rtrm, qtrm) = |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
286 |
case (rtrm, qtrm) of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
(Abs (x, ty, t), Abs (x', ty', t')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
val (y, s) = Term.dest_abs (x, ty, t) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
val (_, s') = Term.dest_abs (x', ty', t') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
val yvar = Free (y, ty) |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
292 |
val result = Term.lambda_name (y, yvar) (insertion_aux (s, s')) |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
294 |
if ty = ty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
then result |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
296 |
else mk_qid (ty, ty', result) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
297 |
end |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
298 |
| (_ $ _, _ $ _) => |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
val rty = fastype_of rtrm |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
301 |
val qty = fastype_of qtrm |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
302 |
val (rhead, rargs) = strip_comb rtrm |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
303 |
val (qhead, qargs) = strip_comb qtrm |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
304 |
val rargs' = map insertion_aux (rargs ~~ qargs) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
305 |
val rhead' = insertion_aux (rhead, qhead) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
306 |
val result = list_comb (rhead', rargs') |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
307 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
308 |
if rty = qty |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
309 |
then result |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
310 |
else mk_qid (rty, qty, result) |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
311 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
312 |
| (Free (_, ty), Free (_, ty')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
313 |
if ty = ty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
314 |
then rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
else mk_qid (ty, ty', rtrm) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
| (Const (s, ty), Const (s', ty')) => |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
317 |
if s = s' |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
318 |
then rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
319 |
else mk_qid (ty, ty', rtrm) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
320 |
| (_, _) => raise (LIFT_MATCH "insertion") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
321 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
|
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
323 |
ML {* |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
324 |
fun insertion ctxt rtrm qtrm = |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
325 |
Syntax.check_term ctxt (insertion_aux (rtrm, qtrm)) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
326 |
*} |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
327 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
328 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
329 |
fun |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
330 |
intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" (infix "\<approx>" 50) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
331 |
where |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
332 |
"intrel (x, y) (u, v) = (x + v = u + y)" |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
333 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
334 |
quotient my_int = "nat \<times> nat" / intrel |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
335 |
apply(unfold EQUIV_def) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
336 |
apply(auto simp add: mem_def expand_fun_eq) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
337 |
done |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
338 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
339 |
fun |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
340 |
my_plus :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)" |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
341 |
where |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
342 |
"my_plus (x, y) (u, v) = (x + u, y + v)" |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
343 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
344 |
quotient_def |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
345 |
PLUS::"my_int \<Rightarrow> my_int \<Rightarrow> my_int" |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
346 |
where |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
347 |
"PLUS \<equiv> my_plus" |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
348 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
349 |
thm PLUS_def |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
350 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
351 |
ML {* MetaSimplifier.rewrite_term *} |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
352 |
|
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
353 |
ML {* |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
354 |
let |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
355 |
val rtrm = @{term "\<forall>a b. my_plus a b \<approx> my_plus b a"} |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
356 |
val qtrm = @{term "\<forall>a b. PLUS a b = PLUS b a"} |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
357 |
val ctxt = @{context} |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
358 |
in |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
359 |
insertion ctxt rtrm qtrm |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
360 |
(*|> Drule.term_rule @{theory} (MetaSimplifier.rewrite_rule [@{thm "qid_def"}])*) |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
361 |
|> Syntax.string_of_term ctxt |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
362 |
|> writeln |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
363 |
end |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
364 |
*} |
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
365 |
|
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
366 |
section {* Regularization *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
367 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
368 |
(* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
369 |
Regularizing an rtrm means: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
370 |
- quantifiers over a type that needs lifting are replaced by |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
371 |
bounded quantifiers, for example: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
372 |
\<forall>x. P \<Longrightarrow> \<forall>x \<in> (Respects R). P / All (Respects R) P |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
373 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
374 |
the relation R is given by the rty and qty; |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
375 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
376 |
- abstractions over a type that needs lifting are replaced |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
377 |
by bounded abstractions: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
378 |
\<lambda>x. P \<Longrightarrow> Ball (Respects R) (\<lambda>x. P) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
379 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
380 |
- equalities over the type being lifted are replaced by |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
381 |
corresponding relations: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
A = B \<Longrightarrow> A \<approx> B |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
383 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
384 |
example with more complicated types of A, B: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
385 |
A = B \<Longrightarrow> (op = \<Longrightarrow> op \<approx>) A B |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
386 |
*) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
387 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
388 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
389 |
(* builds the relation that is the argument of respects *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
390 |
fun mk_resp_arg lthy (rty, qty) = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
391 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
392 |
val thy = ProofContext.theory_of lthy |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
393 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
394 |
if rty = qty |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
395 |
then HOLogic.eq_const rty |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
396 |
else |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
case (rty, qty) of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
398 |
(Type (s, tys), Type (s', tys')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
399 |
if s = s' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
400 |
then let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
401 |
val SOME map_info = maps_lookup thy s |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
402 |
val args = map (mk_resp_arg lthy) (tys ~~ tys') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
403 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
404 |
list_comb (Const (#relfun map_info, dummyT), args) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
405 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
406 |
else let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
407 |
val SOME qinfo = quotdata_lookup_thy thy s' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
408 |
(* FIXME: check in this case that the rty and qty *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
409 |
(* FIXME: correspond to each other *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
410 |
val (s, _) = dest_Const (#rel qinfo) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
411 |
(* FIXME: the relation should only be the string *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
412 |
(* FIXME: and the type needs to be calculated as below; *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
413 |
(* FIXME: maybe one should actually have a term *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
414 |
(* FIXME: and one needs to force it to have this type *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
415 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
Const (s, rty --> rty --> @{typ bool}) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
418 |
| _ => HOLogic.eq_const dummyT |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
419 |
(* FIXME: check that the types correspond to each other? *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
420 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
421 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
422 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
423 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
424 |
val mk_babs = Const (@{const_name "Babs"}, dummyT) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
425 |
val mk_ball = Const (@{const_name "Ball"}, dummyT) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
426 |
val mk_bex = Const (@{const_name "Bex"}, dummyT) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
427 |
val mk_resp = Const (@{const_name Respects}, dummyT) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
428 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
429 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
430 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
431 |
(* - applies f to the subterm of an abstraction, *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
432 |
(* otherwise to the given term, *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
433 |
(* - used by regularize, therefore abstracted *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
434 |
(* variables do not have to be treated specially *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
435 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
436 |
fun apply_subt f trm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
437 |
case trm of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
438 |
(Abs (x, T, t)) => Abs (x, T, f t) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
439 |
| _ => f trm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
440 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
441 |
(* the major type of All and Ex quantifiers *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
442 |
fun qnt_typ ty = domain_type (domain_type ty) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
443 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
444 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
445 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
446 |
(* produces a regularized version of trm *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
447 |
(* - the result is still not completely typed *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
448 |
(* - does not need any special treatment of *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
449 |
(* bound variables *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
450 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
451 |
fun regularize_trm lthy trm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
452 |
case trm of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
453 |
(Const (@{const_name "qid"},_) $ rty' $ qty' $ Abs (x, ty, t)) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
454 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
455 |
val rty = get_typ rty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
456 |
val qty = get_typ qty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
457 |
val subtrm = regularize_trm lthy t |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
458 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
459 |
mk_qid (rty, qty, mk_babs $ (mk_resp $ mk_resp_arg lthy (rty, qty)) $ subtrm) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
460 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
461 |
| (Const (@{const_name "qid"},_) $ rty' $ qty' $ (Const (@{const_name "All"}, ty) $ t)) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
462 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
463 |
val subtrm = apply_subt (regularize_trm lthy) t |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
464 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
465 |
if ty = ty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
466 |
then Const (@{const_name "All"}, ty) $ subtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
467 |
else mk_ball $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
468 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
469 |
| (Const (@{const_name "Ex"}, ty) $ t, Const (@{const_name "Ex"}, ty') $ t') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
470 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
471 |
val subtrm = apply_subt (regularize_trm lthy) t t' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
472 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
473 |
if ty = ty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
474 |
then Const (@{const_name "Ex"}, ty) $ subtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
475 |
else mk_bex $ (mk_resp $ mk_resp_arg lthy (qnt_typ ty, qnt_typ ty')) $ subtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
476 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
477 |
(* FIXME: Should = only be replaced, when fully applied? *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
478 |
(* Then there must be a 2nd argument *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
479 |
| (Const (@{const_name "op ="}, ty) $ t, Const (@{const_name "op ="}, ty') $ t') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
480 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
481 |
val subtrm = regularize_trm lthy t t' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
482 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
483 |
if ty = ty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
484 |
then Const (@{const_name "op ="}, ty) $ subtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
485 |
else mk_resp_arg lthy (domain_type ty, domain_type ty') $ subtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
486 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
487 |
| (t1 $ t2, t1' $ t2') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
488 |
(regularize_trm lthy t1 t1') $ (regularize_trm lthy t2 t2') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
489 |
| (Free (x, ty), Free (x', ty')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
490 |
(* this case cannot arrise as we start with two fully atomized terms *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
491 |
raise (LIFT_MATCH "regularize (frees)") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
492 |
| (Bound i, Bound i') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
493 |
if i = i' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
494 |
then rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
495 |
else raise (LIFT_MATCH "regularize (bounds)") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
496 |
| (Const (s, ty), Const (s', ty')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
497 |
if s = s' andalso ty = ty' |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
498 |
then rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
499 |
else rtrm (* FIXME: check correspondence according to definitions *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
500 |
| (rt, qt) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
501 |
raise (LIFT_MATCH "regularize (default)") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
502 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
503 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
504 |
(* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
505 |
FIXME / TODO: needs to be adapted |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
506 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
507 |
To prove that the raw theorem implies the regularised one, |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
508 |
we try in order: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
509 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
510 |
- Reflexivity of the relation |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
511 |
- Assumption |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
512 |
- Elimnating quantifiers on both sides of toplevel implication |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
513 |
- Simplifying implications on both sides of toplevel implication |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
514 |
- Ball (Respects ?E) ?P = All ?P |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
515 |
- (\<And>x. ?R x \<Longrightarrow> ?P x \<longrightarrow> ?Q x) \<Longrightarrow> All ?P \<longrightarrow> Ball ?R ?Q |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
516 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
517 |
*) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
518 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
519 |
section {* Injections of REP and ABSes *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
520 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
521 |
(* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
522 |
Injecting REPABS means: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
523 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
524 |
For abstractions: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
525 |
* If the type of the abstraction doesn't need lifting we recurse. |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
526 |
* If it does we add RepAbs around the whole term and check if the |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
527 |
variable needs lifting. |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
528 |
* If it doesn't then we recurse |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
529 |
* If it does we recurse and put 'RepAbs' around all occurences |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
530 |
of the variable in the obtained subterm. This in combination |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
531 |
with the RepAbs above will let us change the type of the |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
532 |
abstraction with rewriting. |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
533 |
For applications: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
534 |
* If the term is 'Respects' applied to anything we leave it unchanged |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
535 |
* If the term needs lifting and the head is a constant that we know |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
536 |
how to lift, we put a RepAbs and recurse |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
537 |
* If the term needs lifting and the head is a free applied to subterms |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
538 |
(if it is not applied we treated it in Abs branch) then we |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
539 |
put RepAbs and recurse |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
540 |
* Otherwise just recurse. |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
541 |
*) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
542 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
543 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
544 |
fun mk_repabs lthy (T, T') trm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
545 |
Quotient_Def.get_fun repF lthy (T, T') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
546 |
$ (Quotient_Def.get_fun absF lthy (T, T') $ trm) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
547 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
548 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
549 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
550 |
(* bound variables need to be treated properly, *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
551 |
(* as the type of subterms need to be calculated *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
552 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
553 |
fun inj_repabs_trm lthy (rtrm, qtrm) = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
554 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
555 |
val rty = fastype_of rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
556 |
val qty = fastype_of qtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
557 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
558 |
case (rtrm, qtrm) of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
559 |
(Const (@{const_name "Ball"}, T) $ r $ t, Const (@{const_name "All"}, _) $ t') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
560 |
Const (@{const_name "Ball"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
561 |
| (Const (@{const_name "Bex"}, T) $ r $ t, Const (@{const_name "Ex"}, _) $ t') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
562 |
Const (@{const_name "Bex"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
563 |
| (Const (@{const_name "Babs"}, T) $ r $ t, t') => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
564 |
Const (@{const_name "Babs"}, T) $ r $ (inj_repabs_trm lthy (t, t')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
565 |
| (Abs (x, T, t), Abs (x', T', t')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
566 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
567 |
val (y, s) = Term.dest_abs (x, T, t) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
568 |
val (_, s') = Term.dest_abs (x', T', t') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
569 |
val yvar = Free (y, T) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
570 |
val result = Term.lambda_name (y, yvar) (inj_repabs_trm lthy (s, s')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
571 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
572 |
if rty = qty |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
573 |
then result |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
574 |
else mk_repabs lthy (rty, qty) result |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
575 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
576 |
| _ => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
577 |
(* FIXME / TODO: this is a case that needs to be looked at *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
578 |
(* - variables get a rep-abs insde and outside an application *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
579 |
(* - constants only get a rep-abs on the outside of the application *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
580 |
(* - applications get a rep-abs insde and outside an application *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
581 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
582 |
val (rhead, rargs) = strip_comb rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
583 |
val (qhead, qargs) = strip_comb qtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
584 |
val rargs' = map (inj_repabs_trm lthy) (rargs ~~ qargs) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
585 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
586 |
if rty = qty |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
587 |
then |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
588 |
case (rhead, qhead) of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
589 |
(Free (_, T), Free (_, T')) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
590 |
if T = T' then list_comb (rhead, rargs') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
591 |
else list_comb (mk_repabs lthy (T, T') rhead, rargs') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
592 |
| _ => list_comb (rhead, rargs') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
593 |
else |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
594 |
case (rhead, qhead, length rargs') of |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
595 |
(Const _, Const _, 0) => mk_repabs lthy (rty, qty) rhead |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
596 |
| (Free (_, T), Free (_, T'), 0) => mk_repabs lthy (T, T') rhead |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
597 |
| (Const _, Const _, _) => mk_repabs lthy (rty, qty) (list_comb (rhead, rargs')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
598 |
| (Free (x, T), Free (x', T'), _) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
599 |
mk_repabs lthy (rty, qty) (list_comb (mk_repabs lthy (T, T') rhead, rargs')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
600 |
| (Abs _, Abs _, _ ) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
601 |
mk_repabs lthy (rty, qty) (list_comb (inj_repabs_trm lthy (rhead, qhead), rargs')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
602 |
| _ => raise (LIFT_MATCH "injection") |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
603 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
604 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
605 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
606 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
607 |
section {* Genralisation of free variables in a goal *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
608 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
609 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
610 |
fun inst_spec ctrm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
611 |
Drule.instantiate' [SOME (ctyp_of_term ctrm)] [NONE, SOME ctrm] @{thm spec} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
612 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
613 |
fun inst_spec_tac ctrms = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
614 |
EVERY' (map (dtac o inst_spec) ctrms) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
615 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
616 |
fun all_list xs trm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
617 |
fold (fn (x, T) => fn t' => HOLogic.mk_all (x, T, t')) xs trm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
618 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
619 |
fun apply_under_Trueprop f = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
620 |
HOLogic.dest_Trueprop #> f #> HOLogic.mk_Trueprop |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
621 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
622 |
fun gen_frees_tac ctxt = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
623 |
SUBGOAL (fn (concl, i) => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
624 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
625 |
val thy = ProofContext.theory_of ctxt |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
626 |
val vrs = Term.add_frees concl [] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
627 |
val cvrs = map (cterm_of thy o Free) vrs |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
628 |
val concl' = apply_under_Trueprop (all_list vrs) concl |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
629 |
val goal = Logic.mk_implies (concl', concl) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
630 |
val rule = Goal.prove ctxt [] [] goal |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
631 |
(K (EVERY1 [inst_spec_tac (rev cvrs), atac])) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
632 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
633 |
rtac rule i |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
634 |
end) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
635 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
636 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
637 |
section {* General outline of the lifting procedure *} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
638 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
639 |
(* - A is the original raw theorem *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
640 |
(* - B is the regularized theorem *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
641 |
(* - C is the rep/abs injected version of B *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
642 |
(* - D is the lifted theorem *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
643 |
(* *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
644 |
(* - b is the regularization step *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
645 |
(* - c is the rep/abs injection step *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
646 |
(* - d is the cleaning part *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
647 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
648 |
lemma lifting_procedure: |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
649 |
assumes a: "A" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
650 |
and b: "A \<Longrightarrow> B" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
651 |
and c: "B = C" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
652 |
and d: "C = D" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
653 |
shows "D" |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
654 |
using a b c d |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
655 |
by simp |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
656 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
657 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
658 |
fun lift_match_error ctxt fun_str rtrm qtrm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
659 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
660 |
val rtrm_str = Syntax.string_of_term ctxt rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
661 |
val qtrm_str = Syntax.string_of_term ctxt qtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
662 |
val msg = [enclose "[" "]" fun_str, "The quotient theorem\n", qtrm_str, |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
663 |
"and the lifted theorem\n", rtrm_str, "do not match"] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
664 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
665 |
error (space_implode " " msg) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
666 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
667 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
668 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
669 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
670 |
fun procedure_inst ctxt rtrm qtrm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
671 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
672 |
val thy = ProofContext.theory_of ctxt |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
673 |
val rtrm' = HOLogic.dest_Trueprop rtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
674 |
val qtrm' = HOLogic.dest_Trueprop qtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
675 |
val reg_goal = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
676 |
Syntax.check_term ctxt (regularize_trm ctxt rtrm' qtrm') |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
677 |
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
678 |
val inj_goal = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
679 |
Syntax.check_term ctxt (inj_repabs_trm ctxt (reg_goal, qtrm')) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
680 |
handle (LIFT_MATCH s) => lift_match_error ctxt s rtrm qtrm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
681 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
682 |
Drule.instantiate' [] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
683 |
[SOME (cterm_of thy rtrm'), |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
684 |
SOME (cterm_of thy reg_goal), |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
685 |
SOME (cterm_of thy inj_goal)] @{thm lifting_procedure} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
686 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
687 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
688 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
689 |
(* Left for debugging *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
690 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
691 |
fun procedure_tac lthy rthm = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
692 |
ObjectLogic.full_atomize_tac |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
693 |
THEN' gen_frees_tac lthy |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
694 |
THEN' Subgoal.FOCUS (fn {context, concl, ...} => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
695 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
696 |
val rthm' = atomize_thm rthm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
697 |
val rule = procedure_inst context (prop_of rthm') (term_of concl) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
698 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
699 |
EVERY1 [rtac rule, rtac rthm'] |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
700 |
end) lthy |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
701 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
702 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
703 |
ML {* |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
704 |
(* FIXME/TODO should only get as arguments the rthm like procedure_tac *) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
705 |
fun lift_tac lthy rthm rel_eqv rty quot defs = |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
706 |
ObjectLogic.full_atomize_tac |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
707 |
THEN' gen_frees_tac lthy |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
708 |
THEN' Subgoal.FOCUS (fn {context, concl, ...} => |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
709 |
let |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
710 |
val rthm' = atomize_thm rthm |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
711 |
val rule = procedure_inst context (prop_of rthm') (term_of concl) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
712 |
val aps = find_aps (prop_of rthm') (term_of concl) |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
713 |
val rel_refl = map (fn x => @{thm EQUIV_REFL} OF [x]) rel_eqv |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
714 |
val trans2 = map (fn x => @{thm equiv_trans2} OF [x]) rel_eqv |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
715 |
in |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
716 |
EVERY1 |
455
9cb45d022524
tried to improve the inj_repabs_trm function but left the new part commented out
Christian Urban <urbanc@in.tum.de>
parents:
454
diff
changeset
|
717 |
[rtac rule, rtac rthm'] |
454
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
718 |
end) lthy |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
719 |
*} |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
720 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
721 |
end |
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
722 |
|
cc0b9cb367cd
added a new version of QuotMain to experiment with qids
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
723 |