3807
|
1 |
(*
|
|
2 |
File: Intensional.ML
|
|
3 |
Author: Stephan Merz
|
|
4 |
Copyright: 1997 University of Munich
|
|
5 |
|
|
6 |
Lemmas and tactics for "intensional" logics.
|
|
7 |
*)
|
|
8 |
|
|
9 |
val intensional_rews = [unl_con,unl_lift,unl_lift2,unl_lift3,unl_Rall,unl_Rex];
|
|
10 |
|
|
11 |
(** Lift usual HOL simplifications to "intensional" level.
|
|
12 |
Convert s .= t into rewrites s == t, so we can use the standard
|
|
13 |
simplifier.
|
|
14 |
**)
|
|
15 |
local
|
|
16 |
|
|
17 |
fun prover s = (prove_goal Intensional.thy s
|
|
18 |
(fn _ => [rewrite_goals_tac (int_valid::intensional_rews),
|
|
19 |
blast_tac HOL_cs 1])) RS inteq_reflection;
|
|
20 |
|
|
21 |
in
|
|
22 |
|
|
23 |
val int_simps = map prover
|
|
24 |
[ "(x.=x) .= #True",
|
|
25 |
"(.~#True) .= #False", "(.~#False) .= #True", "(.~ .~ P) .= P",
|
|
26 |
"((.~P) .= P) .= #False", "(P .= (.~P)) .= #False",
|
|
27 |
"(P .~= Q) .= (P .= (.~Q))",
|
|
28 |
"(#True.=P) .= P", "(P.=#True) .= P",
|
|
29 |
"(#True .-> P) .= P", "(#False .-> P) .= #True",
|
|
30 |
"(P .-> #True) .= #True", "(P .-> P) .= #True",
|
|
31 |
"(P .-> #False) .= (.~P)", "(P .-> .~P) .= (.~P)",
|
|
32 |
"(P .& #True) .= P", "(#True .& P) .= P",
|
|
33 |
"(P .& #False) .= #False", "(#False .& P) .= #False",
|
|
34 |
"(P .& P) .= P", "(P .& .~P) .= #False", "(.~P .& P) .= #False",
|
|
35 |
"(P .| #True) .= #True", "(#True .| P) .= #True",
|
|
36 |
"(P .| #False) .= P", "(#False .| P) .= P",
|
|
37 |
"(P .| P) .= P", "(P .| .~P) .= #True", "(.~P .| P) .= #True",
|
|
38 |
"(RALL x.P) .= P", "(REX x.P) .= P",
|
|
39 |
"(.~Q .-> .~P) .= (P .-> Q)",
|
|
40 |
"(P.|Q .-> R) .= ((P.->R).&(Q.->R))" ];
|
|
41 |
|
|
42 |
end;
|
|
43 |
|
|
44 |
Addsimps (intensional_rews @ int_simps);
|
|
45 |
|
|
46 |
(* Derive introduction and destruction rules from definition of
|
|
47 |
intensional validity.
|
|
48 |
*)
|
|
49 |
qed_goal "intI" Intensional.thy "(!!w. w |= A) ==> A"
|
|
50 |
(fn prems => [rewtac int_valid,
|
|
51 |
resolve_tac prems 1
|
|
52 |
]);
|
|
53 |
|
|
54 |
qed_goalw "intD" Intensional.thy [int_valid] "A ==> w |= A"
|
|
55 |
(fn [prem] => [ rtac (forall_elim_var 0 prem) 1 ]);
|
|
56 |
|
|
57 |
(* ======== Functions to "unlift" intensional implications into HOL rules ====== *)
|
|
58 |
|
|
59 |
(* Basic unlifting introduces a parameter "w" and applies basic rewrites, e.g.
|
|
60 |
F .= G gets (w |= F) = (w |= G)
|
|
61 |
F .-> G gets (w |= F) --> (w |= G)
|
|
62 |
*)
|
|
63 |
fun int_unlift th = rewrite_rule intensional_rews (th RS intD);
|
|
64 |
|
|
65 |
(* F .-> G becomes w |= F ==> w |= G *)
|
|
66 |
fun int_mp th = zero_var_indexes ((int_unlift th) RS mp);
|
|
67 |
|
|
68 |
(* F .-> G becomes [| w |= F; w |= G ==> R |] ==> R
|
|
69 |
so that it can be used as an elimination rule
|
|
70 |
*)
|
|
71 |
fun int_impE th = zero_var_indexes ((int_unlift th) RS impE);
|
|
72 |
|
|
73 |
(* F .& G .-> H becomes [| w |= F; w |= G |] ==> w |= H *)
|
|
74 |
fun int_conjmp th = zero_var_indexes (conjI RS (int_mp th));
|
|
75 |
|
|
76 |
(* F .& G .-> H becomes [| w |= F; w |= G; (w |= H ==> R) |] ==> R *)
|
|
77 |
fun int_conjimpE th = zero_var_indexes (conjI RS (int_impE th));
|
|
78 |
|
|
79 |
(* Turn F .= G into meta-level rewrite rule F == G *)
|
|
80 |
fun int_rewrite th = (rewrite_rule intensional_rews (th RS inteq_reflection));
|
|
81 |
|
|
82 |
(* Make the simplifier accept "intensional" goals by first unlifting them.
|
|
83 |
This is the standard way of proving "intensional" theorems; apply
|
|
84 |
int_rewrite (or action_rewrite, temp_rewrite) to convert "x .= y" into "x == y"
|
|
85 |
if you want to rewrite without unlifting.
|
|
86 |
*)
|
|
87 |
fun maybe_unlift th =
|
|
88 |
(case concl_of th of
|
|
89 |
Const("TrueInt",_) $ p => int_unlift th
|
|
90 |
| _ => th);
|
|
91 |
|
|
92 |
simpset := !simpset setmksimps ((mksimps mksimps_pairs) o maybe_unlift);
|
|
93 |
|
|
94 |
|
|
95 |
(* ==================== Rewrites for abstractions ==================== *)
|
|
96 |
|
|
97 |
(* The following are occasionally useful. Don't add them to the default
|
|
98 |
simpset, or it will loop! Alternatively, we could replace the "unl_XXX"
|
|
99 |
rules by definitions of lifting via lambda abstraction, but then proof
|
|
100 |
states would have lots of lambdas, and would be hard to read.
|
|
101 |
*)
|
|
102 |
|
|
103 |
qed_goal "con_abs" Intensional.thy "(%w. c) == #c"
|
|
104 |
(fn _ => [rtac inteq_reflection 1,
|
|
105 |
rtac intI 1,
|
|
106 |
rewrite_goals_tac intensional_rews,
|
|
107 |
rtac refl 1
|
|
108 |
]);
|
|
109 |
|
|
110 |
qed_goal "lift_abs" Intensional.thy "(%w. f(x w)) == (f[x])"
|
|
111 |
(fn _ => [rtac inteq_reflection 1,
|
|
112 |
rtac intI 1,
|
|
113 |
rewrite_goals_tac intensional_rews,
|
|
114 |
rtac refl 1
|
|
115 |
]);
|
|
116 |
|
|
117 |
qed_goal "lift2_abs" Intensional.thy "(%w. f(x w) (y w)) == (f[x,y])"
|
|
118 |
(fn _ => [rtac inteq_reflection 1,
|
|
119 |
rtac intI 1,
|
|
120 |
rewrite_goals_tac intensional_rews,
|
|
121 |
rtac refl 1
|
|
122 |
]);
|
|
123 |
|
|
124 |
qed_goal "lift2_abs_con1" Intensional.thy "(%w. f x (y w)) == (f[#x,y])"
|
|
125 |
(fn _ => [rtac inteq_reflection 1,
|
|
126 |
rtac intI 1,
|
|
127 |
rewrite_goals_tac intensional_rews,
|
|
128 |
rtac refl 1
|
|
129 |
]);
|
|
130 |
|
|
131 |
qed_goal "lift2_abs_con2" Intensional.thy "(%w. f(x w) y) == (f[x,#y])"
|
|
132 |
(fn _ => [rtac inteq_reflection 1,
|
|
133 |
rtac intI 1,
|
|
134 |
rewrite_goals_tac intensional_rews,
|
|
135 |
rtac refl 1
|
|
136 |
]);
|
|
137 |
|
|
138 |
qed_goal "lift3_abs" Intensional.thy "(%w. f(x w) (y w) (z w)) == (f[x,y,z])"
|
|
139 |
(fn _ => [rtac inteq_reflection 1,
|
|
140 |
rtac intI 1,
|
|
141 |
rewrite_goals_tac intensional_rews,
|
|
142 |
rtac refl 1
|
|
143 |
]);
|
|
144 |
|
|
145 |
qed_goal "lift3_abs_con1" Intensional.thy "(%w. f x (y w) (z w)) == (f[#x,y,z])"
|
|
146 |
(fn _ => [rtac inteq_reflection 1,
|
|
147 |
rtac intI 1,
|
|
148 |
rewrite_goals_tac intensional_rews,
|
|
149 |
rtac refl 1
|
|
150 |
]);
|
|
151 |
|
|
152 |
qed_goal "lift3_abs_con2" Intensional.thy "(%w. f (x w) y (z w)) == (f[x,#y,z])"
|
|
153 |
(fn _ => [rtac inteq_reflection 1,
|
|
154 |
rtac intI 1,
|
|
155 |
rewrite_goals_tac intensional_rews,
|
|
156 |
rtac refl 1
|
|
157 |
]);
|
|
158 |
|
|
159 |
qed_goal "lift3_abs_con3" Intensional.thy "(%w. f (x w) (y w) z) == (f[x,y,#z])"
|
|
160 |
(fn _ => [rtac inteq_reflection 1,
|
|
161 |
rtac intI 1,
|
|
162 |
rewrite_goals_tac intensional_rews,
|
|
163 |
rtac refl 1
|
|
164 |
]);
|
|
165 |
|
|
166 |
qed_goal "lift3_abs_con12" Intensional.thy "(%w. f x y (z w)) == (f[#x,#y,z])"
|
|
167 |
(fn _ => [rtac inteq_reflection 1,
|
|
168 |
rtac intI 1,
|
|
169 |
rewrite_goals_tac intensional_rews,
|
|
170 |
rtac refl 1
|
|
171 |
]);
|
|
172 |
|
|
173 |
qed_goal "lift3_abs_con13" Intensional.thy "(%w. f x (y w) z) == (f[#x,y,#z])"
|
|
174 |
(fn _ => [rtac inteq_reflection 1,
|
|
175 |
rtac intI 1,
|
|
176 |
rewrite_goals_tac intensional_rews,
|
|
177 |
rtac refl 1
|
|
178 |
]);
|
|
179 |
|
|
180 |
qed_goal "lift3_abs_con23" Intensional.thy "(%w. f (x w) y z) == (f[x,#y,#z])"
|
|
181 |
(fn _ => [rtac inteq_reflection 1,
|
|
182 |
rtac intI 1,
|
|
183 |
rewrite_goals_tac intensional_rews,
|
|
184 |
rtac refl 1
|
|
185 |
]);
|
|
186 |
|
|
187 |
(* ========================================================================= *)
|
|
188 |
|
|
189 |
qed_goal "Not_rall" Intensional.thy
|
|
190 |
"(.~ (RALL x. F(x))) .= (REX x. .~ F(x))"
|
|
191 |
(fn _ => [rtac intI 1,
|
|
192 |
rewrite_goals_tac intensional_rews,
|
|
193 |
fast_tac HOL_cs 1
|
|
194 |
]);
|
|
195 |
|
|
196 |
qed_goal "Not_rex" Intensional.thy
|
|
197 |
"(.~ (REX x. F(x))) .= (RALL x. .~ F(x))"
|
|
198 |
(fn _ => [rtac intI 1,
|
|
199 |
rewrite_goals_tac intensional_rews,
|
|
200 |
fast_tac HOL_cs 1
|
|
201 |
]);
|
|
202 |
|
|
203 |
(* IntLemmas.ML contains a collection of further lemmas about "intensional" logic.
|
|
204 |
These are not loaded by default because they are not required for the
|
|
205 |
standard proof procedures that first unlift proof goals to the HOL level.
|
|
206 |
|
|
207 |
use "IntLemmas.ML";
|
|
208 |
|
|
209 |
*)
|