author | haftmann |
Sun, 05 Jun 2005 16:09:48 +0200 | |
changeset 16280 | d7f8c48d5acb |
parent 15794 | 5de27a5fc5ed |
child 16391 | 65c8070844ea |
permissions | -rw-r--r-- |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
1 |
(* Title: Provers/induct_method.ML |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
2 |
ID: $Id$ |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
3 |
Author: Markus Wenzel, TU Muenchen |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
4 |
|
11735 | 5 |
Proof by cases and induction on sets and types. |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
6 |
*) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
7 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
8 |
signature INDUCT_METHOD_DATA = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
9 |
sig |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
10 |
val dest_concls: term -> term list |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
11 |
val cases_default: thm |
11996
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
12 |
val local_impI: thm |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
13 |
val conjI: thm |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
14 |
val atomize: thm list |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
15 |
val rulify1: thm list |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
16 |
val rulify2: thm list |
12240 | 17 |
val localize: thm list |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
18 |
end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
19 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
20 |
signature INDUCT_METHOD = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
21 |
sig |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
22 |
val setup: (theory -> theory) list |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
23 |
end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
24 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
25 |
functor InductMethodFun(Data: INDUCT_METHOD_DATA): INDUCT_METHOD = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
26 |
struct |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
27 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
28 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
29 |
(** misc utils **) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
30 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
31 |
(* align lists *) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
32 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
33 |
fun align_left msg xs ys = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
34 |
let val m = length xs and n = length ys |
11735 | 35 |
in if m < n then raise ERROR_MESSAGE msg else (Library.take (n, xs) ~~ ys) end; |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
36 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
37 |
fun align_right msg xs ys = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
38 |
let val m = length xs and n = length ys |
11735 | 39 |
in if m < n then raise ERROR_MESSAGE msg else (Library.drop (m - n, xs) ~~ ys) end; |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
40 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
41 |
|
11735 | 42 |
(* prep_inst *) |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
43 |
|
11735 | 44 |
fun prep_inst align cert tune (tm, ts) = |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
45 |
let |
15531 | 46 |
fun prep_var (x, SOME t) = |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
47 |
let |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
48 |
val cx = cert x; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
49 |
val {T = xT, sign, ...} = Thm.rep_cterm cx; |
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
50 |
val ct = cert (tune t); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
51 |
in |
15531 | 52 |
if Sign.typ_instance sign (#T (Thm.rep_cterm ct), xT) then SOME (cx, ct) |
11735 | 53 |
else raise ERROR_MESSAGE (Pretty.string_of (Pretty.block |
54 |
[Pretty.str "Ill-typed instantiation:", Pretty.fbrk, |
|
55 |
Display.pretty_cterm ct, Pretty.str " ::", Pretty.brk 1, |
|
56 |
Display.pretty_ctyp (#T (Thm.crep_cterm ct))])) |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
57 |
end |
15531 | 58 |
| prep_var (_, NONE) = NONE; |
11735 | 59 |
val xs = InductAttrib.vars_of tm; |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
60 |
in |
11735 | 61 |
align "Rule has fewer variables than instantiations given" xs ts |
15570 | 62 |
|> List.mapPartial prep_var |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
63 |
end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
64 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
65 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
66 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
67 |
(** cases method **) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
68 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
69 |
(* |
11735 | 70 |
rule selection scheme: |
71 |
cases - classical case split |
|
72 |
<x:A> cases ... - set cases |
|
73 |
cases t - type cases |
|
74 |
... cases ... R - explicit rule |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
75 |
*) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
76 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
77 |
local |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
78 |
|
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
79 |
fun resolveq_cases_tac make ruleq i st = |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
80 |
ruleq |> Seq.map (fn (rule, (cases, facts)) => |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
81 |
(Method.insert_tac facts THEN' Tactic.rtac rule) i st |
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
82 |
|> Seq.map (rpair (make (Thm.sign_of_thm rule, Thm.prop_of rule) cases))) |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
83 |
|> Seq.flat; |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
84 |
|
15531 | 85 |
fun find_casesT ctxt ((SOME t :: _) :: _) = InductAttrib.find_casesT ctxt (fastype_of t) |
11735 | 86 |
| find_casesT _ _ = []; |
87 |
||
88 |
fun find_casesS ctxt (fact :: _) = InductAttrib.find_casesS ctxt fact |
|
89 |
| find_casesS _ _ = []; |
|
90 |
||
13597
a8230e035e96
fixes !!-bound vars in induction statement automatically
nipkow
parents:
13425
diff
changeset
|
91 |
fun cases_tac (ctxt, (is_open, (insts, opt_rule))) facts = |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
92 |
let |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
93 |
val sg = ProofContext.sign_of ctxt; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
94 |
val cert = Thm.cterm_of sg; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
95 |
|
11735 | 96 |
fun inst_rule r = |
97 |
if null insts then RuleCases.add r |
|
98 |
else (align_left "Rule has fewer premises than arguments given" (Thm.prems_of r) insts |
|
15570 | 99 |
|> (List.concat o map (prep_inst align_left cert I)) |
11735 | 100 |
|> Drule.cterm_instantiate) r |> rpair (RuleCases.get r); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
101 |
|
11735 | 102 |
val ruleq = |
12852 | 103 |
(case opt_rule of |
15531 | 104 |
NONE => |
12852 | 105 |
let val rules = find_casesS ctxt facts @ find_casesT ctxt insts @ [Data.cases_default] in |
12053 | 106 |
Method.trace ctxt rules; |
11735 | 107 |
Seq.flat (Seq.map (Seq.try inst_rule) (Seq.of_list rules)) |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
108 |
end |
15531 | 109 |
| SOME r => Seq.single (inst_rule r)); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
110 |
|
15570 | 111 |
fun prep_rule (th, (cases, n)) = Seq.map (apsnd (rpair (Library.drop (n, facts))) o rpair cases) |
112 |
(Method.multi_resolves (Library.take (n, facts)) [th]); |
|
15531 | 113 |
in resolveq_cases_tac (RuleCases.make is_open NONE) (Seq.flat (Seq.map prep_rule ruleq)) end; |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
114 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
115 |
in |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
116 |
|
12852 | 117 |
val cases_meth = Method.METHOD_CASES o ((Seq.DETERM o HEADGOAL) oo cases_tac); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
118 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
119 |
end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
120 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
121 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
122 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
123 |
(** induct method **) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
124 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
125 |
(* |
11735 | 126 |
rule selection scheme: |
127 |
<x:A> induct ... - set induction |
|
128 |
induct x - type induction |
|
129 |
... induct ... R - explicit rule |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
130 |
*) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
131 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
132 |
local |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
133 |
|
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
134 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
135 |
(* atomize and rulify *) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
136 |
|
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
137 |
fun atomize_term sg = |
13197
0567f4fd1415
Changed interface of MetaSimplifier.rewrite_term.
berghofe
parents:
13105
diff
changeset
|
138 |
ObjectLogic.drop_judgment sg o MetaSimplifier.rewrite_term sg Data.atomize []; |
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
139 |
|
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
140 |
fun rulified_term thm = |
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
141 |
let val sg = Thm.sign_of_thm thm in |
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
142 |
Thm.prop_of thm |
13197
0567f4fd1415
Changed interface of MetaSimplifier.rewrite_term.
berghofe
parents:
13105
diff
changeset
|
143 |
|> MetaSimplifier.rewrite_term sg Data.rulify1 [] |
0567f4fd1415
Changed interface of MetaSimplifier.rewrite_term.
berghofe
parents:
13105
diff
changeset
|
144 |
|> MetaSimplifier.rewrite_term sg Data.rulify2 [] |
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
145 |
|> pair sg |
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
146 |
end; |
11756 | 147 |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
148 |
val atomize_tac = Tactic.rewrite_goal_tac Data.atomize; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
149 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
150 |
val rulify_tac = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
151 |
Tactic.rewrite_goal_tac Data.rulify1 THEN' |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
152 |
Tactic.rewrite_goal_tac Data.rulify2 THEN' |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
153 |
Tactic.norm_hhf_tac; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
154 |
|
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
155 |
val localize = Tactic.norm_hhf_rule o Tactic.simplify false Data.localize; |
12162 | 156 |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
157 |
|
11996
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
158 |
(* imp_intr --- limited to atomic prems *) |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
159 |
|
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
160 |
fun imp_intr i raw_th = |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
161 |
let |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
162 |
val th = Thm.permute_prems (i - 1) 1 raw_th; |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
163 |
val cprems = Drule.cprems_of th; |
15570 | 164 |
val As = Library.take (length cprems - 1, cprems); |
11996
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
165 |
val C = Thm.cterm_of (Thm.sign_of_thm th) (Var (("C", #maxidx (Thm.rep_thm th) + 1), propT)); |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
166 |
val dummy_st = Drule.mk_triv_goal (Drule.list_implies (As, C)); |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
167 |
in th COMP Thm.lift_rule (dummy_st, 1) Data.local_impI end; |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
168 |
|
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
169 |
|
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
170 |
(* join multi-rules *) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
171 |
|
11735 | 172 |
val eq_prems = curry (Term.aconvs o pairself Thm.prems_of); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
173 |
|
11735 | 174 |
fun join_rules [] = [] |
175 |
| join_rules [th] = [th] |
|
176 |
| join_rules (rules as r :: rs) = |
|
177 |
if not (forall (eq_prems r) rs) then [] |
|
178 |
else |
|
179 |
let |
|
180 |
val th :: ths = map Drule.freeze_all rules; |
|
181 |
val cprems = Drule.cprems_of th; |
|
182 |
val asms = map Thm.assume cprems; |
|
183 |
in |
|
184 |
[foldr1 (fn (x, x') => [x, x'] MRS Data.conjI) |
|
185 |
(map (fn x => Drule.implies_elim_list x asms) (th :: ths)) |
|
186 |
|> Drule.implies_intr_list cprems |
|
12305 | 187 |
|> Drule.standard' |
13425
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13197
diff
changeset
|
188 |
|> RuleCases.save r] |
11735 | 189 |
end; |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
190 |
|
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
191 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
192 |
(* divinate rule instantiation (cannot handle pending goal parameters) *) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
193 |
|
15794
5de27a5fc5ed
Adapted to new interface of instantiation and unification / matching functions.
berghofe
parents:
15708
diff
changeset
|
194 |
fun dest_env sign (env as Envir.Envir {iTs, ...}) = |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
195 |
let |
15794
5de27a5fc5ed
Adapted to new interface of instantiation and unification / matching functions.
berghofe
parents:
15708
diff
changeset
|
196 |
val pairs = Envir.alist_of env; |
5de27a5fc5ed
Adapted to new interface of instantiation and unification / matching functions.
berghofe
parents:
15708
diff
changeset
|
197 |
val ts = map (Thm.cterm_of sign o Envir.norm_term env o #2 o #2) pairs; |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
198 |
val xs = map2 (Thm.cterm_of sign o Var) (map #1 pairs, map (#T o Thm.rep_cterm) ts); |
15794
5de27a5fc5ed
Adapted to new interface of instantiation and unification / matching functions.
berghofe
parents:
15708
diff
changeset
|
199 |
val cert = Thm.ctyp_of sign; |
5de27a5fc5ed
Adapted to new interface of instantiation and unification / matching functions.
berghofe
parents:
15708
diff
changeset
|
200 |
in (map (fn (ixn, (S, T)) => (cert (TVar (ixn, S)), cert T)) (Vartab.dest iTs), xs ~~ ts) end; |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
201 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
202 |
fun divinate_inst rule i st = |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
203 |
let |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
204 |
val {sign, maxidx, ...} = Thm.rep_thm st; |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
205 |
val goal = List.nth (Thm.prems_of st, i - 1); (*exception Subscript*) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
206 |
val params = rev (rename_wrt_term goal (Logic.strip_params goal)); (*as they are printed :-*) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
207 |
in |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
208 |
if not (null params) then |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
209 |
(warning ("Cannot determine rule instantiation due to pending parameter(s): " ^ |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
210 |
commas (map (Sign.string_of_term sign o Syntax.mark_boundT) params)); |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
211 |
Seq.single rule) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
212 |
else |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
213 |
let |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
214 |
val rule' = Thm.incr_indexes (maxidx + 1) rule; |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
215 |
val concl = Logic.strip_assums_concl goal; |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
216 |
in |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
217 |
Unify.smash_unifiers (sign, Envir.empty (#maxidx (Thm.rep_thm rule')), |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
218 |
[(Thm.concl_of rule', concl)]) |
12162 | 219 |
|> Seq.map (fn env => Drule.instantiate (dest_env sign env) rule') |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
220 |
end |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
221 |
end handle Subscript => Seq.empty; |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
222 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
223 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
224 |
(* compose tactics with cases *) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
225 |
|
11996
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
226 |
fun internalize k th = if k > 0 then internalize (k - 1) (imp_intr k th) else th; |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
227 |
|
13597
a8230e035e96
fixes !!-bound vars in induction statement automatically
nipkow
parents:
13425
diff
changeset
|
228 |
fun resolveq_cases_tac' make is_open ruleq i st = |
11996
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
229 |
ruleq |> Seq.map (fn (rule, (cases, k, more_facts)) => st |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
230 |
|> (Method.insert_tac more_facts THEN' atomize_tac) i |
b409a8cbe1fb
induct: internalize ``missing'' consumes-facts from goal state
wenzelm
parents:
11984
diff
changeset
|
231 |
|> Seq.map (fn st' => divinate_inst (internalize k rule) i st' |> Seq.map (fn rule' => |
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
232 |
st' |> Tactic.rtac rule' i |
15531 | 233 |
|> Seq.map (rpair (make is_open (SOME (Thm.prop_of rule')) (rulified_term rule') cases))) |
12799
5472afdd3bd3
MetaSimplifier.rewrite_term replaces slow Tactic.rewrite_cterm;
wenzelm
parents:
12305
diff
changeset
|
234 |
|> Seq.flat) |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
235 |
|> Seq.flat) |
14404
4952c5a92e04
Transitive_Closure: added consumes and case_names attributes
nipkow
parents:
13597
diff
changeset
|
236 |
|> Seq.flat; |
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
237 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
238 |
infix 1 THEN_ALL_NEW_CASES; |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
239 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
240 |
fun (tac1 THEN_ALL_NEW_CASES tac2) i st = |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
241 |
st |> Seq.THEN (tac1 i, (fn (st', cases) => |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
242 |
Seq.map (rpair cases) (Seq.INTERVAL tac2 i (i + nprems_of st' - nprems_of st) st'))); |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
243 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
244 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
245 |
(* find rules *) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
246 |
|
15235
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
247 |
(* rename all outermost !!-bound vars of type T in all premises of thm to x, |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
248 |
possibly indexed to avoid clashes *) |
15531 | 249 |
fun rename [[SOME(Free(x,Type(T,_)))]] thm = |
15235
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
250 |
let |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
251 |
fun index i [] = [] |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
252 |
| index i (y::ys) = if x=y then x^string_of_int i :: index (i+1) ys |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
253 |
else y :: index i ys; |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
254 |
fun rename_params [] = [] |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
255 |
| rename_params ((y,Type(U,_))::ys) = |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
256 |
(if U=T then x else y)::rename_params ys |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
257 |
| rename_params ((y,_)::ys) = y::rename_params ys; |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
258 |
fun rename_asm (A:term):term = |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
259 |
let val xs = rename_params (Logic.strip_params A) |
15570 | 260 |
val xs' = case List.filter (equal x) xs of |
15235
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
261 |
[] => xs | [_] => xs | _ => index 1 xs |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
262 |
in Logic.list_rename_params (xs',A) end; |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
263 |
fun rename_prop (p:term) = |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
264 |
let val (As,C) = Logic.strip_horn p |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
265 |
in Logic.list_implies(map rename_asm As, C) end; |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
266 |
val cp' = cterm_fun rename_prop (cprop_of thm); |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
267 |
val thm' = equal_elim (reflexive cp') thm |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
268 |
in Thm.put_name_tags (Thm.get_name_tags thm) thm' end |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
269 |
| rename _ thm = thm; |
614a804d7116
Induction now preserves the name of the induction variable.
nipkow
parents:
14981
diff
changeset
|
270 |
|
11735 | 271 |
fun find_inductT ctxt insts = |
15574
b1d1b5bfc464
Removed practically all references to Library.foldr.
skalberg
parents:
15570
diff
changeset
|
272 |
foldr multiply [[]] (insts |> List.mapPartial (fn [] => NONE | ts => List.last ts) |
b1d1b5bfc464
Removed practically all references to Library.foldr.
skalberg
parents:
15570
diff
changeset
|
273 |
|> map (InductAttrib.find_inductT ctxt o fastype_of)) |
15570 | 274 |
|> map join_rules |> List.concat |> map (rename insts); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
275 |
|
11735 | 276 |
fun find_inductS ctxt (fact :: _) = InductAttrib.find_inductS ctxt fact |
277 |
| find_inductS _ _ = []; |
|
278 |
||
11790
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
279 |
|
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
280 |
(* main tactic *) |
42393a11642d
simplified resolveq_cases_tac for cases, separate version for induct;
wenzelm
parents:
11781
diff
changeset
|
281 |
|
13597
a8230e035e96
fixes !!-bound vars in induction statement automatically
nipkow
parents:
13425
diff
changeset
|
282 |
fun induct_tac (ctxt, (is_open, (insts, opt_rule))) facts = |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
283 |
let |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
284 |
val sg = ProofContext.sign_of ctxt; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
285 |
val cert = Thm.cterm_of sg; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
286 |
|
13105
3d1e7a199bdc
use eq_thm_prop instead of slightly inadequate eq_thm;
wenzelm
parents:
12852
diff
changeset
|
287 |
fun rule_versions r = Seq.cons (r, Seq.filter (not o curry Thm.eq_thm r) |
15531 | 288 |
(Seq.make (fn () => SOME (localize r, Seq.empty)))) |
12168
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
289 |
|> Seq.map (rpair (RuleCases.get r)); |
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
290 |
|
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
291 |
val inst_rule = apfst (fn r => |
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
292 |
if null insts then r |
11735 | 293 |
else (align_right "Rule has fewer conclusions than arguments given" |
294 |
(Data.dest_concls (Thm.concl_of r)) insts |
|
15570 | 295 |
|> (List.concat o map (prep_inst align_right cert (atomize_term sg))) |
12168
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
296 |
|> Drule.cterm_instantiate) r); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
297 |
|
11735 | 298 |
val ruleq = |
299 |
(case opt_rule of |
|
15531 | 300 |
NONE => |
11735 | 301 |
let val rules = find_inductS ctxt facts @ find_inductT ctxt insts in |
12168
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
302 |
conditional (null rules) (fn () => error "Unable to figure out induct rule"); |
12053 | 303 |
Method.trace ctxt rules; |
12168
dc93c2e82205
induct: rule_versions produces localized variants;
wenzelm
parents:
12162
diff
changeset
|
304 |
rules |> Seq.THEN (Seq.of_list, Seq.THEN (rule_versions, Seq.try inst_rule)) |
11735 | 305 |
end |
15531 | 306 |
| SOME r => r |> Seq.THEN (rule_versions, Seq.single o inst_rule)); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
307 |
|
11735 | 308 |
fun prep_rule (th, (cases, n)) = |
15570 | 309 |
Seq.map (rpair (cases, n - length facts, Library.drop (n, facts))) |
310 |
(Method.multi_resolves (Library.take (n, facts)) [th]); |
|
13597
a8230e035e96
fixes !!-bound vars in induction statement automatically
nipkow
parents:
13425
diff
changeset
|
311 |
val tac = resolveq_cases_tac' RuleCases.make is_open (Seq.flat (Seq.map prep_rule ruleq)); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
312 |
in tac THEN_ALL_NEW_CASES rulify_tac end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
313 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
314 |
in |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
315 |
|
12852 | 316 |
val induct_meth = Method.RAW_METHOD_CASES o ((Seq.DETERM o HEADGOAL) oo induct_tac); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
317 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
318 |
end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
319 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
320 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
321 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
322 |
(** concrete syntax **) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
323 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
324 |
val openN = "open"; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
325 |
val ruleN = "rule"; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
326 |
val ofN = "of"; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
327 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
328 |
local |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
329 |
|
15703 | 330 |
fun named_rule k arg get = |
331 |
Scan.lift (Args.$$$ k -- Args.colon) |-- arg :-- (fn name => Scan.peek (fn ctxt => |
|
332 |
(case get ctxt name of SOME x => Scan.succeed x |
|
333 |
| NONE => error ("No rule for " ^ k ^ " " ^ quote name)))) >> #2; |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
334 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
335 |
fun rule get_type get_set = |
15703 | 336 |
named_rule InductAttrib.typeN Args.local_tyname get_type || |
337 |
named_rule InductAttrib.setN Args.local_const get_set || |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
338 |
Scan.lift (Args.$$$ ruleN -- Args.colon) |-- Attrib.local_thm; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
339 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
340 |
val cases_rule = rule InductAttrib.lookup_casesT InductAttrib.lookup_casesS; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
341 |
val induct_rule = rule InductAttrib.lookup_inductT InductAttrib.lookup_inductS; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
342 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
343 |
val kind_inst = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
344 |
(Args.$$$ InductAttrib.typeN || Args.$$$ InductAttrib.setN || Args.$$$ ruleN || Args.$$$ ofN) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
345 |
-- Args.colon; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
346 |
val term = Scan.unless (Scan.lift kind_inst) Args.local_term; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
347 |
val term_dummy = Scan.unless (Scan.lift kind_inst) |
15531 | 348 |
(Scan.lift (Args.$$$ "_") >> K NONE || Args.local_term >> SOME); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
349 |
|
13425
119ae829ad9b
support for split assumptions in cases (hyps vs. prems);
wenzelm
parents:
13197
diff
changeset
|
350 |
val instss = Args.and_list (Scan.repeat term_dummy); |
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
351 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
352 |
in |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
353 |
|
11735 | 354 |
val cases_args = Method.syntax (Args.mode openN -- (instss -- Scan.option cases_rule)); |
355 |
val induct_args = Method.syntax (Args.mode openN -- (instss -- Scan.option induct_rule)); |
|
11670
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
356 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
357 |
end; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
358 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
359 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
360 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
361 |
(** theory setup **) |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
362 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
363 |
val setup = |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
364 |
[Method.add_methods |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
365 |
[(InductAttrib.casesN, cases_meth oo cases_args, "case analysis on types or sets"), |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
366 |
(InductAttrib.inductN, induct_meth oo induct_args, "induction on types or sets")]]; |
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
367 |
|
59f79df42d1f
proof by cases and induction on types and sets (used to be specific for HOL);
wenzelm
parents:
diff
changeset
|
368 |
end; |
15708 | 369 |