1
|
1 |
(* Title: HOL/simpdata.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Tobias Nipkow
|
|
4 |
Copyright 1991 University of Cambridge
|
|
5 |
|
|
6 |
Instantiation of the generic simplifier
|
|
7 |
*)
|
|
8 |
|
0
|
9 |
open Simplifier;
|
|
10 |
|
|
11 |
local
|
|
12 |
|
|
13 |
fun prover s = prove_goal HOL.thy s (fn _ => [fast_tac HOL_cs 1]);
|
|
14 |
|
|
15 |
val P_imp_P_iff_True = prover "P --> (P = True)" RS mp;
|
|
16 |
val P_imp_P_eq_True = P_imp_P_iff_True RS eq_reflection;
|
|
17 |
|
|
18 |
val not_P_imp_P_iff_F = prover "~P --> (P = False)" RS mp;
|
|
19 |
val not_P_imp_P_eq_False = not_P_imp_P_iff_F RS eq_reflection;
|
|
20 |
|
|
21 |
fun atomize r =
|
|
22 |
case concl_of r of
|
|
23 |
Const("Trueprop",_) $ p =>
|
|
24 |
(case p of
|
|
25 |
Const("op -->",_)$_$_ => atomize(r RS mp)
|
|
26 |
| Const("op &",_)$_$_ => atomize(r RS conjunct1) @
|
|
27 |
atomize(r RS conjunct2)
|
|
28 |
| Const("All",_)$_ => atomize(r RS spec)
|
|
29 |
| Const("True",_) => []
|
|
30 |
| Const("False",_) => []
|
|
31 |
| _ => [r])
|
|
32 |
| _ => [r];
|
|
33 |
|
|
34 |
fun mk_eq r = case concl_of r of
|
|
35 |
Const("==",_)$_$_ => r
|
|
36 |
| _$(Const("op =",_)$_$_) => r RS eq_reflection
|
|
37 |
| _$(Const("not",_)$_) => r RS not_P_imp_P_eq_False
|
|
38 |
| _ => r RS P_imp_P_eq_True;
|
|
39 |
(* last 2 lines requires all formulae to be of the from Trueprop(.) *)
|
|
40 |
|
|
41 |
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th;
|
|
42 |
|
|
43 |
fun mk_rews thm = map mk_eq (atomize(gen_all thm));
|
|
44 |
|
1
|
45 |
val imp_cong = impI RSN
|
0
|
46 |
(2, prove_goal HOL.thy "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))"
|
|
47 |
(fn _=> [fast_tac HOL_cs 1]) RS mp RS mp);
|
|
48 |
|
|
49 |
val o_apply = prove_goal HOL.thy "(f o g)(x) = f(g(x))"
|
|
50 |
(fn _ => [ (stac o_def 1), (rtac refl 1) ]);
|
|
51 |
|
|
52 |
val simp_thms = map prover
|
|
53 |
[ "(x=x) = True",
|
|
54 |
"(~True) = False", "(~False) = True", "(~ ~ P) = P",
|
|
55 |
"(True=P) = P", "(P=True) = P",
|
|
56 |
"(True --> P) = P", "(False --> P) = True",
|
|
57 |
"(P --> True) = True", "(P --> P) = True",
|
|
58 |
"(P & True) = P", "(True & P) = P",
|
|
59 |
"(P & False) = False", "(False & P) = False", "(P & P) = P",
|
|
60 |
"(P | True) = True", "(True | P) = True",
|
|
61 |
"(P | False) = P", "(False | P) = P", "(P | P) = P",
|
|
62 |
"(!x.P) = P",
|
|
63 |
"(P|Q --> R) = ((P-->R)&(Q-->R))" ];
|
|
64 |
|
|
65 |
val meta_obj_reflection = prove_goal HOL.thy "x==y ==> x=y"
|
|
66 |
(fn [prem] => [rewtac prem, rtac refl 1]);
|
|
67 |
|
|
68 |
in
|
|
69 |
|
|
70 |
|
|
71 |
val if_True = prove_goal HOL.thy "if(True,x,y) = x"
|
|
72 |
(fn _=>[stac if_def 1, fast_tac (HOL_cs addIs [select_equality]) 1]);
|
|
73 |
|
|
74 |
val if_False = prove_goal HOL.thy "if(False,x,y) = y"
|
|
75 |
(fn _=>[stac if_def 1, fast_tac (HOL_cs addIs [select_equality]) 1]);
|
|
76 |
|
|
77 |
val if_P = prove_goal HOL.thy "P ==> if(P,x,y) = x"
|
|
78 |
(fn [prem] => [ stac (prem RS eqTrueI) 1, rtac if_True 1 ]);
|
|
79 |
|
|
80 |
val if_not_P = prove_goal HOL.thy "~P ==> if(P,x,y) = y"
|
|
81 |
(fn [prem] => [ stac (prem RS not_P_imp_P_iff_F) 1, rtac if_False 1 ]);
|
|
82 |
|
|
83 |
val expand_if = prove_goal HOL.thy
|
|
84 |
"P(if(Q,x,y)) = ((Q --> P(x)) & (~Q --> P(y)))"
|
|
85 |
(fn _=> [ (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1),
|
|
86 |
rtac (if_P RS ssubst) 2,
|
|
87 |
rtac (if_not_P RS ssubst) 1,
|
|
88 |
REPEAT(fast_tac HOL_cs 1) ]);
|
|
89 |
|
|
90 |
val if_cong = prove_goal HOL.thy
|
|
91 |
"[| b=c; c ==> x=u; ~c ==> y=v |] ==> if(b,x,y) = if(c,u,v)"
|
|
92 |
(fn rew::prems =>
|
|
93 |
[stac rew 1, stac expand_if 1, stac expand_if 1,
|
1
|
94 |
fast_tac (HOL_cs addDs prems) 1]);
|
0
|
95 |
|
1
|
96 |
infix addcongs;
|
|
97 |
fun ss addcongs congs = ss addeqcongs (congs RL [eq_reflection]);
|
0
|
98 |
|
|
99 |
val HOL_ss = empty_ss
|
|
100 |
setmksimps mk_rews
|
|
101 |
setsolver (fn prems => resolve_tac (TrueI::refl::prems))
|
|
102 |
setsubgoaler asm_simp_tac
|
|
103 |
addsimps ([if_True, if_False, o_apply] @ simp_thms)
|
1
|
104 |
addcongs [imp_cong];
|
0
|
105 |
|
|
106 |
fun split_tac splits =
|
|
107 |
mk_case_split_tac (meta_obj_reflection RS iffD2) (map mk_eq splits);
|
|
108 |
|
|
109 |
end;
|