181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
theory IntEx
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
imports QuotMain
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
begin
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
fun
|
281
|
6 |
intrel :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool" (infix "\<approx>" 50)
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
"intrel (x, y) (u, v) = (x + v = u + y)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
quotient my_int = "nat \<times> nat" / intrel
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
apply(unfold EQUIV_def)
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
apply(auto simp add: mem_def expand_fun_eq)
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
done
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
15 |
thm my_int_equiv
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
16 |
|
239
|
17 |
print_theorems
|
274
|
18 |
print_quotients
|
239
|
19 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
20 |
quotient_def
|
218
|
21 |
ZERO::"my_int"
|
|
22 |
where
|
|
23 |
"ZERO \<equiv> (0::nat, 0::nat)"
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
24 |
|
318
|
25 |
ML {* print_qconstinfo @{context} *}
|
|
26 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
27 |
term ZERO
|
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
28 |
thm ZERO_def
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
|
290
a0be84b0c707
removed typing information from get_fun in quotient_def; *potentially* dangerous
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
30 |
ML {* prop_of @{thm ZERO_def} *}
|
a0be84b0c707
removed typing information from get_fun in quotient_def; *potentially* dangerous
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
31 |
|
318
|
32 |
ML {* separate *}
|
|
33 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
34 |
quotient_def
|
218
|
35 |
ONE::"my_int"
|
193
|
36 |
where
|
218
|
37 |
"ONE \<equiv> (1::nat, 0::nat)"
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
|
318
|
39 |
ML {* print_qconstinfo @{context} *}
|
|
40 |
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
term ONE
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
42 |
thm ONE_def
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
43 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
44 |
fun
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
45 |
my_plus :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
46 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
47 |
"my_plus (x, y) (u, v) = (x + u, y + v)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
48 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
49 |
quotient_def
|
218
|
50 |
PLUS::"my_int \<Rightarrow> my_int \<Rightarrow> my_int"
|
|
51 |
where
|
275
|
52 |
"PLUS \<equiv> my_plus"
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
53 |
|
318
|
54 |
term my_plus
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
55 |
term PLUS
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
thm PLUS_def
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
fun
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
my_neg :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
"my_neg (x, y) = (y, x)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
62 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
63 |
quotient_def
|
220
|
64 |
NEG::"my_int \<Rightarrow> my_int"
|
|
65 |
where
|
|
66 |
"NEG \<equiv> my_neg"
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
term NEG
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
thm NEG_def
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
definition
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
MINUS :: "my_int \<Rightarrow> my_int \<Rightarrow> my_int"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
"MINUS z w = PLUS z (NEG w)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
76 |
fun
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
my_mult :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> (nat \<times> nat)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
"my_mult (x, y) (u, v) = (x*u + y*v, x*v + y*u)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
81 |
quotient_def
|
220
|
82 |
MULT::"my_int \<Rightarrow> my_int \<Rightarrow> my_int"
|
|
83 |
where
|
|
84 |
"MULT \<equiv> my_mult"
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
85 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
86 |
term MULT
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
87 |
thm MULT_def
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
(* NOT SURE WETHER THIS DEFINITION IS CORRECT *)
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
fun
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
91 |
my_le :: "(nat \<times> nat) \<Rightarrow> (nat \<times> nat) \<Rightarrow> bool"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
"my_le (x, y) (u, v) = (x+v \<le> u+y)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
|
268
4d58c02289ca
simplified the quotient_def code; type of the defined constant must now be given; for-part eliminated
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
95 |
quotient_def
|
220
|
96 |
LE :: "my_int \<Rightarrow> my_int \<Rightarrow> bool"
|
|
97 |
where
|
|
98 |
"LE \<equiv> my_le"
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
100 |
term LE
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
thm LE_def
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
103 |
|
181
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
definition
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
LESS :: "my_int \<Rightarrow> my_int \<Rightarrow> bool"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
106 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
"LESS z w = (LE z w \<and> z \<noteq> w)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
109 |
term LESS
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
thm LESS_def
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
definition
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
113 |
ABS :: "my_int \<Rightarrow> my_int"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
"ABS i = (if (LESS i ZERO) then (NEG i) else i)"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
definition
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
118 |
SIGN :: "my_int \<Rightarrow> my_int"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
119 |
where
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
120 |
"SIGN i = (if i = ZERO then ZERO else if (LESS ZERO i) then ONE else (NEG ONE))"
|
3e53081ad53a
added another example file about integers (see HOL/Int.thy)
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
|
310
fec6301a1989
added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
122 |
ML {* print_qconstinfo @{context} *}
|
fec6301a1989
added a container for quotient constants (does not work yet though)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
123 |
|
199
|
124 |
lemma plus_sym_pre:
|
281
|
125 |
shows "my_plus a b \<approx> my_plus b a"
|
199
|
126 |
apply(cases a)
|
|
127 |
apply(cases b)
|
|
128 |
apply(auto)
|
|
129 |
done
|
|
130 |
|
206
|
131 |
lemma ho_plus_rsp:
|
228
|
132 |
"(intrel ===> intrel ===> intrel) my_plus my_plus"
|
192
|
133 |
by (simp)
|
|
134 |
|
|
135 |
ML {* val qty = @{typ "my_int"} *}
|
239
|
136 |
ML {* val ty_name = "my_int" *}
|
192
|
137 |
ML {* val rsp_thms = @{thms ho_plus_rsp} @ @{thms ho_all_prs ho_ex_prs} *}
|
260
59578f428bbe
Fixes after optimization and preparing for a general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
138 |
ML {* val defs = @{thms PLUS_def} *}
|
197
|
139 |
|
198
|
140 |
ML {*
|
|
141 |
fun lift_thm_my_int lthy t =
|
260
59578f428bbe
Fixes after optimization and preparing for a general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
142 |
lift_thm lthy qty ty_name rsp_thms defs t
|
239
|
143 |
*}
|
|
144 |
|
312
4cf79f70efec
looking up data in quot_info works now (needs qualified string)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
145 |
print_quotients
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
146 |
ML {* quotdata_lookup @{context} "IntEx.my_int" *}
|
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
147 |
ML {* quotdata_lookup @{context} "my_int" *}
|
312
4cf79f70efec
looking up data in quot_info works now (needs qualified string)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
148 |
|
319
|
149 |
ML {*
|
|
150 |
val test = lift_thm_my_int @{context} @{thm plus_sym_pre}
|
|
151 |
*}
|
|
152 |
|
|
153 |
ML {*
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
154 |
val aqtrm = (prop_of (atomize_thm test))
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
155 |
val artrm = (prop_of (atomize_thm @{thm plus_sym_pre}))
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
156 |
val reg_artm = mk_REGULARIZE_goal @{context} artrm aqtrm
|
319
|
157 |
*}
|
198
|
158 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
159 |
prove {* reg_artm *}
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
160 |
apply(tactic {* ObjectLogic.full_atomize_tac 1 *})
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
161 |
apply(tactic {* REGULARIZE_tac' @{context} @{thm "TrueI"} @{thm my_int_equiv} *})
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
162 |
done
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
163 |
|
330
|
164 |
(* rep-abs injection *)
|
|
165 |
|
326
|
166 |
ML {*
|
330
|
167 |
(* FIXME: is this the right get_fun function for rep-abs injection *)
|
326
|
168 |
fun mk_repabs lthy (T, T') trm =
|
|
169 |
Quotient_Def.get_fun repF lthy (T, T')
|
|
170 |
$ (Quotient_Def.get_fun absF lthy (T, T') $ trm)
|
|
171 |
*}
|
|
172 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
173 |
ML {*
|
330
|
174 |
(* replaces a term for the bound variable, *)
|
|
175 |
(* possible capture *)
|
326
|
176 |
fun replace_bnd0 (trm, Abs (x, T, t)) =
|
|
177 |
Abs (x, T, subst_bound (trm, t))
|
|
178 |
*}
|
|
179 |
|
|
180 |
ML {*
|
330
|
181 |
(* bound variables need to be treated properly, *)
|
|
182 |
(* as the type of subterms need to be calculated *)
|
|
183 |
|
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
184 |
fun inj_REPABS lthy (rtrm, qtrm) =
|
326
|
185 |
let
|
|
186 |
val rty = fastype_of rtrm
|
|
187 |
val qty = fastype_of qtrm
|
|
188 |
in
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
189 |
case (rtrm, qtrm) of
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
190 |
(Abs (x, T, t), Abs (x', T', t')) =>
|
330
|
191 |
let
|
|
192 |
val (y, s) = Term.dest_abs (x, T, t)
|
|
193 |
val (y', s') = Term.dest_abs (x', T', t')
|
|
194 |
val yvar = Free (y, T)
|
|
195 |
val res = lambda yvar (inj_REPABS lthy (s, s'))
|
|
196 |
in
|
|
197 |
if T = T'
|
|
198 |
then res
|
|
199 |
else mk_repabs lthy (rty, qty) (replace_bnd0 (mk_repabs lthy (T, T') (Bound 0), res))
|
|
200 |
end
|
|
201 |
(* FIXME: Does one have to look at the abstraction or have to go under the lambda? *)
|
326
|
202 |
| (Const (@{const_name "Ball"}, T) $ r $ t, Const (@{const_name "All"}, _) $ t') =>
|
330
|
203 |
Const (@{const_name "Ball"}, T) $ r $ (inj_REPABS lthy (t, t'))
|
326
|
204 |
| (Const (@{const_name "Bex"}, T) $ r $ t, Const (@{const_name "Ex"}, _) $ t') =>
|
330
|
205 |
Const (@{const_name "Bex"}, T) $ r $ (inj_REPABS lthy (t, t'))
|
|
206 |
| (_ $ _, _ $ _) =>
|
|
207 |
let
|
|
208 |
val (rhead, rargs) = strip_comb rtrm
|
|
209 |
val (qhead, qargs) = strip_comb qtrm
|
|
210 |
val rhead' = inj_REPABS lthy (rhead, qhead)
|
|
211 |
val rargs' = map (inj_REPABS lthy) (rargs ~~ qargs)
|
|
212 |
val result = list_comb (rhead', rargs')
|
|
213 |
in
|
|
214 |
if rty = qty
|
|
215 |
then result
|
|
216 |
else mk_repabs lthy (rty, qty) res
|
|
217 |
end
|
|
218 |
(* FIXME: cases for frees and vars? *)
|
326
|
219 |
| _ => rtrm
|
|
220 |
end
|
|
221 |
*}
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
222 |
|
326
|
223 |
ML {*
|
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
224 |
fun mk_inj_REPABS_goal lthy (rtrm, qtrm) =
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
225 |
Logic.mk_equals (rtrm, Syntax.check_term lthy (inj_REPABS lthy (rtrm, qtrm)))
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
226 |
*}
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
227 |
|
198
|
228 |
lemma plus_assoc_pre:
|
281
|
229 |
shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)"
|
198
|
230 |
apply (cases i)
|
|
231 |
apply (cases j)
|
|
232 |
apply (cases k)
|
224
|
233 |
apply (simp)
|
198
|
234 |
done
|
|
235 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
236 |
ML {* val test2 = lift_thm_my_int @{context} @{thm plus_assoc_pre} *}
|
224
|
237 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
238 |
ML {*
|
326
|
239 |
val arthm = atomize_thm @{thm plus_assoc_pre}
|
|
240 |
val aqthm = atomize_thm test2
|
|
241 |
|
|
242 |
val aqtrm = prop_of aqthm
|
|
243 |
val artrm = prop_of arthm
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
244 |
*}
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
245 |
|
326
|
246 |
prove testtest: {* mk_REGULARIZE_goal @{context} artrm aqtrm *}
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
247 |
apply(tactic {* ObjectLogic.full_atomize_tac 1 *})
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
248 |
apply(tactic {* REGULARIZE_tac' @{context} @{thm "TrueI"} @{thm my_int_equiv} *})
|
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
249 |
done
|
224
|
250 |
|
326
|
251 |
ML {* @{thm testtest} OF [arthm] *}
|
|
252 |
|
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
253 |
ML {* val reg_atrm = prop_of (@{thm testtest} OF [arthm]) *}
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
254 |
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
255 |
ML {*
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
256 |
fun r_mk_comb_tac ctxt rty quot_thm reflex_thm trans_thm rsp_thms =
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
257 |
(REPEAT1 o FIRST1)
|
328
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
258 |
[(K (print_tac "start")) THEN' (K no_tac),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
259 |
DT ctxt "1" (rtac trans_thm),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
260 |
DT ctxt "2" (LAMBDA_RES_TAC ctxt),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
261 |
DT ctxt "3" (ball_rsp_tac ctxt),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
262 |
DT ctxt "4" (bex_rsp_tac ctxt),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
263 |
DT ctxt "5" (FIRST' (map rtac rsp_thms)),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
264 |
DT ctxt "6" (instantiate_tac @{thm REP_ABS_RSP(1)} ctxt THEN' (RANGE [quotient_tac quot_thm])),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
265 |
DT ctxt "7" (rtac refl),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
266 |
DT ctxt "8" (APPLY_RSP_TAC rty ctxt THEN' (RANGE [quotient_tac quot_thm, quotient_tac quot_thm])),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
267 |
DT ctxt "9" (Cong_Tac.cong_tac @{thm cong}),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
268 |
DT ctxt "A" (rtac @{thm ext}),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
269 |
DT ctxt "B" (rtac reflex_thm),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
270 |
DT ctxt "C" (atac),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
271 |
DT ctxt "D" (SOLVES' (simp_tac (HOL_ss addsimps @{thms FUN_REL.simps}))),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
272 |
DT ctxt "E" (WEAK_LAMBDA_RES_TAC ctxt),
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
273 |
DT ctxt "F" (CHANGED' (asm_full_simp_tac (HOL_ss addsimps @{thms FUN_REL_EQ})))]
|
326
|
274 |
*}
|
|
275 |
|
|
276 |
ML {*
|
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
277 |
val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} @{typ "my_int"}
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
278 |
val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int"
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
279 |
val consts = lookup_quot_consts defs
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
280 |
*}
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
281 |
|
328
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
282 |
ML {* cprem_of *}
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
283 |
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
284 |
ML {*
|
330
|
285 |
mk_inj_REPABS_goal @{context} (reg_atrm, aqtrm)
|
|
286 |
|> Syntax.check_term @{context}
|
328
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
287 |
*}
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
288 |
|
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
289 |
prove {* mk_inj_REPABS_goal @{context} (reg_atrm, aqtrm) *}
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
290 |
apply(tactic {* ObjectLogic.full_atomize_tac 1 *})
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
291 |
(* does not work *)
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
292 |
apply(tactic {* r_mk_comb_tac @{context} rty quot rel_refl trans2 rsp_thms *})
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
293 |
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
294 |
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
295 |
ML {*
|
326
|
296 |
inj_REPABS @{context} (reg_atrm, aqtrm)
|
|
297 |
|> Syntax.string_of_term @{context}
|
|
298 |
|> writeln
|
|
299 |
*}
|
|
300 |
|
|
301 |
|
281
|
302 |
lemma ho_tst: "foldl my_plus x [] = x"
|
|
303 |
apply simp
|
|
304 |
done
|
276
|
305 |
|
224
|
306 |
text {* Below is the construction site code used if things do not work *}
|
276
|
307 |
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *}
|
|
308 |
ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int" *}
|
|
309 |
(* ML {* val consts = [@{const_name my_plus}] *}*)
|
260
59578f428bbe
Fixes after optimization and preparing for a general FORALL_PRS
Cezary Kaliszyk <kaliszyk@in.tum.de>
diff
changeset
|
310 |
ML {* val consts = lookup_quot_consts defs *}
|
276
|
311 |
ML {* val t_a = atomize_thm @{thm ho_tst} *}
|
281
|
312 |
|
286
|
313 |
(*
|
|
314 |
prove t_r: {* build_regularize_goal t_a rty rel @{context} *}
|
276
|
315 |
ML_prf {* fun tac ctxt =
|
|
316 |
(ObjectLogic.full_atomize_tac) THEN'
|
|
317 |
REPEAT_ALL_NEW (FIRST' [
|
|
318 |
rtac rel_refl,
|
|
319 |
atac,
|
|
320 |
rtac @{thm universal_twice},
|
|
321 |
(rtac @{thm impI} THEN' atac),
|
|
322 |
(*rtac @{thm equality_twice},*)
|
|
323 |
EqSubst.eqsubst_tac ctxt [0]
|
|
324 |
[(@{thm equiv_res_forall} OF [rel_eqv]),
|
|
325 |
(@{thm equiv_res_exists} OF [rel_eqv])],
|
|
326 |
(rtac @{thm impI} THEN' (asm_full_simp_tac (Simplifier.context ctxt HOL_ss)) THEN' rtac rel_refl),
|
|
327 |
(rtac @{thm RIGHT_RES_FORALL_REGULAR})
|
|
328 |
]);*}
|
|
329 |
apply (atomize(full))
|
|
330 |
apply (tactic {* tac @{context} 1 *})
|
|
331 |
apply (auto)
|
281
|
332 |
done
|
|
333 |
ML {* val t_r = @{thm t_r} OF [t_a] *}*)
|
|
334 |
ML {* val t_r = regularize t_a rty rel rel_eqv rel_refl @{context} *}
|
|
335 |
ML {*
|
|
336 |
val rt = build_repabs_term @{context} t_r consts rty qty
|
|
337 |
val rg = Logic.mk_equals ((Thm.prop_of t_r), rt);
|
|
338 |
*}
|
286
|
339 |
*)
|
281
|
340 |
|
|
341 |
lemma foldl_rsp:
|
|
342 |
"((IntEx.intrel ===> IntEx.intrel ===> IntEx.intrel) ===>
|
|
343 |
IntEx.intrel ===> op = ===> IntEx.intrel)
|
|
344 |
foldl foldl"
|
|
345 |
apply (simp only:FUN_REL.simps)
|
|
346 |
apply (rule allI)
|
|
347 |
apply (rule allI)
|
|
348 |
apply (rule impI)
|
|
349 |
apply (rule allI)
|
|
350 |
apply (rule allI)
|
|
351 |
apply (rule impI)
|
|
352 |
apply (rule allI)
|
|
353 |
apply (rule allI)
|
|
354 |
apply (rule impI)
|
|
355 |
apply (simp only:)
|
|
356 |
apply (rule list.induct)
|
|
357 |
apply (simp)
|
|
358 |
apply (simp only: foldl.simps)
|
|
359 |
sorry
|
|
360 |
|
|
361 |
ML {* val rsp_thms = @{thm foldl_rsp} :: rsp_thms *}
|
|
362 |
prove t_t: rg
|
|
363 |
apply(atomize(full))
|
|
364 |
ML_prf {* fun r_mk_comb_tac_int lthy = r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms *}
|
|
365 |
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_int @{context}) 1 *})
|
|
366 |
done
|
|
367 |
ML {* val t_t = @{thm Pure.equal_elim_rule1} OF [@{thm t_t},t_r] *}
|
|
368 |
ML {* val abs = findabs rty (prop_of t_a) *}
|
|
369 |
ML {* val aps = findaps rty (prop_of t_a); *}
|
|
370 |
ML {* val simp_lam_prs_thms = map (make_simp_prs_thm @{context} quot @{thm LAMBDA_PRS}) abs *}
|
|
371 |
|
305
|
372 |
(*ML {* val t_t = repabs @{context} @{thm t_r} consts rty qty quot rel_refl trans2 rsp_thms *}*)
|
276
|
373 |
ML {* val (alls, exs) = findallex rty qty (prop_of t_a) *}
|
|
374 |
ML {* val allthms = map (make_allex_prs_thm @{context} quot @{thm FORALL_PRS}) alls *}
|
|
375 |
ML {* val t_a = MetaSimplifier.rewrite_rule (allthms) t_t *}
|
|
376 |
ML {* val t_l = repeat_eqsubst_thm @{context} simp_lam_prs_thms t_a *}
|
281
|
377 |
ML {* val defs_sym = add_lower_defs @{context} defs *}
|
276
|
378 |
ML {* val t_d = repeat_eqsubst_thm @{context} defs_sym t_l *}
|
197
|
379 |
ML {* val t_r = MetaSimplifier.rewrite_rule [reps_same] t_d *}
|
191
|
380 |
ML {* ObjectLogic.rulify t_r *}
|