author | krauss |
Mon, 23 Oct 2006 17:46:11 +0200 | |
changeset 21100 | cda93bbf35db |
parent 21051 | c49467a9c1e1 |
child 21237 | b803f9870e97 |
permissions | -rw-r--r-- |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
1 |
(* Title: HOL/Tools/function_package/fundef_proof.ML |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
2 |
ID: $Id$ |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
3 |
Author: Alexander Krauss, TU Muenchen |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
4 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
5 |
A package for general recursive function definitions. |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
6 |
Internal proofs. |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
7 |
*) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
8 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
9 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
10 |
signature FUNDEF_PROOF = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
11 |
sig |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
12 |
|
19922 | 13 |
val mk_partial_rules : theory -> FundefCommon.prep_result |
14 |
-> thm -> FundefCommon.fundef_result |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
15 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
16 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
17 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
18 |
structure FundefProof : FUNDEF_PROOF = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
19 |
struct |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
20 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
21 |
open FundefLib |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
22 |
open FundefCommon |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
23 |
open FundefAbbrev |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
24 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
25 |
(* Theory dependencies *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
26 |
val subsetD = thm "subsetD" |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
27 |
val split_apply = thm "Product_Type.split" |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
28 |
val wf_induct_rule = thm "FunDef.wfP_induct_rule"; |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
29 |
val Pair_inject = thm "Product_Type.Pair_inject"; |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
30 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
31 |
val wf_in_rel = thm "FunDef.wf_in_rel"; |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
32 |
val in_rel_def = thm "FunDef.in_rel_def"; |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
33 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
34 |
val acc_induct_rule = thm "FunDef.accP_induct_rule" |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
35 |
val acc_downward = thm "FunDef.accP_downward" |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
36 |
val accI = thm "FunDef.accPI" |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
37 |
|
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
38 |
val acc_subset_induct = thm "FunDef.accP_subset_induct" |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
39 |
|
19922 | 40 |
val conjunctionD1 = thm "conjunctionD1" |
41 |
val conjunctionD2 = thm "conjunctionD2" |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
42 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
43 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
44 |
fun mk_psimp thy globals R f_iff graph_is_function clause valthm = |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
45 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
46 |
val Globals {domT, z, ...} = globals |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
47 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
48 |
val ClauseInfo {qglr = (oqs, _, _, _), cdata = ClauseContext {qs, cqs, gs, lhs, rhs, ags, ...}, ...} = clause |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
49 |
val lhs_acc = cterm_of thy (Trueprop (mk_acc domT R $ lhs)) (* "acc R lhs" *) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
50 |
val z_smaller = cterm_of thy (Trueprop (R $ z $ lhs)) (* "R z lhs" *) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
51 |
in |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
52 |
((assume z_smaller) RS ((assume lhs_acc) RS acc_downward)) |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
53 |
|> (fn it => it COMP graph_is_function) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
54 |
|> implies_intr z_smaller |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
55 |
|> forall_intr (cterm_of thy z) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
56 |
|> (fn it => it COMP valthm) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
57 |
|> implies_intr lhs_acc |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
58 |
|> asm_simplify (HOL_basic_ss addsimps [f_iff]) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
59 |
|> fold_rev (implies_intr o cprop_of) ags |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
60 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
61 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
62 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
63 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
64 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
65 |
fun mk_partial_induct_rule thy globals R complete_thm clauses = |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
66 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
67 |
val Globals {domT, x, z, a, P, D, ...} = globals |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
68 |
val acc_R = mk_acc domT R |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
69 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
70 |
val x_D = assume (cterm_of thy (Trueprop (D $ x))) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
71 |
val a_D = cterm_of thy (Trueprop (D $ a)) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
72 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
73 |
val D_subset = cterm_of thy (mk_forall x (implies $ Trueprop (D $ x) $ Trueprop (acc_R $ x))) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
74 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
75 |
val D_dcl = (* "!!x z. [| x: D; (z,x):R |] ==> z:D" *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
76 |
mk_forall x |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
77 |
(mk_forall z (Logic.mk_implies (Trueprop (D $ x), |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
78 |
Logic.mk_implies (Trueprop (R $ z $ x), |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
79 |
Trueprop (D $ z))))) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
80 |
|> cterm_of thy |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
81 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
82 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
83 |
(* Inductive Hypothesis: !!z. (z,x):R ==> P z *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
84 |
val ihyp = all domT $ Abs ("z", domT, |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
85 |
implies $ Trueprop (R $ Bound 0 $ x) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
86 |
$ Trueprop (P $ Bound 0)) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
87 |
|> cterm_of thy |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
88 |
|
19922 | 89 |
val aihyp = assume ihyp |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
90 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
91 |
fun prove_case clause = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
92 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
93 |
val ClauseInfo {cdata = ClauseContext {qs, cqs, ags, gs, lhs, rhs, case_hyp, ...}, RCs, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
94 |
qglr = (oqs, _, _, _), ...} = clause |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
95 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
96 |
val replace_x_ss = HOL_basic_ss addsimps [case_hyp] |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
97 |
val lhs_D = simplify replace_x_ss x_D (* lhs : D *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
98 |
val sih = full_simplify replace_x_ss aihyp |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
99 |
|
19922 | 100 |
fun mk_Prec (RCInfo {llRI, RIvs, CCas, rcarg, ...}) = |
101 |
sih |> forall_elim (cterm_of thy rcarg) |
|
102 |
|> implies_elim_swp llRI |
|
103 |
|> fold_rev (implies_intr o cprop_of) CCas |
|
104 |
|> fold_rev (forall_intr o cterm_of thy o Free) RIvs |
|
105 |
||
106 |
val P_recs = map mk_Prec RCs (* [P rec1, P rec2, ... ] *) |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
107 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
108 |
val step = Trueprop (P $ lhs) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
109 |
|> fold_rev (curry Logic.mk_implies o prop_of) P_recs |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
110 |
|> fold_rev (curry Logic.mk_implies) gs |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
111 |
|> curry Logic.mk_implies (Trueprop (D $ lhs)) |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
112 |
|> fold_rev mk_forall_rename (map fst oqs ~~ qs) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
113 |
|> cterm_of thy |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
114 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
115 |
val P_lhs = assume step |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
116 |
|> fold forall_elim cqs |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
117 |
|> implies_elim_swp lhs_D |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
118 |
|> fold_rev implies_elim_swp ags |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
119 |
|> fold implies_elim_swp P_recs |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
120 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
121 |
val res = cterm_of thy (Trueprop (P $ x)) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
122 |
|> Simplifier.rewrite replace_x_ss |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
123 |
|> symmetric (* P lhs == P x *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
124 |
|> (fn eql => equal_elim eql P_lhs) (* "P x" *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
125 |
|> implies_intr (cprop_of case_hyp) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
126 |
|> fold_rev (implies_intr o cprop_of) ags |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
127 |
|> fold_rev forall_intr cqs |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
128 |
in |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
129 |
(res, step) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
130 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
131 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
132 |
val (cases, steps) = split_list (map prove_case clauses) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
133 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
134 |
val istep = complete_thm |
19922 | 135 |
|> forall_elim_vars 0 |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
136 |
|> fold (curry op COMP) cases (* P x *) |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
137 |
|> implies_intr ihyp |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
138 |
|> implies_intr (cprop_of x_D) |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
139 |
|> forall_intr (cterm_of thy x) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
140 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
141 |
val subset_induct_rule = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
142 |
acc_subset_induct |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
143 |
|> (curry op COMP) (assume D_subset) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
144 |
|> (curry op COMP) (assume D_dcl) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
145 |
|> (curry op COMP) (assume a_D) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
146 |
|> (curry op COMP) istep |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
147 |
|> fold_rev implies_intr steps |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
148 |
|> implies_intr a_D |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
149 |
|> implies_intr D_dcl |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
150 |
|> implies_intr D_subset |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
151 |
|
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
152 |
val subset_induct_all = fold_rev (forall_intr o cterm_of thy) [P, a, D] subset_induct_rule |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
153 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
154 |
val simple_induct_rule = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
155 |
subset_induct_rule |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
156 |
|> forall_intr (cterm_of thy D) |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
157 |
|> forall_elim (cterm_of thy acc_R) |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
158 |
|> assume_tac 1 |> Seq.hd |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
159 |
|> (curry op COMP) (acc_downward |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
160 |
|> (instantiate' [SOME (ctyp_of thy domT)] |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
161 |
(map (SOME o cterm_of thy) [R, x, z])) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
162 |
|> forall_intr (cterm_of thy z) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
163 |
|> forall_intr (cterm_of thy x)) |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
164 |
|> forall_intr (cterm_of thy a) |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
165 |
|> forall_intr (cterm_of thy P) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
166 |
in |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19583
diff
changeset
|
167 |
(subset_induct_all, simple_induct_rule) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
168 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
169 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
170 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
171 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
172 |
(* Does this work with Guards??? *) |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
173 |
fun mk_domain_intro thy globals R R_cases clause = |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
174 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
175 |
val Globals {z, domT, ...} = globals |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
176 |
val ClauseInfo {cdata = ClauseContext {qs, gs, lhs, rhs, cqs, ...}, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
177 |
qglr = (oqs, _, _, _), ...} = clause |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
178 |
val goal = Trueprop (mk_acc domT R $ lhs) |
19782
48c4632e2c28
HOL/Tools/function_package: imporoved handling of guards, added an example
krauss
parents:
19781
diff
changeset
|
179 |
|> fold_rev (curry Logic.mk_implies) gs |
48c4632e2c28
HOL/Tools/function_package: imporoved handling of guards, added an example
krauss
parents:
19781
diff
changeset
|
180 |
|> cterm_of thy |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
181 |
in |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
182 |
Goal.init goal |
19781 | 183 |
|> (SINGLE (resolve_tac [accI] 1)) |> the |
19922 | 184 |
|> (SINGLE (eresolve_tac [forall_elim_vars 0 R_cases] 1)) |> the |
19781 | 185 |
|> (SINGLE (CLASIMPSET auto_tac)) |> the |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
186 |
|> Goal.conclude |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
187 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
188 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
189 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
190 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
191 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
192 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
193 |
fun mk_nest_term_case thy globals R' ihyp clause = |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
194 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
195 |
val Globals {x, z, ...} = globals |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
196 |
val ClauseInfo {cdata = ClauseContext {qs,cqs,ags,lhs,rhs,case_hyp,...},tree, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
197 |
qglr=(oqs, _, _, _), ...} = clause |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
198 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
199 |
val ih_case = full_simplify (HOL_basic_ss addsimps [case_hyp]) ihyp |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
200 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
201 |
fun step (fixes, assumes) (_ $ arg) u (sub,(hyps,thms)) = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
202 |
let |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
203 |
val used = map (fn ((f,a),thm) => FundefCtxTree.export_thm thy (f, map prop_of a) thm) (u @ sub) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
204 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
205 |
val hyp = Trueprop (R' $ arg $ lhs) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
206 |
|> fold_rev (curry Logic.mk_implies o prop_of) used |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
207 |
|> FundefCtxTree.export_term (fixes, map prop_of assumes) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
208 |
|> fold_rev (curry Logic.mk_implies o prop_of) ags |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
209 |
|> fold_rev mk_forall_rename (map fst oqs ~~ qs) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
210 |
|> cterm_of thy |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
211 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
212 |
val thm = assume hyp |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
213 |
|> fold forall_elim cqs |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
214 |
|> fold implies_elim_swp ags |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
215 |
|> FundefCtxTree.import_thm thy (fixes, assumes) (* "(arg, lhs) : R'" *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
216 |
|> fold implies_elim_swp used |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
217 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
218 |
val acc = thm COMP ih_case |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
219 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
220 |
val z_eq_arg = cterm_of thy (Trueprop (HOLogic.mk_eq (z, arg))) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
221 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
222 |
val arg_eq_z = (assume z_eq_arg) RS sym |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
223 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
224 |
val z_acc = simplify (HOL_basic_ss addsimps [arg_eq_z]) acc (* fragile, slow... *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
225 |
|> implies_intr (cprop_of case_hyp) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
226 |
|> implies_intr z_eq_arg |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
227 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
228 |
val z_eq_arg = assume (cterm_of thy (Trueprop (mk_eq (z, arg)))) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
229 |
val x_eq_lhs = assume (cterm_of thy (Trueprop (mk_eq (x, lhs)))) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
230 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
231 |
val ethm = (z_acc OF [z_eq_arg, x_eq_lhs]) |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
232 |
|> FundefCtxTree.export_thm thy (fixes, |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
233 |
prop_of z_eq_arg :: prop_of x_eq_lhs :: map prop_of (ags @ assumes)) |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
234 |
|> fold_rev forall_intr_rename (map fst oqs ~~ cqs) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
235 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
236 |
val sub' = sub @ [(([],[]), acc)] |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
237 |
in |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
238 |
(sub', (hyp :: hyps, ethm :: thms)) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
239 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
240 |
| step _ _ _ _ = raise Match |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
241 |
in |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
242 |
FundefCtxTree.traverse_tree step tree |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
243 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
244 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
245 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
246 |
fun mk_nest_term_rule thy globals R R_cases clauses = |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
247 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
248 |
val Globals { domT, x, z, ... } = globals |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
249 |
val acc_R = mk_acc domT R |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
250 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
251 |
val R' = Free ("R", fastype_of R) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
252 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
253 |
val Rrel = Free ("R", mk_relT (domT, domT)) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
254 |
val inrel_R = Const ("FunDef.in_rel", mk_relT (domT, domT) --> fastype_of R) $ Rrel |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
255 |
|
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
256 |
val wfR' = cterm_of thy (Trueprop (Const ("FunDef.wfP", (domT --> domT --> boolT) --> boolT) $ R')) (* "wf R'" *) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
257 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
258 |
(* Inductive Hypothesis: !!z. (z,x):R' ==> z : acc R *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
259 |
val ihyp = all domT $ Abs ("z", domT, |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
260 |
implies $ Trueprop (R' $ Bound 0 $ x) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
261 |
$ Trueprop (acc_R $ Bound 0)) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
262 |
|> cterm_of thy |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
263 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
264 |
val ihyp_a = assume ihyp |> forall_elim_vars 0 |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
265 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
266 |
val R_z_x = cterm_of thy (Trueprop (R $ z $ x)) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
267 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
268 |
val (hyps,cases) = fold (mk_nest_term_case thy globals R' ihyp_a) clauses ([],[]) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
269 |
in |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
270 |
R_cases |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
271 |
|> forall_elim (cterm_of thy z) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
272 |
|> forall_elim (cterm_of thy x) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
273 |
|> forall_elim (cterm_of thy (acc_R $ z)) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
274 |
|> curry op COMP (assume R_z_x) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
275 |
|> fold_rev (curry op COMP) cases |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
276 |
|> implies_intr R_z_x |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
277 |
|> forall_intr (cterm_of thy z) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
278 |
|> (fn it => it COMP accI) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
279 |
|> implies_intr ihyp |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
280 |
|> forall_intr (cterm_of thy x) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
281 |
|> (fn it => Drule.compose_single(it,2,wf_induct_rule)) |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
282 |
|> curry op RS (assume wfR') |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
283 |
|> fold implies_intr hyps |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
284 |
|> implies_intr wfR' |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
285 |
|> forall_intr (cterm_of thy R') |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
286 |
|> forall_elim (cterm_of thy (inrel_R)) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
287 |
|> curry op RS wf_in_rel |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
288 |
|> full_simplify (HOL_basic_ss addsimps [in_rel_def]) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20523
diff
changeset
|
289 |
|> forall_intr (cterm_of thy Rrel) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
290 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
291 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
292 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
293 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
294 |
|
19922 | 295 |
fun mk_partial_rules thy data provedgoal = |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
296 |
let |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
297 |
val Prep {globals, G, f, R, clauses, values, R_cases, ex1_iff, ...} = data |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
298 |
|
19922 | 299 |
val _ = print "Closing Derivation" |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
300 |
|
19922 | 301 |
val provedgoal = Drule.close_derivation provedgoal |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
302 |
|
19922 | 303 |
val _ = print "Getting gif" |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
304 |
|
19922 | 305 |
val graph_is_function = (provedgoal COMP conjunctionD1) |
306 |
|> forall_elim_vars 0 |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
307 |
|
19922 | 308 |
val _ = print "Getting cases" |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
309 |
|
19922 | 310 |
val complete_thm = provedgoal COMP conjunctionD2 |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
311 |
|
19922 | 312 |
val _ = print "making f_iff" |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
313 |
|
19922 | 314 |
val f_iff = (graph_is_function RS ex1_iff) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
315 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
316 |
val _ = Output.debug "Proving simplification rules" |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
317 |
val psimps = map2 (mk_psimp thy globals R f_iff graph_is_function) clauses values |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
318 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
319 |
val _ = Output.debug "Proving partial induction rule" |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
320 |
val (subset_pinduct, simple_pinduct) = mk_partial_induct_rule thy globals R complete_thm clauses |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
321 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
322 |
val _ = Output.debug "Proving nested termination rule" |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
323 |
val total_intro = mk_nest_term_rule thy globals R R_cases clauses |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
324 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
325 |
val _ = Output.debug "Proving domain introduction rules" |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
19930
diff
changeset
|
326 |
val dom_intros = map (mk_domain_intro thy globals R R_cases) clauses |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
327 |
in |
19922 | 328 |
FundefResult {f=f, G=G, R=R, completeness=complete_thm, |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
329 |
psimps=psimps, subset_pinduct=subset_pinduct, simple_pinduct=simple_pinduct, total_intro=total_intro, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
330 |
dom_intros=dom_intros} |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
331 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
332 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
333 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
334 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
335 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
336 |