author | wenzelm |
Thu, 01 Sep 2005 00:46:14 +0200 (2005-08-31) | |
changeset 17215 | 8b969275a5d2 |
parent 9517 | f58863b1406a |
child 17309 | c43ed29bd197 |
permissions | -rw-r--r-- |
3807 | 1 |
(* |
2 |
File: Intensional.ML |
|
3 |
Author: Stephan Merz |
|
6255 | 4 |
Copyright: 1998 University of Munich |
3807 | 5 |
|
6 |
Lemmas and tactics for "intensional" logics. |
|
7 |
*) |
|
8 |
||
6255 | 9 |
val intensional_rews = [unl_con,unl_lift,unl_lift2,unl_lift3,unl_Rall,unl_Rex,unl_Rex1]; |
10 |
||
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
11 |
Goalw [Valid_def,unl_lift2] "|- x=y ==> (x==y)"; |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
12 |
by (rtac eq_reflection 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
13 |
by (rtac ext 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
14 |
by (etac spec 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
15 |
qed "inteq_reflection"; |
3807 | 16 |
|
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
17 |
val [prem] = goalw thy [Valid_def] "(!!w. w |= A) ==> |- A"; |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
18 |
by (REPEAT (resolve_tac [allI,prem] 1)); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
19 |
qed "intI"; |
6255 | 20 |
|
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
21 |
Goalw [Valid_def] "|- A ==> w |= A"; |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
22 |
by (etac spec 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
23 |
qed "intD"; |
6255 | 24 |
|
25 |
(** Lift usual HOL simplifications to "intensional" level. **) |
|
3807 | 26 |
local |
27 |
||
28 |
fun prover s = (prove_goal Intensional.thy s |
|
6255 | 29 |
(fn _ => [rewrite_goals_tac (Valid_def::intensional_rews), |
30 |
blast_tac HOL_cs 1])) RS inteq_reflection |
|
3807 | 31 |
|
32 |
in |
|
33 |
||
34 |
val int_simps = map prover |
|
6255 | 35 |
[ "|- (x=x) = #True", |
36 |
"|- (~#True) = #False", "|- (~#False) = #True", "|- (~~ P) = P", |
|
37 |
"|- ((~P) = P) = #False", "|- (P = (~P)) = #False", |
|
38 |
"|- (P ~= Q) = (P = (~Q))", |
|
39 |
"|- (#True=P) = P", "|- (P=#True) = P", |
|
40 |
"|- (#True --> P) = P", "|- (#False --> P) = #True", |
|
41 |
"|- (P --> #True) = #True", "|- (P --> P) = #True", |
|
42 |
"|- (P --> #False) = (~P)", "|- (P --> ~P) = (~P)", |
|
43 |
"|- (P & #True) = P", "|- (#True & P) = P", |
|
44 |
"|- (P & #False) = #False", "|- (#False & P) = #False", |
|
45 |
"|- (P & P) = P", "|- (P & ~P) = #False", "|- (~P & P) = #False", |
|
46 |
"|- (P | #True) = #True", "|- (#True | P) = #True", |
|
47 |
"|- (P | #False) = P", "|- (#False | P) = P", |
|
48 |
"|- (P | P) = P", "|- (P | ~P) = #True", "|- (~P | P) = #True", |
|
49 |
"|- (! x. P) = P", "|- (? x. P) = P", |
|
50 |
"|- (~Q --> ~P) = (P --> Q)", |
|
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
51 |
"|- (P|Q --> R) = ((P-->R)&(Q-->R))" ] |
3807 | 52 |
end; |
53 |
||
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
54 |
Goal "|- #True"; |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
55 |
by (simp_tac (simpset() addsimps [Valid_def,unl_con]) 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
56 |
qed "TrueW"; |
3807 | 57 |
|
6255 | 58 |
Addsimps (TrueW::intensional_rews); |
59 |
Addsimps int_simps; |
|
60 |
AddSIs [intI]; |
|
61 |
AddDs [intD]; |
|
3807 | 62 |
|
63 |
||
64 |
(* ======== Functions to "unlift" intensional implications into HOL rules ====== *) |
|
65 |
||
66 |
(* Basic unlifting introduces a parameter "w" and applies basic rewrites, e.g. |
|
6255 | 67 |
|- F = G becomes F w = G w |
68 |
|- F --> G becomes F w --> G w |
|
3807 | 69 |
*) |
70 |
||
6255 | 71 |
fun int_unlift th = |
72 |
rewrite_rule intensional_rews ((th RS intD) handle _ => th); |
|
3807 | 73 |
|
6255 | 74 |
(* Turn |- F = G into meta-level rewrite rule F == G *) |
75 |
fun int_rewrite th = |
|
76 |
zero_var_indexes (rewrite_rule intensional_rews (th RS inteq_reflection)); |
|
3807 | 77 |
|
6255 | 78 |
(* flattening turns "-->" into "==>" and eliminates conjunctions in the |
79 |
antecedent. For example, |
|
80 |
||
81 |
P & Q --> (R | S --> T) becomes [| P; Q; R | S |] ==> T |
|
3807 | 82 |
|
6255 | 83 |
Flattening can be useful with "intensional" lemmas (after unlifting). |
84 |
Naive resolution with mp and conjI may run away because of higher-order |
|
85 |
unification, therefore the code is a little awkward. |
|
86 |
*) |
|
87 |
fun flatten t = |
|
88 |
let |
|
89 |
(* analogous to RS, but using matching instead of resolution *) |
|
90 |
fun matchres tha i thb = |
|
91 |
case Seq.chop (2, biresolution true [(false,tha)] i thb) of |
|
92 |
([th],_) => th |
|
93 |
| ([],_) => raise THM("matchres: no match", i, [tha,thb]) |
|
94 |
| _ => raise THM("matchres: multiple unifiers", i, [tha,thb]) |
|
3807 | 95 |
|
6255 | 96 |
(* match tha with some premise of thb *) |
97 |
fun matchsome tha thb = |
|
98 |
let fun hmatch 0 = raise THM("matchsome: no match", 0, [tha,thb]) |
|
99 |
| hmatch n = (matchres tha n thb) handle _ => hmatch (n-1) |
|
100 |
in hmatch (nprems_of thb) end |
|
3807 | 101 |
|
6255 | 102 |
fun hflatten t = |
103 |
case (concl_of t) of |
|
104 |
Const _ $ (Const ("op -->", _) $ _ $ _) => hflatten (t RS mp) |
|
105 |
| _ => (hflatten (matchsome conjI t)) handle _ => zero_var_indexes t |
|
106 |
in |
|
107 |
hflatten t |
|
108 |
end; |
|
3807 | 109 |
|
6255 | 110 |
fun int_use th = |
111 |
case (concl_of th) of |
|
112 |
Const _ $ (Const ("Intensional.Valid", _) $ _) => |
|
113 |
((flatten (int_unlift th)) handle _ => th) |
|
114 |
| _ => th; |
|
3807 | 115 |
|
116 |
(* ========================================================================= *) |
|
117 |
||
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
118 |
Goalw [Valid_def] "|- (~(! x. F x)) = (? x. ~F x)"; |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
119 |
by (Simp_tac 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
120 |
qed "Not_Rall"; |
3807 | 121 |
|
9517
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
122 |
Goalw [Valid_def] "|- (~ (? x. F x)) = (! x. ~ F x)"; |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
123 |
by (Simp_tac 1); |
f58863b1406a
tuned version by Stephan Merz (unbatchified etc.);
wenzelm
parents:
6255
diff
changeset
|
124 |
qed "Not_Rex"; |
3807 | 125 |