author | Christian Urban <urbanc@in.tum.de> |
Tue, 28 Dec 2010 00:20:50 +0000 | |
changeset 2629 | ffb5a181844b |
parent 2628 | 16ffbc8442ca |
child 2630 | 8268b277d240 |
permissions | -rw-r--r-- |
2573 | 1 |
theory Foo2 |
2 |
imports "../Nominal2" |
|
3 |
begin |
|
4 |
||
5 |
(* |
|
6 |
Contrived example that has more than one |
|
7 |
binding clause |
|
8 |
*) |
|
9 |
||
10 |
atom_decl name |
|
11 |
||
12 |
nominal_datatype foo: trm = |
|
13 |
Var "name" |
|
14 |
| App "trm" "trm" |
|
15 |
| Lam x::"name" t::"trm" bind x in t |
|
16 |
| Let1 a1::"assg" t1::"trm" a2::"assg" t2::"trm" bind "bn a1" in t1, bind "bn a2" in t2 |
|
17 |
| Let2 x::"name" y::"name" t1::"trm" t2::"trm" bind x y in t1, bind y in t2 |
|
18 |
and assg = |
|
19 |
As_Nil |
|
20 |
| As "name" x::"name" t::"trm" "assg" |
|
21 |
binder |
|
22 |
bn::"assg \<Rightarrow> atom list" |
|
23 |
where |
|
2611
3d101f2f817c
simple cases for strong inducts done; infrastructure for the difficult ones is there
Christian Urban <urbanc@in.tum.de>
parents:
2609
diff
changeset
|
24 |
"bn (As x y t a) = [atom x] @ bn a" |
2573 | 25 |
| "bn (As_Nil) = []" |
26 |
||
2628
16ffbc8442ca
generated goals for strong induction theorems.
Christian Urban <urbanc@in.tum.de>
parents:
2626
diff
changeset
|
27 |
|
16ffbc8442ca
generated goals for strong induction theorems.
Christian Urban <urbanc@in.tum.de>
parents:
2626
diff
changeset
|
28 |
|
2598
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2594
diff
changeset
|
29 |
thm foo.bn_defs |
b136721eedb2
automated permute_bn theorems
Christian Urban <urbanc@in.tum.de>
parents:
2594
diff
changeset
|
30 |
thm foo.permute_bn |
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2592
diff
changeset
|
31 |
thm foo.perm_bn_alpha |
2573 | 32 |
thm foo.perm_bn_simps |
2593
25dcb2b1329e
ordered raw_bn_info to agree with the order of the raw_bn_functions; started alpha_bn proof
Christian Urban <urbanc@in.tum.de>
parents:
2592
diff
changeset
|
33 |
thm foo.bn_finite |
2573 | 34 |
|
35 |
thm foo.distinct |
|
36 |
thm foo.induct |
|
37 |
thm foo.inducts |
|
38 |
thm foo.exhaust |
|
2626
d1bdc281be2b
moved all strong_exhaust code to nominal_dt_quot; tuned examples
Christian Urban <urbanc@in.tum.de>
parents:
2616
diff
changeset
|
39 |
thm foo.strong_exhaust |
2573 | 40 |
thm foo.fv_defs |
41 |
thm foo.bn_defs |
|
42 |
thm foo.perm_simps |
|
2607
7430e07a5d61
moved setify and listify functions into the library; introduced versions that have a type argument
Christian Urban <urbanc@in.tum.de>
parents:
2603
diff
changeset
|
43 |
thm foo.eq_iff |
2573 | 44 |
thm foo.fv_bn_eqvt |
45 |
thm foo.size_eqvt |
|
46 |
thm foo.supports |
|
47 |
thm foo.fsupp |
|
48 |
thm foo.supp |
|
49 |
thm foo.fresh |
|
50 |
||
2629
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
51 |
ML {* |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
52 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
53 |
open Function_Lib |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
54 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
55 |
type rec_call_info = int * (string * typ) list * term list * term list |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
56 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
57 |
datatype scheme_case = SchemeCase of |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
58 |
{bidx : int, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
59 |
qs: (string * typ) list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
60 |
oqnames: string list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
61 |
gs: term list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
62 |
lhs: term list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
63 |
rs: rec_call_info list} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
64 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
65 |
datatype scheme_branch = SchemeBranch of |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
66 |
{P : term, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
67 |
xs: (string * typ) list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
68 |
ws: (string * typ) list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
69 |
Cs: term list} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
70 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
71 |
datatype ind_scheme = IndScheme of |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
72 |
{T: typ, (* sum of products *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
73 |
branches: scheme_branch list, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
74 |
cases: scheme_case list} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
75 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
76 |
val ind_atomize = Raw_Simplifier.rewrite true @{thms induct_atomize} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
77 |
val ind_rulify = Raw_Simplifier.rewrite true @{thms induct_rulify} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
78 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
79 |
fun meta thm = thm RS eq_reflection |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
80 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
81 |
val sum_prod_conv = Raw_Simplifier.rewrite true |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
82 |
(map meta (@{thm split_conv} :: @{thms sum.cases})) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
83 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
84 |
fun term_conv thy cv t = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
85 |
cv (cterm_of thy t) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
86 |
|> prop_of |> Logic.dest_equals |> snd |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
87 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
88 |
fun mk_relT T = HOLogic.mk_setT (HOLogic.mk_prodT (T, T)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
89 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
90 |
fun dest_hhf ctxt t = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
91 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
92 |
val ((vars, imp), ctxt') = Function_Lib.focus_term t ctxt |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
93 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
94 |
(ctxt', vars, Logic.strip_imp_prems imp, Logic.strip_imp_concl imp) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
95 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
96 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
97 |
fun mk_scheme' ctxt cases concl = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
98 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
99 |
fun mk_branch concl = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
100 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
101 |
val _ = tracing ("concl:\n" ^ Syntax.string_of_term ctxt concl) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
102 |
val (_, ws, Cs, _ $ Pxs) = dest_hhf ctxt concl |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
103 |
val (P, xs) = strip_comb Pxs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
104 |
val _ = tracing ("xs: " ^ commas (map @{make_string} xs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
105 |
val _ = map dest_Free xs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
106 |
val _ = tracing ("done") |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
107 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
108 |
SchemeBranch { P=P, xs=map dest_Free xs, ws=ws, Cs=Cs } |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
109 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
110 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
111 |
val (branches, cases') = (* correction *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
112 |
case Logic.dest_conjunctions concl of |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
113 |
[conc] => |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
114 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
115 |
val _ $ Pxs = Logic.strip_assums_concl conc |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
116 |
val (P, _) = strip_comb Pxs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
117 |
val (cases', conds) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
118 |
take_prefix (Term.exists_subterm (curry op aconv P)) cases |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
119 |
val concl' = fold_rev (curry Logic.mk_implies) conds conc |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
120 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
121 |
([mk_branch concl'], cases') |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
122 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
123 |
| concls => (map mk_branch concls, cases) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
124 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
125 |
fun mk_case premise = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
126 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
127 |
val (ctxt', qs, prems, _ $ Plhs) = dest_hhf ctxt premise |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
128 |
val (P, lhs) = strip_comb Plhs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
129 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
130 |
fun bidx Q = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
131 |
find_index (fn SchemeBranch {P=P',...} => Q aconv P') branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
132 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
133 |
fun mk_rcinfo pr = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
134 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
135 |
val (_, Gvs, Gas, _ $ Phyp) = dest_hhf ctxt' pr |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
136 |
val (P', rcs) = strip_comb Phyp |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
137 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
138 |
(bidx P', Gvs, Gas, rcs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
139 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
140 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
141 |
fun is_pred v = exists (fn SchemeBranch {P,...} => v aconv P) branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
142 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
143 |
val (gs, rcprs) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
144 |
take_prefix (not o Term.exists_subterm is_pred) prems |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
145 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
146 |
SchemeCase {bidx=bidx P, qs=qs, oqnames=map fst qs(*FIXME*), |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
147 |
gs=gs, lhs=lhs, rs=map mk_rcinfo rcprs} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
148 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
149 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
150 |
fun PT_of (SchemeBranch { xs, ...}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
151 |
foldr1 HOLogic.mk_prodT (map snd xs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
152 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
153 |
val ST = Balanced_Tree.make (uncurry SumTree.mk_sumT) (map PT_of branches) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
154 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
155 |
IndScheme {T=ST, cases=map mk_case cases', branches=branches } |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
156 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
157 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
158 |
fun mk_completeness ctxt (IndScheme {cases, branches, ...}) bidx = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
159 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
160 |
val SchemeBranch { xs, ws, Cs, ... } = nth branches bidx |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
161 |
val relevant_cases = filter (fn SchemeCase {bidx=bidx', ...} => bidx' = bidx) cases |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
162 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
163 |
val allqnames = fold (fn SchemeCase {qs, ...} => fold (insert (op =) o Free) qs) relevant_cases [] |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
164 |
val (Pbool :: xs') = map Free (Variable.variant_frees ctxt allqnames (("P", HOLogic.boolT) :: xs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
165 |
val Cs' = map (Pattern.rewrite_term (ProofContext.theory_of ctxt) (filter_out (op aconv) (map Free xs ~~ xs')) []) Cs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
166 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
167 |
fun mk_case (SchemeCase {qs, oqnames, gs, lhs, ...}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
168 |
HOLogic.mk_Trueprop Pbool |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
169 |
|> fold_rev (fn x_l => curry Logic.mk_implies (HOLogic.mk_Trueprop(HOLogic.mk_eq x_l))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
170 |
(xs' ~~ lhs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
171 |
|> fold_rev (curry Logic.mk_implies) gs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
172 |
|> fold_rev mk_forall_rename (oqnames ~~ map Free qs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
173 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
174 |
HOLogic.mk_Trueprop Pbool |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
175 |
|> fold_rev (curry Logic.mk_implies o mk_case) relevant_cases |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
176 |
|> fold_rev (curry Logic.mk_implies) Cs' |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
177 |
|> fold_rev (Logic.all o Free) ws |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
178 |
|> fold_rev mk_forall_rename (map fst xs ~~ xs') |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
179 |
|> mk_forall_rename ("P", Pbool) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
180 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
181 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
182 |
fun mk_wf R (IndScheme {T, ...}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
183 |
HOLogic.Trueprop $ (Const (@{const_name wf}, mk_relT T --> HOLogic.boolT) $ R) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
184 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
185 |
fun mk_ineqs R (IndScheme {T, cases, branches}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
186 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
187 |
fun inject i ts = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
188 |
SumTree.mk_inj T (length branches) (i + 1) (foldr1 HOLogic.mk_prod ts) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
189 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
190 |
val thesis = Free ("thesis", HOLogic.boolT) (* FIXME *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
191 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
192 |
fun mk_pres bdx args = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
193 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
194 |
val SchemeBranch { xs, ws, Cs, ... } = nth branches bdx |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
195 |
fun replace (x, v) t = betapply (lambda (Free x) t, v) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
196 |
val Cs' = map (fold replace (xs ~~ args)) Cs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
197 |
val cse = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
198 |
HOLogic.mk_Trueprop thesis |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
199 |
|> fold_rev (curry Logic.mk_implies) Cs' |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
200 |
|> fold_rev (Logic.all o Free) ws |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
201 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
202 |
Logic.mk_implies (cse, HOLogic.mk_Trueprop thesis) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
203 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
204 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
205 |
fun f (SchemeCase {bidx, qs, oqnames, gs, lhs, rs, ...}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
206 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
207 |
fun g (bidx', Gvs, Gas, rcarg) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
208 |
let val export = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
209 |
fold_rev (curry Logic.mk_implies) Gas |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
210 |
#> fold_rev (curry Logic.mk_implies) gs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
211 |
#> fold_rev (Logic.all o Free) Gvs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
212 |
#> fold_rev mk_forall_rename (oqnames ~~ map Free qs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
213 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
214 |
(HOLogic.mk_mem (HOLogic.mk_prod (inject bidx' rcarg, inject bidx lhs), R) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
215 |
|> HOLogic.mk_Trueprop |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
216 |
|> export, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
217 |
mk_pres bidx' rcarg |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
218 |
|> export |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
219 |
|> Logic.all thesis) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
220 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
221 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
222 |
map g rs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
223 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
224 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
225 |
map f cases |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
226 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
227 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
228 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
229 |
fun mk_ind_goal thy branches = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
230 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
231 |
fun brnch (SchemeBranch { P, xs, ws, Cs, ... }) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
232 |
HOLogic.mk_Trueprop (list_comb (P, map Free xs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
233 |
|> fold_rev (curry Logic.mk_implies) Cs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
234 |
|> fold_rev (Logic.all o Free) ws |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
235 |
|> term_conv thy ind_atomize |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
236 |
|> Object_Logic.drop_judgment thy |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
237 |
|> HOLogic.tupled_lambda (foldr1 HOLogic.mk_prod (map Free xs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
238 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
239 |
SumTree.mk_sumcases HOLogic.boolT (map brnch branches) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
240 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
241 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
242 |
fun mk_induct_rule ctxt R x complete_thms wf_thm ineqss |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
243 |
(IndScheme {T, cases=scases, branches}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
244 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
245 |
val n = length branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
246 |
val scases_idx = map_index I scases |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
247 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
248 |
fun inject i ts = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
249 |
SumTree.mk_inj T n (i + 1) (foldr1 HOLogic.mk_prod ts) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
250 |
val P_of = nth (map (fn (SchemeBranch { P, ... }) => P) branches) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
251 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
252 |
val thy = ProofContext.theory_of ctxt |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
253 |
val cert = cterm_of thy |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
254 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
255 |
val P_comp = mk_ind_goal thy branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
256 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
257 |
(* Inductive Hypothesis: !!z. (z,x):R ==> P z *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
258 |
val ihyp = Term.all T $ Abs ("z", T, |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
259 |
Logic.mk_implies |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
260 |
(HOLogic.mk_Trueprop ( |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
261 |
Const (@{const_name Set.member}, HOLogic.mk_prodT (T, T) --> mk_relT T --> HOLogic.boolT) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
262 |
$ (HOLogic.pair_const T T $ Bound 0 $ x) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
263 |
$ R), |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
264 |
HOLogic.mk_Trueprop (P_comp $ Bound 0))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
265 |
|> cert |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
266 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
267 |
val aihyp = Thm.assume ihyp |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
268 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
269 |
(* Rule for case splitting along the sum types *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
270 |
val xss = map (fn (SchemeBranch { xs, ... }) => map Free xs) branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
271 |
val pats = map_index (uncurry inject) xss |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
272 |
val sum_split_rule = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
273 |
Pat_Completeness.prove_completeness thy [x] (P_comp $ x) xss (map single pats) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
274 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
275 |
fun prove_branch (bidx, (SchemeBranch { P, xs, ws, Cs, ... }, (complete_thm, pat))) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
276 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
277 |
val fxs = map Free xs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
278 |
val branch_hyp = Thm.assume (cert (HOLogic.mk_Trueprop (HOLogic.mk_eq (x, pat)))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
279 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
280 |
val C_hyps = map (cert #> Thm.assume) Cs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
281 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
282 |
val (relevant_cases, ineqss') = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
283 |
(scases_idx ~~ ineqss) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
284 |
|> filter (fn ((_, SchemeCase {bidx=bidx', ...}), _) => bidx' = bidx) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
285 |
|> split_list |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
286 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
287 |
fun prove_case (cidx, SchemeCase {qs, gs, lhs, rs, ...}) ineq_press = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
288 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
289 |
val case_hyps = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
290 |
map (Thm.assume o cert o HOLogic.mk_Trueprop o HOLogic.mk_eq) (fxs ~~ lhs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
291 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
292 |
val cqs = map (cert o Free) qs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
293 |
val ags = map (Thm.assume o cert) gs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
294 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
295 |
val replace_x_ss = HOL_basic_ss addsimps (branch_hyp :: case_hyps) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
296 |
val sih = full_simplify replace_x_ss aihyp |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
297 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
298 |
fun mk_Prec (idx, Gvs, Gas, rcargs) (ineq, pres) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
299 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
300 |
val cGas = map (Thm.assume o cert) Gas |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
301 |
val cGvs = map (cert o Free) Gvs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
302 |
val import = fold Thm.forall_elim (cqs @ cGvs) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
303 |
#> fold Thm.elim_implies (ags @ cGas) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
304 |
val ipres = pres |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
305 |
|> Thm.forall_elim (cert (list_comb (P_of idx, rcargs))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
306 |
|> import |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
307 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
308 |
sih |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
309 |
|> Thm.forall_elim (cert (inject idx rcargs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
310 |
|> Thm.elim_implies (import ineq) (* Psum rcargs *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
311 |
|> Conv.fconv_rule sum_prod_conv |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
312 |
|> Conv.fconv_rule ind_rulify |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
313 |
|> (fn th => th COMP ipres) (* P rs *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
314 |
|> fold_rev (Thm.implies_intr o cprop_of) cGas |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
315 |
|> fold_rev Thm.forall_intr cGvs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
316 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
317 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
318 |
val P_recs = map2 mk_Prec rs ineq_press (* [P rec1, P rec2, ... ] *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
319 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
320 |
val step = HOLogic.mk_Trueprop (list_comb (P, lhs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
321 |
|> fold_rev (curry Logic.mk_implies o prop_of) P_recs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
322 |
|> fold_rev (curry Logic.mk_implies) gs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
323 |
|> fold_rev (Logic.all o Free) qs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
324 |
|> cert |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
325 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
326 |
val Plhs_to_Pxs_conv = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
327 |
foldl1 (uncurry Conv.combination_conv) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
328 |
(Conv.all_conv :: map (fn ch => K (Thm.symmetric (ch RS eq_reflection))) case_hyps) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
329 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
330 |
val res = Thm.assume step |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
331 |
|> fold Thm.forall_elim cqs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
332 |
|> fold Thm.elim_implies ags |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
333 |
|> fold Thm.elim_implies P_recs (* P lhs *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
334 |
|> Conv.fconv_rule (Conv.arg_conv Plhs_to_Pxs_conv) (* P xs *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
335 |
|> fold_rev (Thm.implies_intr o cprop_of) (ags @ case_hyps) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
336 |
|> fold_rev Thm.forall_intr cqs (* !!qs. Gas ==> xs = lhss ==> P xs *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
337 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
338 |
(res, (cidx, step)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
339 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
340 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
341 |
val (cases, steps) = split_list (map2 prove_case relevant_cases ineqss') |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
342 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
343 |
val bstep = complete_thm |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
344 |
|> Thm.forall_elim (cert (list_comb (P, fxs))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
345 |
|> fold (Thm.forall_elim o cert) (fxs @ map Free ws) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
346 |
|> fold Thm.elim_implies C_hyps |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
347 |
|> fold Thm.elim_implies cases (* P xs *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
348 |
|> fold_rev (Thm.implies_intr o cprop_of) C_hyps |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
349 |
|> fold_rev (Thm.forall_intr o cert o Free) ws |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
350 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
351 |
val Pxs = cert (HOLogic.mk_Trueprop (P_comp $ x)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
352 |
|> Goal.init |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
353 |
|> (Simplifier.rewrite_goals_tac (map meta (branch_hyp :: @{thm split_conv} :: @{thms sum.cases})) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
354 |
THEN CONVERSION ind_rulify 1) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
355 |
|> Seq.hd |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
356 |
|> Thm.elim_implies (Conv.fconv_rule Drule.beta_eta_conversion bstep) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
357 |
|> Goal.finish ctxt |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
358 |
|> Thm.implies_intr (cprop_of branch_hyp) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
359 |
|> fold_rev (Thm.forall_intr o cert) fxs |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
360 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
361 |
(Pxs, steps) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
362 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
363 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
364 |
val (branches, steps) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
365 |
map_index prove_branch (branches ~~ (complete_thms ~~ pats)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
366 |
|> split_list |> apsnd flat |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
367 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
368 |
val istep = sum_split_rule |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
369 |
|> fold (fn b => fn th => Drule.compose_single (b, 1, th)) branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
370 |
|> Thm.implies_intr ihyp |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
371 |
|> Thm.forall_intr (cert x) (* "!!x. (!!y<x. P y) ==> P x" *) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
372 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
373 |
val induct_rule = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
374 |
@{thm "wf_induct_rule"} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
375 |
|> (curry op COMP) wf_thm |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
376 |
|> (curry op COMP) istep |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
377 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
378 |
val steps_sorted = map snd (sort (int_ord o pairself fst) steps) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
379 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
380 |
(steps_sorted, induct_rule) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
381 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
382 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
383 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
384 |
fun mk_ind_tac comp_tac pres_tac term_tac ctxt facts = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
385 |
(ALLGOALS (Method.insert_tac facts)) THEN HEADGOAL (SUBGOAL (fn (t, i) => |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
386 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
387 |
val (ctxt', _, cases, concl) = dest_hhf ctxt t |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
388 |
val scheme as IndScheme {T=ST, branches, ...} = mk_scheme' ctxt' cases concl |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
389 |
val ([Rn,xn], ctxt'') = Variable.variant_fixes ["R","x"] ctxt' |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
390 |
val R = Free (Rn, mk_relT ST) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
391 |
val x = Free (xn, ST) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
392 |
val cert = cterm_of (ProofContext.theory_of ctxt) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
393 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
394 |
val ineqss = mk_ineqs R scheme |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
395 |
|> map (map (pairself (Thm.assume o cert))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
396 |
val complete = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
397 |
map_range (mk_completeness ctxt scheme #> cert #> Thm.assume) (length branches) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
398 |
val wf_thm = mk_wf R scheme |> cert |> Thm.assume |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
399 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
400 |
val (descent, pres) = split_list (flat ineqss) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
401 |
val newgoals = complete @ pres @ wf_thm :: descent |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
402 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
403 |
val (steps, indthm) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
404 |
mk_induct_rule ctxt'' R x complete wf_thm ineqss scheme |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
405 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
406 |
fun project (i, SchemeBranch {xs, ...}) = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
407 |
let |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
408 |
val inst = (foldr1 HOLogic.mk_prod (map Free xs)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
409 |
|> SumTree.mk_inj ST (length branches) (i + 1) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
410 |
|> cert |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
411 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
412 |
indthm |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
413 |
|> Drule.instantiate' [] [SOME inst] |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
414 |
|> simplify SumTree.sumcase_split_ss |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
415 |
|> Conv.fconv_rule ind_rulify |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
416 |
end |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
417 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
418 |
val res = Conjunction.intr_balanced (map_index project branches) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
419 |
|> fold_rev Thm.implies_intr (map cprop_of newgoals @ steps) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
420 |
|> Drule.generalize ([], [Rn]) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
421 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
422 |
val nbranches = length branches |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
423 |
val npres = length pres |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
424 |
in |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
425 |
Thm.compose_no_flatten false (res, length newgoals) i |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
426 |
THEN term_tac (i + nbranches + npres) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
427 |
THEN (EVERY (map (TRY o pres_tac) ((i + nbranches + npres - 1) downto (i + nbranches)))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
428 |
THEN (EVERY (map (TRY o comp_tac) ((i + nbranches - 1) downto i))) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
429 |
end)) |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
430 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
431 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
432 |
fun induction_schema_tac ctxt = |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
433 |
mk_ind_tac (K all_tac) (assume_tac APPEND' Goal.assume_rule_tac ctxt) (K all_tac) ctxt; |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
434 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
435 |
*} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
436 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
437 |
ML {* |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
438 |
val trm1 = @{prop "P1 &&& P2 &&& P3"} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
439 |
val trm2 = @{prop "(P1 &&& P2) &&& P3 &&& P4"} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
440 |
*} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
441 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
442 |
ML {* |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
443 |
Logic.dest_conjunctions trm2 |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
444 |
*} |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
445 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
446 |
lemma |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
447 |
shows "P1" "P2" "P4" |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
448 |
oops |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
449 |
|
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
450 |
lemma |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
451 |
shows "P1" "P2" "P3" "P4" |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
452 |
oops |
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
453 |
|
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
454 |
lemma strong_induct: |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
455 |
fixes c :: "'a :: fs" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
456 |
and assg :: assg and trm :: trm |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
457 |
assumes a0: "\<And>name c. P1 c (Var name)" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
458 |
and a1: "\<And>trm1 trm2 c. \<lbrakk>\<And>d. P1 d trm1; \<And>d. P1 d trm2\<rbrakk> \<Longrightarrow> P1 c (App trm1 trm2)" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
459 |
and a2: "\<And>name trm c. (\<And>d. P1 d trm) \<Longrightarrow> P1 c (Lam name trm)" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
460 |
and a3: "\<And>a1 t1 a2 t2 c. |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
461 |
\<lbrakk>((set (bn a1)) \<union> (set (bn a2))) \<sharp>* c; \<And>d. P2 c a1; \<And>d. P1 d t1; \<And>d. P2 d a2; \<And>d. P1 d t2\<rbrakk> |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
462 |
\<Longrightarrow> P1 c (Let1 a1 t1 a2 t2)" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
463 |
and a4: "\<And>n1 n2 t1 t2 c. |
2626
d1bdc281be2b
moved all strong_exhaust code to nominal_dt_quot; tuned examples
Christian Urban <urbanc@in.tum.de>
parents:
2616
diff
changeset
|
464 |
\<lbrakk>({atom n1} \<union> {atom n2}) \<sharp>* c; \<And>d. P1 d t1; \<And>d. P1 d t2\<rbrakk> \<Longrightarrow> P1 c (Let2 n1 n2 t1 t2)" |
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
465 |
and a5: "\<And>c. P2 c As_Nil" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
466 |
and a6: "\<And>name1 name2 trm assg c. \<lbrakk>\<And>d. P1 d trm; \<And>d. P2 d assg\<rbrakk> \<Longrightarrow> P2 c (As name1 name2 trm assg)" |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
467 |
shows "P1 c trm" "P2 c assg" |
2629
ffb5a181844b
proper application of induction_schema and strong_exhaust rules; needs local fix in induction_schema.ML
Christian Urban <urbanc@in.tum.de>
parents:
2628
diff
changeset
|
468 |
apply(raw_tactic {* induction_schema_tac @{context} @{thms assms} *}) |
2626
d1bdc281be2b
moved all strong_exhaust code to nominal_dt_quot; tuned examples
Christian Urban <urbanc@in.tum.de>
parents:
2616
diff
changeset
|
469 |
apply(rule_tac y="trm" and c="c" in foo.strong_exhaust(1)) |
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
470 |
apply(simp_all)[5] |
2626
d1bdc281be2b
moved all strong_exhaust code to nominal_dt_quot; tuned examples
Christian Urban <urbanc@in.tum.de>
parents:
2616
diff
changeset
|
471 |
apply(rule_tac ya="assg" in foo.strong_exhaust(2)) |
2588
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
472 |
apply(simp_all)[2] |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
473 |
apply(relation "measure (sum_case (size o snd) (size o snd))") |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
474 |
apply(simp_all add: foo.size) |
8f5420681039
completed the strong exhausts rules for Foo2 using general lemmas
Christian Urban <urbanc@in.tum.de>
parents:
2586
diff
changeset
|
475 |
done |
2584
1eac050a36f4
completely different method fro deriving the exhaust lemma
Christian Urban <urbanc@in.tum.de>
parents:
2579
diff
changeset
|
476 |
|
2573 | 477 |
end |
478 |
||
479 |
||
480 |