author | paulson |
Wed, 28 Jun 2000 10:54:21 +0200 | |
changeset 9169 | 85a47aa21f74 |
parent 7654 | 57c4cea8b137 |
child 9245 | 428385c4bc50 |
permissions | -rw-r--r-- |
2640 | 1 |
(* Title: HOLCF/Tr.ML |
2 |
ID: $Id$ |
|
3 |
Author: Franz Regensburger |
|
4 |
Copyright 1993 Technische Universitaet Muenchen |
|
5 |
||
6 |
Lemmas for Tr.thy |
|
7 |
*) |
|
8 |
||
9 |
open Tr; |
|
10 |
||
11 |
(* ------------------------------------------------------------------------ *) |
|
12 |
(* Exhaustion and Elimination for type one *) |
|
13 |
(* ------------------------------------------------------------------------ *) |
|
14 |
qed_goalw "Exh_tr" thy [FF_def,TT_def] "t=UU | t = TT | t = FF" |
|
15 |
(fn prems => |
|
16 |
[ |
|
17 |
(lift.induct_tac "t" 1), |
|
18 |
(fast_tac HOL_cs 1), |
|
4098 | 19 |
(fast_tac (HOL_cs addss simpset()) 1) |
2640 | 20 |
]); |
21 |
||
9169 | 22 |
val prems = Goal "[| p=UU ==> Q; p = TT ==>Q; p = FF ==>Q|] ==>Q"; |
23 |
by (rtac (Exh_tr RS disjE) 1); |
|
24 |
by (eresolve_tac prems 1); |
|
25 |
by (etac disjE 1); |
|
26 |
by (eresolve_tac prems 1); |
|
27 |
by (eresolve_tac prems 1); |
|
28 |
qed "trE"; |
|
2640 | 29 |
|
30 |
(* ------------------------------------------------------------------------ *) |
|
31 |
(* tactic for tr-thms with case split *) |
|
32 |
(* ------------------------------------------------------------------------ *) |
|
33 |
||
7654 | 34 |
bind_thms ("tr_defs", [andalso_def,orelse_def,neg_def,ifte_def,TT_def,FF_def]); |
2640 | 35 |
|
36 |
fun prover t = prove_goal thy t |
|
37 |
(fn prems => |
|
38 |
[ |
|
39 |
(res_inst_tac [("p","y")] trE 1), |
|
4098 | 40 |
(REPEAT(asm_simp_tac (simpset() addsimps |
2640 | 41 |
[o_def,flift1_def,flift2_def,inst_lift_po]@tr_defs) 1)) |
42 |
]); |
|
43 |
||
44 |
(* ------------------------------------------------------------------------ *) |
|
45 |
(* distinctness for type tr *) |
|
46 |
(* ------------------------------------------------------------------------ *) |
|
47 |
||
7654 | 48 |
bind_thms ("dist_less_tr", map prover [ |
2640 | 49 |
"~TT << UU", |
50 |
"~FF << UU", |
|
51 |
"~TT << FF", |
|
52 |
"~FF << TT" |
|
7654 | 53 |
]); |
2640 | 54 |
|
55 |
val dist_eq_tr = map prover ["TT~=UU","FF~=UU","TT~=FF"]; |
|
7654 | 56 |
bind_thms ("dist_eq_tr", dist_eq_tr @ (map (fn thm => (thm RS not_sym)) dist_eq_tr)); |
2640 | 57 |
|
58 |
(* ------------------------------------------------------------------------ *) |
|
59 |
(* lemmas about andalso, orelse, neg and if *) |
|
60 |
(* ------------------------------------------------------------------------ *) |
|
61 |
||
7654 | 62 |
bind_thms ("andalso_thms", map prover [ |
2640 | 63 |
"(TT andalso y) = y", |
64 |
"(FF andalso y) = FF", |
|
65 |
"(UU andalso y) = UU", |
|
66 |
"(y andalso TT) = y", |
|
67 |
"(y andalso y) = y" |
|
7654 | 68 |
]); |
2640 | 69 |
|
7654 | 70 |
bind_thms ("orelse_thms", map prover [ |
2640 | 71 |
"(TT orelse y) = TT", |
72 |
"(FF orelse y) = y", |
|
73 |
"(UU orelse y) = UU", |
|
74 |
"(y orelse FF) = y", |
|
7654 | 75 |
"(y orelse y) = y"]); |
2640 | 76 |
|
7654 | 77 |
bind_thms ("neg_thms", map prover [ |
2640 | 78 |
"neg`TT = FF", |
79 |
"neg`FF = TT", |
|
80 |
"neg`UU = UU" |
|
7654 | 81 |
]); |
2640 | 82 |
|
7654 | 83 |
bind_thms ("ifte_thms", map prover [ |
2640 | 84 |
"If UU then e1 else e2 fi = UU", |
85 |
"If FF then e1 else e2 fi = e2", |
|
7654 | 86 |
"If TT then e1 else e2 fi = e1"]); |
2640 | 87 |
|
88 |
Addsimps (dist_less_tr @ dist_eq_tr @ andalso_thms @ |
|
89 |
orelse_thms @ neg_thms @ ifte_thms); |
|
90 |
||
3038 | 91 |
(* ------------------------------------------------------------------- *) |
92 |
(* split-tac for If via If2 because the constant has to be a constant *) |
|
93 |
(* ------------------------------------------------------------------- *) |
|
94 |
||
5068 | 95 |
Goalw [If2_def] |
3038 | 96 |
"P (If2 Q x y ) = ((Q=UU --> P UU) & (Q=TT --> P x) & (Q=FF --> P y))"; |
97 |
by (res_inst_tac [("p","Q")] trE 1); |
|
98 |
by (REPEAT (Asm_full_simp_tac 1)); |
|
4833 | 99 |
qed"split_If2"; |
2640 | 100 |
|
3038 | 101 |
val split_If_tac = |
4833 | 102 |
simp_tac (HOL_basic_ss addsimps [symmetric If2_def]) THEN' (split_tac [split_If2]); |
2640 | 103 |
|
3038 | 104 |
|
2640 | 105 |
|
3038 | 106 |
(* ----------------------------------------------------------------- *) |
107 |
section"Rewriting of HOLCF operations to HOL functions"; |
|
108 |
(* ----------------------------------------------------------------- *) |
|
2640 | 109 |
|
110 |
||
5068 | 111 |
Goal |
3038 | 112 |
"!!t.[|t~=UU|]==> ((t andalso s)=FF)=(t=FF | s=FF)"; |
113 |
by (rtac iffI 1); |
|
114 |
by (res_inst_tac [("p","t")] trE 1); |
|
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4423
diff
changeset
|
115 |
by Auto_tac; |
3038 | 116 |
by (res_inst_tac [("p","t")] trE 1); |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4423
diff
changeset
|
117 |
by Auto_tac; |
3038 | 118 |
qed"andalso_or"; |
2640 | 119 |
|
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5068
diff
changeset
|
120 |
Goal "[|t~=UU|]==> ((t andalso s)~=FF)=(t~=FF & s~=FF)"; |
2640 | 121 |
by (rtac iffI 1); |
3038 | 122 |
by (res_inst_tac [("p","t")] trE 1); |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4423
diff
changeset
|
123 |
by Auto_tac; |
2640 | 124 |
by (res_inst_tac [("p","t")] trE 1); |
4477
b3e5857d8d99
New Auto_tac (by Oheimb), and new syntax (without parens), and expandshort
paulson
parents:
4423
diff
changeset
|
125 |
by Auto_tac; |
2640 | 126 |
qed"andalso_and"; |
127 |
||
5068 | 128 |
Goal "(Def x ~=FF)= x"; |
4098 | 129 |
by (simp_tac (simpset() addsimps [FF_def]) 1); |
3038 | 130 |
qed"Def_bool1"; |
2640 | 131 |
|
5068 | 132 |
Goal "(Def x = FF) = (~x)"; |
4098 | 133 |
by (simp_tac (simpset() addsimps [FF_def]) 1); |
3038 | 134 |
qed"Def_bool2"; |
2640 | 135 |
|
5068 | 136 |
Goal "(Def x = TT) = x"; |
4098 | 137 |
by (simp_tac (simpset() addsimps [TT_def]) 1); |
3038 | 138 |
qed"Def_bool3"; |
139 |
||
5068 | 140 |
Goal "(Def x ~= TT) = (~x)"; |
4098 | 141 |
by (simp_tac (simpset() addsimps [TT_def]) 1); |
3038 | 142 |
qed"Def_bool4"; |
2640 | 143 |
|
5068 | 144 |
Goal |
2640 | 145 |
"(If Def P then A else B fi)= (if P then A else B)"; |
146 |
by (res_inst_tac [("p","Def P")] trE 1); |
|
147 |
by (Asm_full_simp_tac 1); |
|
4098 | 148 |
by (asm_full_simp_tac (simpset() addsimps tr_defs@[flift1_def,o_def]) 1); |
149 |
by (asm_full_simp_tac (simpset() addsimps tr_defs@[flift1_def,o_def]) 1); |
|
2640 | 150 |
qed"If_and_if"; |
151 |
||
3038 | 152 |
Addsimps [Def_bool1,Def_bool2,Def_bool3,Def_bool4]; |
153 |
||
154 |
(* ----------------------------------------------------------------- *) |
|
155 |
section"admissibility"; |
|
156 |
(* ----------------------------------------------------------------- *) |
|
157 |
||
158 |
||
159 |
(* The following rewrite rules for admissibility should in the future be |
|
160 |
replaced by a more general admissibility test that also checks |
|
161 |
chain-finiteness, of which these lemmata are specific examples *) |
|
162 |
||
5068 | 163 |
Goal "x~=FF = (x=TT|x=UU)"; |
3038 | 164 |
by (res_inst_tac [("p","x")] trE 1); |
165 |
by (TRYALL (Asm_full_simp_tac)); |
|
166 |
qed"adm_trick_1"; |
|
167 |
||
5068 | 168 |
Goal "x~=TT = (x=FF|x=UU)"; |
3038 | 169 |
by (res_inst_tac [("p","x")] trE 1); |
170 |
by (TRYALL (Asm_full_simp_tac)); |
|
171 |
qed"adm_trick_2"; |
|
172 |
||
7654 | 173 |
bind_thms ("adm_tricks", [adm_trick_1,adm_trick_2]); |
3038 | 174 |
|
175 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5068
diff
changeset
|
176 |
Goal "cont(f) ==> adm (%x. (f x)~=TT)"; |
3038 | 177 |
by (simp_tac (HOL_basic_ss addsimps adm_tricks) 1); |
178 |
by (REPEAT ((resolve_tac (adm_lemmas@cont_lemmas1) 1) ORELSE atac 1)); |
|
179 |
qed"adm_nTT"; |
|
180 |
||
5143
b94cd208f073
Removal of leading "\!\!..." from most Goal commands
paulson
parents:
5068
diff
changeset
|
181 |
Goal "cont(f) ==> adm (%x. (f x)~=FF)"; |
3038 | 182 |
by (simp_tac (HOL_basic_ss addsimps adm_tricks) 1); |
183 |
by (REPEAT ((resolve_tac (adm_lemmas@cont_lemmas1) 1) ORELSE atac 1)); |
|
184 |
qed"adm_nFF"; |
|
185 |
||
4642 | 186 |
Addsimps [adm_nTT,adm_nFF]; |