author | Cezary Kaliszyk <kaliszyk@in.tum.de> |
Mon, 23 Nov 2009 15:08:09 +0100 | |
changeset 342 | eb15be678ac4 |
parent 340 | 2f17bbd47c47 |
child 344 | 0aba42afedad |
permissions | -rw-r--r-- |
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
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
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>
parents:
320
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>
parents:
320
diff
changeset
|
16 |
|
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
228
diff
changeset
|
17 |
print_theorems |
274
df225aa45770
simplified the quotient_def code
Christian Urban <urbanc@in.tum.de>
parents:
268
diff
changeset
|
18 |
print_quotients |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
228
diff
changeset
|
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>
parents:
263
diff
changeset
|
20 |
quotient_def |
218
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
21 |
ZERO::"my_int" |
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
22 |
where |
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
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
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
25 |
ML {* print_qconstinfo @{context} *} |
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
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>
parents:
263
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>
parents:
263
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>
parents:
286
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>
parents:
286
diff
changeset
|
31 |
|
318
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
32 |
ML {* separate *} |
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
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>
parents:
263
diff
changeset
|
34 |
quotient_def |
218
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
35 |
ONE::"my_int" |
193 | 36 |
where |
218
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
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
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
39 |
ML {* print_qconstinfo @{context} *} |
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
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>
parents:
263
diff
changeset
|
49 |
quotient_def |
218
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
50 |
PLUS::"my_int \<Rightarrow> my_int \<Rightarrow> my_int" |
df05cd030d2f
added infrastructure for defining lifted constants
Christian Urban <urbanc@in.tum.de>
parents:
210
diff
changeset
|
51 |
where |
275
34ad627ac5d5
fixed definition of PLUS
Christian Urban <urbanc@in.tum.de>
parents:
274
diff
changeset
|
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
746b17e1d6d8
fixed the storage of qconst definitions
Christian Urban <urbanc@in.tum.de>
parents:
312
diff
changeset
|
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>
parents:
263
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>
parents:
263
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>
parents:
263
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>
parents:
320
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>
parents:
306
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>
parents:
306
diff
changeset
|
123 |
|
199 | 124 |
lemma plus_sym_pre: |
281
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
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
1e227c9ee915
Fixed APPLY_RSP vs Cong in the InjRepAbs tactic.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
200
diff
changeset
|
131 |
lemma ho_plus_rsp: |
228
268a727b0f10
disambiguate ===> syntax
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
224
diff
changeset
|
132 |
"(intrel ===> intrel ===> intrel) my_plus my_plus" |
192
a296bf1a3b09
Simplifying code in int
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
191
diff
changeset
|
133 |
by (simp) |
a296bf1a3b09
Simplifying code in int
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
191
diff
changeset
|
134 |
|
a296bf1a3b09
Simplifying code in int
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
191
diff
changeset
|
135 |
ML {* val qty = @{typ "my_int"} *} |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
228
diff
changeset
|
136 |
ML {* val ty_name = "my_int" *} |
192
a296bf1a3b09
Simplifying code in int
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
191
diff
changeset
|
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>
parents:
239
diff
changeset
|
138 |
ML {* val defs = @{thms PLUS_def} *} |
197
c0f2db9a243b
Further reordering in Int code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
196
diff
changeset
|
139 |
|
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
140 |
ML {* |
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
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>
parents:
239
diff
changeset
|
142 |
lift_thm lthy qty ty_name rsp_thms defs t |
239
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
228
diff
changeset
|
143 |
*} |
02b14a21761a
Cleaning of the interface to lift.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
228
diff
changeset
|
144 |
|
342 | 145 |
ML {* |
146 |
fun regularize_goal thm rel_eqv rel_refl lthy qtrm = |
|
147 |
let |
|
148 |
val reg_trm = mk_REGULARIZE_goal @{context} (prop_of thm) qtrm; |
|
149 |
fun tac ctxt = |
|
150 |
(ObjectLogic.full_atomize_tac) THEN' |
|
151 |
REPEAT_ALL_NEW (FIRST' [ |
|
152 |
rtac rel_refl, |
|
153 |
atac, |
|
154 |
rtac @{thm universal_twice}, |
|
155 |
(rtac @{thm impI} THEN' atac), |
|
156 |
rtac @{thm implication_twice}, |
|
157 |
EqSubst.eqsubst_tac ctxt [0] |
|
158 |
[(@{thm equiv_res_forall} OF [rel_eqv]), |
|
159 |
(@{thm equiv_res_exists} OF [rel_eqv])], |
|
160 |
(* For a = b \<longrightarrow> a \<approx> b *) |
|
161 |
(rtac @{thm impI} THEN' (asm_full_simp_tac HOL_ss) THEN' rtac rel_refl), |
|
162 |
(rtac @{thm RIGHT_RES_FORALL_REGULAR}) |
|
163 |
]); |
|
164 |
val cthm = Goal.prove lthy [] [] reg_trm |
|
165 |
(fn {context, ...} => tac context 1); |
|
166 |
in |
|
167 |
cthm OF [thm] |
|
168 |
end |
|
169 |
*} |
|
170 |
||
171 |
ML {* |
|
172 |
fun repabs_goal lthy thm rty quot_thm reflex_thm trans_thm rsp_thms qtrm = |
|
173 |
let |
|
174 |
val rg = Syntax.check_term lthy (mk_inj_REPABS_goal lthy ((prop_of thm), qtrm)); |
|
175 |
fun tac ctxt = (ObjectLogic.full_atomize_tac) THEN' |
|
176 |
(REPEAT_ALL_NEW (r_mk_comb_tac ctxt rty quot_thm reflex_thm trans_thm rsp_thms)); |
|
177 |
val cthm = Goal.prove lthy [] [] rg (fn x => tac (#context x) 1); |
|
178 |
in |
|
179 |
@{thm Pure.equal_elim_rule1} OF [cthm, thm] |
|
180 |
end |
|
181 |
*} |
|
182 |
||
183 |
||
184 |
ML {* |
|
185 |
fun lift_thm_goal lthy qty qty_name rsp_thms defs rthm goal = |
|
186 |
let |
|
187 |
val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data lthy qty; |
|
188 |
val (trans2, reps_same, absrep, quot) = lookup_quot_thms lthy qty_name; |
|
189 |
val consts = lookup_quot_consts defs; |
|
190 |
val t_a = atomize_thm rthm; |
|
191 |
val goal_a = atomize_goal (ProofContext.theory_of lthy) goal; |
|
192 |
val t_r = regularize_goal t_a rel_eqv rel_refl lthy goal_a; |
|
193 |
val t_t = repabs_goal lthy t_r rty quot rel_refl trans2 rsp_thms goal_a; |
|
194 |
val (alls, exs) = findallex lthy rty qty (prop_of t_a); |
|
195 |
val allthms = map (make_allex_prs_thm lthy quot @{thm FORALL_PRS}) alls |
|
196 |
val exthms = map (make_allex_prs_thm lthy quot @{thm EXISTS_PRS}) exs |
|
197 |
val t_a = MetaSimplifier.rewrite_rule (allthms @ exthms) t_t |
|
198 |
val abs = findabs rty (prop_of t_a); |
|
199 |
val aps = findaps rty (prop_of t_a); |
|
200 |
val app_prs_thms = map (applic_prs lthy rty qty absrep) aps; |
|
201 |
val lam_prs_thms = map (make_simp_prs_thm lthy quot @{thm LAMBDA_PRS}) abs; |
|
202 |
val t_l = repeat_eqsubst_thm lthy (lam_prs_thms @ app_prs_thms) t_a; |
|
203 |
val defs_sym = flat (map (add_lower_defs lthy) defs); |
|
204 |
val defs_sym_eq = map (fn x => eq_reflection OF [x]) defs_sym; |
|
205 |
val t_id = simp_ids lthy t_l; |
|
206 |
val t_d0 = MetaSimplifier.rewrite_rule defs_sym_eq t_id; |
|
207 |
val t_d = repeat_eqsubst_thm lthy defs_sym t_d0; |
|
208 |
val t_r = MetaSimplifier.rewrite_rule [reps_same] t_d; |
|
209 |
val t_rv = ObjectLogic.rulify t_r |
|
210 |
in |
|
211 |
Thm.varifyT t_rv |
|
212 |
end |
|
213 |
*} |
|
214 |
||
215 |
ML {* |
|
216 |
fun lift_thm_g_my_int lthy t g = |
|
217 |
lift_thm_goal lthy qty ty_name rsp_thms defs t g |
|
218 |
*} |
|
219 |
||
312
4cf79f70efec
looking up data in quot_info works now (needs qualified string)
Christian Urban <urbanc@in.tum.de>
parents:
310
diff
changeset
|
220 |
print_quotients |
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
221 |
ML {* quotdata_lookup @{context} "IntEx.my_int" *} |
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
222 |
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>
parents:
310
diff
changeset
|
223 |
|
319 | 224 |
ML {* |
225 |
val test = lift_thm_my_int @{context} @{thm plus_sym_pre} |
|
226 |
*} |
|
227 |
||
228 |
ML {* |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
229 |
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>
parents:
320
diff
changeset
|
230 |
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>
parents:
320
diff
changeset
|
231 |
val reg_artm = mk_REGULARIZE_goal @{context} artrm aqtrm |
319 | 232 |
*} |
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
233 |
|
342 | 234 |
ML {* |
235 |
lift_thm_g_my_int @{context} @{thm plus_sym_pre} @{term "Trueprop (\<forall>a b. PLUS a b = PLUS b a)"} |
|
236 |
*} |
|
237 |
||
238 |
||
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
239 |
prove {* reg_artm *} |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
240 |
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>
parents:
320
diff
changeset
|
241 |
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>
parents:
320
diff
changeset
|
242 |
done |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
243 |
|
320
7d3d86beacd6
started regularize of rtrm/qtrm version; looks quite promising
Christian Urban <urbanc@in.tum.de>
parents:
319
diff
changeset
|
244 |
|
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
245 |
lemma plus_assoc_pre: |
281
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
246 |
shows "my_plus (my_plus i j) k \<approx> my_plus i (my_plus j k)" |
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
247 |
apply (cases i) |
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
248 |
apply (cases j) |
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
249 |
apply (cases k) |
224
f9a25fe22037
Cleaning the unnecessary theorems in 'IntEx'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
222
diff
changeset
|
250 |
apply (simp) |
198
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
251 |
done |
ff4425e000db
Completely cleaned Int.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
197
diff
changeset
|
252 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
253 |
ML {* val test2 = lift_thm_my_int @{context} @{thm plus_assoc_pre} *} |
224
f9a25fe22037
Cleaning the unnecessary theorems in 'IntEx'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
222
diff
changeset
|
254 |
|
321
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
255 |
ML {* |
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
256 |
val arthm = atomize_thm @{thm plus_assoc_pre} |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
257 |
val aqthm = atomize_thm test2 |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
258 |
val aqtrm = prop_of aqthm |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
259 |
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>
parents:
320
diff
changeset
|
260 |
*} |
f46dc0ca08c3
simplified get_fun so that it uses directly rty and qty, instead of qenv
Christian Urban <urbanc@in.tum.de>
parents:
320
diff
changeset
|
261 |
|
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
262 |
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>
parents:
320
diff
changeset
|
263 |
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>
parents:
320
diff
changeset
|
264 |
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>
parents:
320
diff
changeset
|
265 |
done |
224
f9a25fe22037
Cleaning the unnecessary theorems in 'IntEx'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
222
diff
changeset
|
266 |
|
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
267 |
ML {* @{thm testtest} OF [arthm] *} |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
268 |
|
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
269 |
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>
parents:
326
diff
changeset
|
270 |
|
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
335
diff
changeset
|
271 |
(* |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
335
diff
changeset
|
272 |
does not work. |
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
273 |
ML {* |
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
274 |
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>
parents:
326
diff
changeset
|
275 |
(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>
parents:
327
diff
changeset
|
276 |
[(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>
parents:
327
diff
changeset
|
277 |
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>
parents:
327
diff
changeset
|
278 |
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>
parents:
327
diff
changeset
|
279 |
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>
parents:
327
diff
changeset
|
280 |
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>
parents:
327
diff
changeset
|
281 |
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>
parents:
327
diff
changeset
|
282 |
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>
parents:
327
diff
changeset
|
283 |
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>
parents:
327
diff
changeset
|
284 |
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>
parents:
327
diff
changeset
|
285 |
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>
parents:
327
diff
changeset
|
286 |
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>
parents:
327
diff
changeset
|
287 |
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>
parents:
327
diff
changeset
|
288 |
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>
parents:
327
diff
changeset
|
289 |
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>
parents:
327
diff
changeset
|
290 |
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>
parents:
327
diff
changeset
|
291 |
DT ctxt "F" (CHANGED' (asm_full_simp_tac (HOL_ss addsimps @{thms FUN_REL_EQ})))] |
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
292 |
*} |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
335
diff
changeset
|
293 |
*) |
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
294 |
|
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
295 |
ML {* |
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
296 |
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>
parents:
326
diff
changeset
|
297 |
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>
parents:
326
diff
changeset
|
298 |
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>
parents:
326
diff
changeset
|
299 |
*} |
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
300 |
|
328
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
parents:
327
diff
changeset
|
301 |
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>
parents:
327
diff
changeset
|
302 |
|
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
parents:
327
diff
changeset
|
303 |
ML {* |
330
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
329
diff
changeset
|
304 |
mk_inj_REPABS_goal @{context} (reg_atrm, aqtrm) |
1a0f0b758071
a little tuning of comments
Christian Urban <urbanc@in.tum.de>
parents:
329
diff
changeset
|
305 |
|> 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>
parents:
327
diff
changeset
|
306 |
*} |
491dde407f40
some debugging code, but cannot find the place where the cprems_of exception is raised
Christian Urban <urbanc@in.tum.de>
parents:
327
diff
changeset
|
307 |
|
334 | 308 |
|
309 |
ML {* val my_goal = cterm_of @{theory} (mk_inj_REPABS_goal @{context} (reg_atrm, aqtrm)) *} |
|
310 |
ML {* val yr_goal = cterm_of @{theory} (build_repabs_goal @{context} (@{thm testtest} OF [arthm]) consts rty qty) *} |
|
311 |
||
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
312 |
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>
parents:
326
diff
changeset
|
313 |
apply(tactic {* ObjectLogic.full_atomize_tac 1 *}) |
336
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
335
diff
changeset
|
314 |
apply(tactic {* REPEAT_ALL_NEW (r_mk_comb_tac @{context} rty quot rel_refl trans2 rsp_thms) 1 *}) |
e6b6e5ba0cc5
Moved new repabs_inj code to QuotMain
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
335
diff
changeset
|
315 |
done |
327
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
316 |
|
22c8bf90cadb
tried to prove the repabs_inj lemma, but failed for the moment
Christian Urban <urbanc@in.tum.de>
parents:
326
diff
changeset
|
317 |
ML {* |
326
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
318 |
inj_REPABS @{context} (reg_atrm, aqtrm) |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
319 |
|> Syntax.string_of_term @{context} |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
320 |
|> writeln |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
321 |
*} |
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
322 |
|
e755a5da14c8
my first version of repabs injection
Christian Urban <urbanc@in.tum.de>
parents:
324
diff
changeset
|
323 |
|
281
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
324 |
lemma ho_tst: "foldl my_plus x [] = x" |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
325 |
apply simp |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
326 |
done |
276 | 327 |
|
224
f9a25fe22037
Cleaning the unnecessary theorems in 'IntEx'.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
222
diff
changeset
|
328 |
text {* Below is the construction site code used if things do not work *} |
276 | 329 |
ML {* val (rty, rel, rel_refl, rel_eqv) = lookup_quot_data @{context} qty *} |
330 |
ML {* val (trans2, reps_same, absrep, quot) = lookup_quot_thms @{context} "my_int" *} |
|
331 |
(* 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>
parents:
239
diff
changeset
|
332 |
ML {* val consts = lookup_quot_consts defs *} |
276 | 333 |
ML {* val t_a = atomize_thm @{thm ho_tst} *} |
281
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
334 |
|
286 | 335 |
(* |
336 |
prove t_r: {* build_regularize_goal t_a rty rel @{context} *} |
|
276 | 337 |
ML_prf {* fun tac ctxt = |
338 |
(ObjectLogic.full_atomize_tac) THEN' |
|
339 |
REPEAT_ALL_NEW (FIRST' [ |
|
340 |
rtac rel_refl, |
|
341 |
atac, |
|
342 |
rtac @{thm universal_twice}, |
|
343 |
(rtac @{thm impI} THEN' atac), |
|
344 |
(*rtac @{thm equality_twice},*) |
|
345 |
EqSubst.eqsubst_tac ctxt [0] |
|
346 |
[(@{thm equiv_res_forall} OF [rel_eqv]), |
|
347 |
(@{thm equiv_res_exists} OF [rel_eqv])], |
|
348 |
(rtac @{thm impI} THEN' (asm_full_simp_tac (Simplifier.context ctxt HOL_ss)) THEN' rtac rel_refl), |
|
349 |
(rtac @{thm RIGHT_RES_FORALL_REGULAR}) |
|
350 |
]);*} |
|
351 |
apply (atomize(full)) |
|
352 |
apply (tactic {* tac @{context} 1 *}) |
|
353 |
apply (auto) |
|
281
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
354 |
done |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
355 |
ML {* val t_r = @{thm t_r} OF [t_a] *}*) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
356 |
ML {* val t_r = regularize t_a rty rel rel_eqv rel_refl @{context} *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
357 |
ML {* |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
358 |
val rt = build_repabs_term @{context} t_r consts rty qty |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
359 |
val rg = Logic.mk_equals ((Thm.prop_of t_r), rt); |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
360 |
*} |
340 | 361 |
|
281
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
362 |
|
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
363 |
lemma foldl_rsp: |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
364 |
"((IntEx.intrel ===> IntEx.intrel ===> IntEx.intrel) ===> |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
365 |
IntEx.intrel ===> op = ===> IntEx.intrel) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
366 |
foldl foldl" |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
367 |
apply (simp only:FUN_REL.simps) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
368 |
apply (rule allI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
369 |
apply (rule allI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
370 |
apply (rule impI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
371 |
apply (rule allI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
372 |
apply (rule allI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
373 |
apply (rule impI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
374 |
apply (rule allI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
375 |
apply (rule allI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
376 |
apply (rule impI) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
377 |
apply (simp only:) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
378 |
apply (rule list.induct) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
379 |
apply (simp) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
380 |
apply (simp only: foldl.simps) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
381 |
sorry |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
382 |
|
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
383 |
ML {* val rsp_thms = @{thm foldl_rsp} :: rsp_thms *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
384 |
prove t_t: rg |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
385 |
apply(atomize(full)) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
386 |
ML_prf {* fun r_mk_comb_tac_int lthy = r_mk_comb_tac lthy rty quot rel_refl trans2 rsp_thms *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
387 |
apply (tactic {* REPEAT_ALL_NEW (r_mk_comb_tac_int @{context}) 1 *}) |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
388 |
done |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
389 |
ML {* val t_t = @{thm Pure.equal_elim_rule1} OF [@{thm t_t},t_r] *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
390 |
ML {* val abs = findabs rty (prop_of t_a) *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
391 |
ML {* val aps = findaps rty (prop_of t_a); *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
392 |
ML {* val simp_lam_prs_thms = map (make_simp_prs_thm @{context} quot @{thm LAMBDA_PRS}) abs *} |
46e6d06efe3f
Experiments with lifting partially applied constants.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
276
diff
changeset
|
393 |
|
305
d7b60303adb8
Removed 'Toplevel.program' for polyml 5.3
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
290
diff
changeset
|
394 |
(*ML {* val t_t = repabs @{context} @{thm t_r} consts rty qty quot rel_refl trans2 rsp_thms *}*) |
340 | 395 |
ML findallex |
396 |
ML {* val (alls, exs) = findallex @{context} rty qty (prop_of t_a) *} |
|
276 | 397 |
ML {* val allthms = map (make_allex_prs_thm @{context} quot @{thm FORALL_PRS}) alls *} |
398 |
ML {* val t_a = MetaSimplifier.rewrite_rule (allthms) t_t *} |
|
399 |
ML {* val t_l = repeat_eqsubst_thm @{context} simp_lam_prs_thms t_a *} |
|
340 | 400 |
ML {* val defs_sym = flat (map (add_lower_defs @{context}) defs) *} |
276 | 401 |
ML {* val t_d = repeat_eqsubst_thm @{context} defs_sym t_l *} |
197
c0f2db9a243b
Further reordering in Int code.
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
196
diff
changeset
|
402 |
ML {* val t_r = MetaSimplifier.rewrite_rule [reps_same] t_d *} |
191
b97f3f5fbc18
Symmetry of integer addition
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
184
diff
changeset
|
403 |
ML {* ObjectLogic.rulify t_r *} |