author  ballarin 
Wed, 19 Jul 2006 19:25:58 +0200  
changeset 20168  ed7bced29e1b 
parent 18988  d6e5fa2ba8b8 
child 20217  25b068a99d2b 
permissions  rwrr 
4  1 
(* Title: Provers/splitter 
2 
ID: $Id$ 

3 
Author: Tobias Nipkow 

1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

4 
Copyright 1995 TU Munich 
4  5 

6 
Generic casesplitter, suitable for most logics. 

13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

7 
Deals with equalities of the form ?P(f args) = ... 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

8 
where "f args" must be a firstorder term without duplicate variables. 
0  9 
*) 
10 

5304  11 
infix 4 addsplits delsplits; 
12 

13 
signature SPLITTER_DATA = 

14 
sig 

5553  15 
val mk_eq : thm > thm 
5304  16 
val meta_eq_to_iff: thm (* "x == y ==> x = y" *) 
17 
val iffD : thm (* "[ P = Q; Q ] ==> P" *) 

18 
val disjE : thm (* "[ P  Q; P ==> R; Q ==> R ] ==> R" *) 

19 
val conjE : thm (* "[ P & Q; [ P; Q ] ==> R ] ==> R" *) 

20 
val exE : thm (* "[ x. P x; !!x. P x ==> Q ] ==> Q" *) 

21 
val contrapos : thm (* "[ ~ Q; P ==> Q ] ==> ~ P" *) 

22 
val contrapos2 : thm (* "[ Q; ~ P ==> ~ Q ] ==> P" *) 

23 
val notnotD : thm (* "~ ~ P ==> P" *) 

24 
end 

25 

26 
signature SPLITTER = 

27 
sig 

28 
val split_tac : thm list > int > tactic 

29 
val split_inside_tac: thm list > int > tactic 

30 
val split_asm_tac : thm list > int > tactic 

31 
val addsplits : simpset * thm list > simpset 

32 
val delsplits : simpset * thm list > simpset 

33 
val Addsplits : thm list > unit 

34 
val Delsplits : thm list > unit 

18728  35 
val split_add: attribute 
36 
val split_del: attribute 

8468  37 
val split_modifiers : (Args.T list > (Method.modifier * Args.T list)) list 
18708  38 
val setup: theory > theory 
5304  39 
end; 
40 

41 
functor SplitterFun(Data: SPLITTER_DATA): SPLITTER = 

17881  42 
struct 
5304  43 

18545  44 
val Const (const_not, _) $ _ = 
45 
ObjectLogic.drop_judgment (the_context ()) 

46 
(#1 (Logic.dest_implies (Thm.prop_of Data.notnotD))); 

5304  47 

18545  48 
val Const (const_or , _) $ _ $ _ = 
49 
ObjectLogic.drop_judgment (the_context ()) 

50 
(#1 (Logic.dest_implies (Thm.prop_of Data.disjE))); 

51 

52 
val const_Trueprop = ObjectLogic.judgment_name (the_context ()); 

53 

1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

54 

4668
131989b78417
Little reorganization. Loop tactics have names now.
nipkow
parents:
4519
diff
changeset

55 
fun split_format_err() = error("Wrong format for split rule"); 
131989b78417
Little reorganization. Loop tactics have names now.
nipkow
parents:
4519
diff
changeset

56 

5553  57 
fun split_thm_info thm = case concl_of (Data.mk_eq thm) of 
13855
644692eca537
addsplits / delsplits no longer ignore type of constant.
berghofe
parents:
13157
diff
changeset

58 
Const("==", _) $ (Var _ $ t) $ c => (case strip_comb t of 
644692eca537
addsplits / delsplits no longer ignore type of constant.
berghofe
parents:
13157
diff
changeset

59 
(Const p, _) => (p, case c of (Const (s, _) $ _) => s = const_not  _ => false) 
644692eca537
addsplits / delsplits no longer ignore type of constant.
berghofe
parents:
13157
diff
changeset

60 
 _ => split_format_err ()) 
644692eca537
addsplits / delsplits no longer ignore type of constant.
berghofe
parents:
13157
diff
changeset

61 
 _ => split_format_err (); 
5304  62 

63 
fun mk_case_split_tac order = 

0  64 
let 
65 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

66 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

67 
(************************************************************ 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

68 
Create lifttheorem "trlift" : 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

69 

7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

70 
[ !!x. Q x == R x; P(%x. R x) == C ] ==> P (%x. Q x) == C 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

71 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

72 
*************************************************************) 
5304  73 

74 
val meta_iffD = Data.meta_eq_to_iff RS Data.iffD; 

943  75 
val lift = 
18545  76 
let val ct = read_cterm Pure.thy 
77 
("(!!x. (Q::('b::{})=>('c::{}))(x) == R(x)) ==> \ 

14854  78 
\P(%x. Q(x)) == P(%x. R(x))::'a::{}",propT) 
17959  79 
in OldGoals.prove_goalw_cterm [] ct 
943  80 
(fn [prem] => [rewtac prem, rtac reflexive_thm 1]) 
81 
end; 

4  82 

0  83 
val trlift = lift RS transitive_thm; 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

84 
val _ $ (P $ _) $ _ = concl_of trlift; 
0  85 

86 

17881  87 
(************************************************************************ 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

88 
Set up term for instantiation of P in the lifttheorem 
17881  89 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

90 
Ts : types of parameters (i.e. variables bound by metaquantifiers) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

91 
t : lefthand side of metaequality in subgoal 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

92 
the lift theorem is applied to (see select) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

93 
pos : "path" leading to abstraction, coded as a list 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

94 
T : type of body of P(...) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

95 
maxi : maximum index of Vars 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

96 
*************************************************************************) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

97 

1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

98 
fun mk_cntxt Ts t pos T maxi = 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

99 
let fun var (t,i) = Var(("X",i),type_of1(Ts,t)); 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

100 
fun down [] t i = Bound 0 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

101 
 down (p::ps) t i = 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

102 
let val (h,ts) = strip_comb t 
15570  103 
val v1 = ListPair.map var (Library.take(p,ts), i upto (i+p1)) 
104 
val u::us = Library.drop(p,ts) 

2266  105 
val v2 = ListPair.map var (us, (i+p) upto (i+length(ts)2)) 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

106 
in list_comb(h,v1@[down ps u (i+length ts)]@v2) end; 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

107 
in Abs("", T, down (rev pos) t maxi) end; 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

108 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

109 

17881  110 
(************************************************************************ 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

111 
Set up term for instantiation of P in the splittheorem 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

112 
P(...) == rhs 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

113 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

114 
t : lefthand side of metaequality in subgoal 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

115 
the split theorem is applied to (see select) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

116 
T : type of body of P(...) 
4232  117 
tt : the term Const(key,..) $ ... 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

118 
*************************************************************************) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

119 

4232  120 
fun mk_cntxt_splitthm t tt T = 
121 
let fun repl lev t = 

7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

122 
if incr_boundvars lev tt aconv t then Bound lev 
4232  123 
else case t of 
124 
(Abs (v, T2, t)) => Abs (v, T2, repl (lev+1) t) 

125 
 (Bound i) => Bound (if i>=lev then i+1 else i) 

126 
 (t1 $ t2) => (repl lev t1) $ (repl lev t2) 

127 
 t => t 

128 
in Abs("", T, repl 0 t) end; 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

129 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

130 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

131 
(* add all loose bound variables in t to list is *) 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

132 
fun add_lbnos(is,t) = add_loose_bnos(t,0,is); 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

133 

7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

134 
(* check if the innermost abstraction that needs to be removed 
1064  135 
has a body of type T; otherwise the expansion thm will fail later on 
136 
*) 

137 
fun type_test(T,lbnos,apsns) = 

15570  138 
let val (_,U,_) = List.nth(apsns, Library.foldl Int.min (hd lbnos, tl lbnos)) 
1064  139 
in T=U end; 
0  140 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

141 
(************************************************************************* 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

142 
Create a "split_pack". 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

143 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

144 
thm : the relevant splittheorem, i.e. P(...) == rhs , where P(...) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

145 
is of the form 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

146 
P( Const(key,...) $ t_1 $ ... $ t_n ) (e.g. key = "if") 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

147 
T : type of P(...) 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

148 
T' : type of term to be scanned 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

149 
n : number of arguments expected by Const(key,...) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

150 
ts : list of arguments actually found 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

151 
apsns : list of tuples of the form (T,U,pos), one tuple for each 
17881  152 
abstraction that is encountered on the way to the position where 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

153 
Const(key, ...) $ ... occurs, where 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

154 
T : type of the variable bound by the abstraction 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

155 
U : type of the abstraction's body 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

156 
pos : "path" leading to the body of the abstraction 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

157 
pos : "path" leading to the position where Const(key, ...) $ ... occurs. 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

158 
TB : type of Const(key,...) $ t_1 $ ... $ t_n 
1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

159 
t : the term Const(key,...) $ t_1 $ ... $ t_n 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

160 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

161 
A split pack is a tuple of the form 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

162 
(thm, apsns, pos, TB, tt) 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

163 
Note : apsns is reversed, so that the outermost quantifier's position 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

164 
comes first ! If the terms in ts don't contain variables bound 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

165 
by other than metaquantifiers, apsns is empty, because no further 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

166 
lifting is required before applying the splittheorem. 
17881  167 
******************************************************************************) 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

168 

7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

169 
fun mk_split_pack(thm, T, T', n, ts, apsns, pos, TB, t) = 
1064  170 
if n > length ts then [] 
171 
else let val lev = length apsns 

15570  172 
val lbnos = Library.foldl add_lbnos ([],Library.take(n,ts)) 
173 
val flbnos = List.filter (fn i => i < lev) lbnos 

4232  174 
val tt = incr_boundvars (~lev) t 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

175 
in if null flbnos then 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

176 
if T = T' then [(thm,[],pos,TB,tt)] else [] 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

177 
else if type_test(T,flbnos,apsns) then [(thm, rev apsns,pos,TB,tt)] 
2143  178 
else [] 
1064  179 
end; 
0  180 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

181 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

182 
(**************************************************************************** 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

183 
Recursively scans term for occurences of Const(key,...) $ ... 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

184 
Returns a list of "splitpacks" (one for each occurence of Const(key,...) ) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

185 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

186 
cmap : association list of splittheorems that should be tried. 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

187 
The elements have the format (key,(thm,T,n)) , where 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

188 
key : the theorem's key constant ( Const(key,...) $ ... ) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

189 
thm : the theorem itself 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

190 
T : type of P( Const(key,...) $ ... ) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

191 
n : number of arguments expected by Const(key,...) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

192 
Ts : types of parameters 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

193 
t : the term to be scanned 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

194 
******************************************************************************) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

195 

13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

196 
(* Simplified firstorder matching; 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

197 
assumes that all Vars in the pattern are distinct; 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

198 
see Pure/pattern.ML for the full version; 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

199 
*) 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

200 
local 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

201 
exception MATCH 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

202 
in 
16935  203 
fun typ_match sg (tyenv, TU) = (Sign.typ_match sg TU tyenv) 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

204 
handle Type.TYPE_MATCH => raise MATCH; 
16935  205 
fun fomatch sg args = 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

206 
let 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

207 
fun mtch tyinsts = fn 
16935  208 
(Ts,Var(_,T), t) => typ_match sg (tyinsts, (T, fastype_of1(Ts,t))) 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

209 
 (_,Free (a,T), Free (b,U)) => 
16935  210 
if a=b then typ_match sg (tyinsts,(T,U)) else raise MATCH 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

211 
 (_,Const (a,T), Const (b,U)) => 
16935  212 
if a=b then typ_match sg (tyinsts,(T,U)) else raise MATCH 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

213 
 (_,Bound i, Bound j) => if i=j then tyinsts else raise MATCH 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

214 
 (Ts,Abs(_,T,t), Abs(_,U,u)) => 
16935  215 
mtch (typ_match sg (tyinsts,(T,U))) (U::Ts,t,u) 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

216 
 (Ts, f$t, g$u) => mtch (mtch tyinsts (Ts,f,g)) (Ts, t, u) 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

217 
 _ => raise MATCH 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

218 
in (mtch Vartab.empty args; true) handle MATCH => false end; 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

219 
end 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

220 

6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

221 
fun split_posns cmap sg Ts t = 
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

222 
let 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

223 
val T' = fastype_of1 (Ts, t); 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

224 
fun posns Ts pos apsns (Abs (_, T, t)) = 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

225 
let val U = fastype_of1 (T::Ts,t) 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

226 
in posns (T::Ts) (0::pos) ((T, U, pos)::apsns) t end 
6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

227 
 posns Ts pos apsns t = 
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

228 
let 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

229 
val (h, ts) = strip_comb t 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

230 
fun iter((i, a), t) = (i+1, (posns Ts (i::pos) apsns t) @ a); 
6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

231 
val a = case h of 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

232 
Const(c, cT) => 
9267
dbf30a2d1b56
Now two split thms for same constant at different types is allowed.
nipkow
parents:
8815
diff
changeset

233 
let fun find [] = [] 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

234 
 find ((gcT, pat, thm, T, n)::tups) = 
15570  235 
let val t2 = list_comb (h, Library.take (n, ts)) 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

236 
in if Sign.typ_instance sg (cT, gcT) 
16935  237 
andalso fomatch sg (Ts,pat,t2) 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

238 
then mk_split_pack(thm,T,T',n,ts,apsns,pos,type_of1(Ts,t2),t2) 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

239 
else find tups 
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

240 
end 
17184  241 
in find (these (AList.lookup (op =) cmap c)) end 
6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

242 
 _ => [] 
15570  243 
in snd(Library.foldl iter ((0, a), ts)) end 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

244 
in posns Ts [] [] t end; 
0  245 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

246 

15570  247 
fun nth_subgoal i thm = List.nth(prems_of thm,i1); 
0  248 

1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

249 
fun shorter((_,ps,pos,_,_),(_,qs,qos,_,_)) = 
4519  250 
prod_ord (int_ord o pairself length) (order o pairself length) 
251 
((ps, pos), (qs, qos)); 

252 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

253 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

254 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

255 
(************************************************************ 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

256 
call split_posns with appropriate parameters 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

257 
*************************************************************) 
0  258 

1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

259 
fun select cmap state i = 
6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

260 
let val sg = #sign(rep_thm state) 
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

261 
val goali = nth_subgoal i state 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

262 
val Ts = rev(map #2 (Logic.strip_params goali)) 
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

263 
val _ $ t $ _ = Logic.strip_assums_concl goali; 
6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

264 
in (Ts,t, sort shorter (split_posns cmap sg Ts t)) end; 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

265 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

266 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

267 
(************************************************************* 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

268 
instantiate lift theorem 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

269 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

270 
if t is of the form 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

271 
... ( Const(...,...) $ Abs( .... ) ) ... 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

272 
then 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

273 
P = %a. ... ( Const(...,...) $ a ) ... 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

274 
where a has type T > U 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

275 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

276 
Ts : types of parameters 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

277 
t : lefthand side of metaequality in subgoal 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

278 
the split theorem is applied to (see cmap) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

279 
T,U,pos : see mk_split_pack 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

280 
state : current proof state 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

281 
lift : the lift theorem 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

282 
i : no. of subgoal 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

283 
**************************************************************) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

284 

7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

285 
fun inst_lift Ts t (T, U, pos) state i = 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

286 
let 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

287 
val cert = cterm_of (sign_of_thm state); 
17881  288 
val cntxt = mk_cntxt Ts t pos (T > U) (#maxidx(rep_thm trlift)); 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

289 
in cterm_instantiate [(cert P, cert cntxt)] trlift 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

290 
end; 
0  291 

292 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

293 
(************************************************************* 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

294 
instantiate split theorem 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

295 

c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

296 
Ts : types of parameters 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

297 
t : lefthand side of metaequality in subgoal 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

298 
the split theorem is applied to (see cmap) 
4232  299 
tt : the term Const(key,..) $ ... 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

300 
thm : the split theorem 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

301 
TB : type of body of P(...) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

302 
state : current proof state 
4232  303 
i : number of subgoal 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

304 
**************************************************************) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

305 

4232  306 
fun inst_split Ts t tt thm TB state i = 
17881  307 
let 
18145  308 
val thm' = Thm.lift_rule (Thm.cprem_of state i) thm; 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

309 
val (P, _) = strip_comb (fst (Logic.dest_equals 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

310 
(Logic.strip_assums_concl (#prop (rep_thm thm'))))); 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

311 
val cert = cterm_of (sign_of_thm state); 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

312 
val cntxt = mk_cntxt_splitthm t tt TB; 
15570  313 
val abss = Library.foldl (fn (t, T) => Abs ("", T, t)); 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

314 
in cterm_instantiate [(cert P, cert (abss (cntxt, Ts)))] thm' 
4232  315 
end; 
1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

316 

7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

317 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

318 
(***************************************************************************** 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

319 
The splittactic 
17881  320 

1686
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

321 
splits : list of splittheorems to be tried 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

322 
i : number of subgoal the tactic should be applied to 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

323 
*****************************************************************************) 
c67d543bc395
Added functions mk_cntxt_splitthm and inst_split which instantiate
berghofe
parents:
1064
diff
changeset

324 

0  325 
fun split_tac [] i = no_tac 
326 
 split_tac splits i = 

5553  327 
let val splits = map Data.mk_eq splits; 
9267
dbf30a2d1b56
Now two split thms for same constant at different types is allowed.
nipkow
parents:
8815
diff
changeset

328 
fun add_thm(cmap,thm) = 
3918  329 
(case concl_of thm of _$(t as _$lhs)$_ => 
6130
30b84ad2131d
Fixed old bug: selection of constant to be split should depend not just on
nipkow
parents:
5553
diff
changeset

330 
(case strip_comb lhs of (Const(a,aT),args) => 
13157
4a4599f78f18
allowed more general split rules to cope with div/mod 2
nipkow
parents:
10821
diff
changeset

331 
let val info = (aT,lhs,thm,fastype_of t,length args) 
17184  332 
in case AList.lookup (op =) cmap a of 
17325  333 
SOME infos => AList.update (op =) (a, info::infos) cmap 
15531  334 
 NONE => (a,[info])::cmap 
9267
dbf30a2d1b56
Now two split thms for same constant at different types is allowed.
nipkow
parents:
8815
diff
changeset

335 
end 
4668
131989b78417
Little reorganization. Loop tactics have names now.
nipkow
parents:
4519
diff
changeset

336 
 _ => split_format_err()) 
131989b78417
Little reorganization. Loop tactics have names now.
nipkow
parents:
4519
diff
changeset

337 
 _ => split_format_err()) 
15570  338 
val cmap = Library.foldl add_thm ([],splits); 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

339 
fun lift_tac Ts t p st = rtac (inst_lift Ts t p st i) i st 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

340 
fun lift_split_tac state = 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

341 
let val (Ts, t, splits) = select cmap state i 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

342 
in case splits of 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

343 
[] => no_tac state 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

344 
 (thm, apsns, pos, TB, tt)::_ => 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

345 
(case apsns of 
7672
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

346 
[] => compose_tac (false, inst_split Ts t tt thm TB state i, 0) i state 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

347 
 p::_ => EVERY [lift_tac Ts t p, 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

348 
rtac reflexive_thm (i+1), 
c092e67d12f8
 Fixed bug in mk_split_pack which caused application of expansion theorem
berghofe
parents:
6130
diff
changeset

349 
lift_split_tac] state) 
1030
1d8fa2fc4b9c
Completely rewrote split_tac. The old one failed in strange circumstances.
nipkow
parents:
943
diff
changeset

350 
end 
17881  351 
in COND (has_fewer_prems i) no_tac 
5304  352 
(rtac meta_iffD i THEN lift_split_tac) 
0  353 
end; 
354 

355 
in split_tac end; 

1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

356 

5304  357 

358 
val split_tac = mk_case_split_tac int_ord; 

4189  359 

5304  360 
val split_inside_tac = mk_case_split_tac (rev_order o int_ord); 
361 

4189  362 

363 
(***************************************************************************** 

364 
The splittactic for premises 

17881  365 

4189  366 
splits : list of splittheorems to be tried 
5304  367 
****************************************************************************) 
4202  368 
fun split_asm_tac [] = K no_tac 
17881  369 
 split_asm_tac splits = 
5304  370 

13855
644692eca537
addsplits / delsplits no longer ignore type of constant.
berghofe
parents:
13157
diff
changeset

371 
let val cname_list = map (fst o fst o split_thm_info) splits; 
4189  372 
fun is_case (a,_) = a mem cname_list; 
17881  373 
fun tac (t,i) = 
374 
let val n = find_index (exists_Const is_case) 

375 
(Logic.strip_assums_hyp t); 

18545  376 
fun first_prem_is_disj (Const ("==>", _) $ (Const (c, _) 
377 
$ (Const (s, _) $ _ $ _ )) $ _ ) = c = const_Trueprop andalso s = const_or 

17881  378 
 first_prem_is_disj (Const("all",_)$Abs(_,_,t)) = 
379 
first_prem_is_disj t 

380 
 first_prem_is_disj _ = false; 

5437  381 
(* does not work properly if the split variable is bound by a quantfier *) 
17881  382 
fun flat_prems_tac i = SUBGOAL (fn (t,i) => 
383 
(if first_prem_is_disj t 

384 
then EVERY[etac Data.disjE i,rotate_tac ~1 i, 

385 
rotate_tac ~1 (i+1), 

386 
flat_prems_tac (i+1)] 

387 
else all_tac) 

388 
THEN REPEAT (eresolve_tac [Data.conjE,Data.exE] i) 

389 
THEN REPEAT (dresolve_tac [Data.notnotD] i)) i; 

390 
in if n<0 then no_tac else DETERM (EVERY' 

391 
[rotate_tac n, etac Data.contrapos2, 

392 
split_tac splits, 

393 
rotate_tac ~1, etac Data.contrapos, rotate_tac ~1, 

394 
flat_prems_tac] i) 

395 
end; 

4189  396 
in SUBGOAL tac 
397 
end; 

398 

10652  399 
fun gen_split_tac [] = K no_tac 
400 
 gen_split_tac (split::splits) = 

401 
let val (_,asm) = split_thm_info split 

402 
in (if asm then split_asm_tac else split_tac) [split] ORELSE' 

403 
gen_split_tac splits 

404 
end; 

8468  405 

18688  406 

8468  407 
(** declare split rules **) 
408 

409 
(* addsplits / delsplits *) 

410 

13859
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

411 
fun string_of_typ (Type (s, Ts)) = (if null Ts then "" 
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

412 
else enclose "(" ")" (commas (map string_of_typ Ts))) ^ s 
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

413 
 string_of_typ _ = "_"; 
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

414 

17881  415 
fun split_name (name, T) asm = "split " ^ 
13859
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

416 
(if asm then "asm " else "") ^ name ^ " :: " ^ string_of_typ T; 
4189  417 

5304  418 
fun ss addsplits splits = 
419 
let fun addsplit (ss,split) = 

420 
let val (name,asm) = split_thm_info split 

13859
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

421 
in Simplifier.addloop (ss, (split_name name asm, 
17881  422 
(if asm then split_asm_tac else split_tac) [split])) end 
15570  423 
in Library.foldl addsplit (ss,splits) end; 
1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

424 

5304  425 
fun ss delsplits splits = 
426 
let fun delsplit(ss,split) = 

427 
let val (name,asm) = split_thm_info split 

13859
adf68d9e5dec
split_name no longer uses Sign.string_of_typ to encode types, since
berghofe
parents:
13855
diff
changeset

428 
in Simplifier.delloop (ss, split_name name asm) 
15570  429 
end in Library.foldl delsplit (ss,splits) end; 
1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

430 

17881  431 
fun Addsplits splits = (change_simpset (fn ss => ss addsplits splits)); 
432 
fun Delsplits splits = (change_simpset (fn ss => ss delsplits splits)); 

8468  433 

434 

435 
(* attributes *) 

436 

437 
val splitN = "split"; 

438 

18688  439 
val split_add = Simplifier.attrib (op addsplits); 
440 
val split_del = Simplifier.attrib (op delsplits); 

8634  441 

442 

9703  443 
(* methods *) 
8468  444 

445 
val split_modifiers = 

18728  446 
[Args.$$$ splitN  Args.colon >> K ((I, split_add): Method.modifier), 
447 
Args.$$$ splitN  Args.add  Args.colon >> K (I, split_add), 

448 
Args.$$$ splitN  Args.del  Args.colon >> K (I, split_del)]; 

8468  449 

18688  450 
fun split_meth src = 
18988  451 
Method.syntax Attrib.thms src 
18688  452 
#> (fn (_, ths) => Method.SIMPLE_METHOD' HEADGOAL (CHANGED_PROP o gen_split_tac ths)); 
9703  453 

8468  454 

18688  455 
(* theory setup *) 
8468  456 

9703  457 
val setup = 
18708  458 
(Attrib.add_attributes 
18728  459 
[(splitN, Attrib.add_del_args split_add split_del, "declaration of case split rule")] #> 
18708  460 
Method.add_methods [(splitN, split_meth, "apply case split rule")]); 
4189  461 

1721
445654b6cb95
Rewrote mk_cntxt_splitthm. Added function mk_case_split_inside_tac.
berghofe
parents:
1686
diff
changeset

462 
end; 