author | krauss |
Wed, 08 Nov 2006 09:08:54 +0100 | |
changeset 21240 | 8e75fb38522c |
parent 21237 | b803f9870e97 |
child 21255 | 617fdb08abe9 |
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_common.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 |
Common type definitions and other infrastructure. |
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 |
structure FundefCommon = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
10 |
struct |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
11 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
12 |
(* Theory Dependencies *) |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
13 |
val acc_const_name = "FunDef.accP" |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
14 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
15 |
fun mk_acc domT R = |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
16 |
Const (acc_const_name, (fastype_of R) --> domT --> HOLogic.boolT) $ R |
19564
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 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
19 |
type depgraph = int IntGraph.T |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
20 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
21 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
22 |
datatype ctx_tree |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
23 |
= Leaf of term |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
24 |
| Cong of (term * thm * depgraph * ((string * typ) list * thm list * ctx_tree) list) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
25 |
| RCall of (term * ctx_tree) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
26 |
|
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
27 |
type glrs = (term list * term list * term * term) list |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
28 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
29 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
30 |
datatype globals = |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
31 |
Globals of { |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
32 |
fvar: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
33 |
domT: typ, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
34 |
ranT: typ, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
35 |
h: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
36 |
y: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
37 |
x: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
38 |
z: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
39 |
a:term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
40 |
P: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
41 |
D: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
42 |
Pbool:term |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
43 |
} |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
44 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
45 |
|
19583
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
46 |
datatype rec_call_info = |
19781 | 47 |
RCInfo of |
48 |
{ |
|
19922 | 49 |
RIvs: (string * typ) list, (* Call context: fixes and assumes *) |
50 |
CCas: thm list, |
|
51 |
rcarg: term, (* The recursive argument *) |
|
52 |
||
53 |
llRI: thm, |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
54 |
h_assum: term |
19781 | 55 |
} |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
56 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
57 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
58 |
datatype clause_context = |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
59 |
ClauseContext of |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
60 |
{ |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
61 |
ctxt : Proof.context, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
62 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
63 |
qs : term list, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
64 |
gs : term list, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
65 |
lhs: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
66 |
rhs: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
67 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
68 |
cqs: cterm list, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
69 |
ags: thm list, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
70 |
case_hyp : thm |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
71 |
} |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
72 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
73 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
74 |
fun transfer_clause_ctx thy (ClauseContext { ctxt, qs, gs, lhs, rhs, cqs, ags, case_hyp }) = |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
75 |
ClauseContext { ctxt = ProofContext.transfer thy ctxt, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
76 |
qs = qs, gs = gs, lhs = lhs, rhs = rhs, cqs = cqs, ags = ags, case_hyp = case_hyp } |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
77 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
78 |
|
19583
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
79 |
datatype clause_info = |
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
80 |
ClauseInfo of |
19564
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 |
no: int, |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
83 |
qglr : ((string * typ) list * term list * term * term), |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
84 |
cdata : clause_context, |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
85 |
|
19922 | 86 |
tree: ctx_tree, |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
87 |
lGI: thm, |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
88 |
RCs: rec_call_info list |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
89 |
} |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
90 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
91 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
92 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
93 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
94 |
type qgar = string * (string * typ) list * term list * term list * term |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
95 |
|
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
96 |
fun name_of_fqgar (f, _, _, _, _) = f |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
97 |
|
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
98 |
datatype mutual_part = |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
99 |
MutualPart of |
21237 | 100 |
{ |
101 |
fvar : string * typ, |
|
102 |
cargTs: typ list, |
|
103 |
pthA: SumTools.sum_path, |
|
104 |
pthR: SumTools.sum_path, |
|
105 |
f_def: term, |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
106 |
|
21237 | 107 |
f: term option, |
108 |
f_defthm : thm option |
|
109 |
} |
|
110 |
||
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
111 |
|
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
112 |
datatype mutual_info = |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
113 |
Mutual of |
21237 | 114 |
{ |
115 |
defname: string, |
|
116 |
fsum_var : string * typ, |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
117 |
|
21237 | 118 |
ST: typ, |
119 |
RST: typ, |
|
120 |
streeA: SumTools.sum_tree, |
|
121 |
streeR: SumTools.sum_tree, |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
122 |
|
21237 | 123 |
parts: mutual_part list, |
124 |
fqgars: qgar list, |
|
125 |
qglrs: ((string * typ) list * term list * term * term) list, |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
126 |
|
21237 | 127 |
fsum : term option |
128 |
} |
|
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
129 |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
130 |
|
19583
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
131 |
datatype prep_result = |
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
132 |
Prep of |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
133 |
{ |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
134 |
globals: globals, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
135 |
f: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
136 |
G: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
137 |
R: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
138 |
|
19922 | 139 |
goal: term, |
140 |
goalI: thm, |
|
141 |
values: thm list, |
|
142 |
clauses: clause_info list, |
|
143 |
||
144 |
R_cases: thm, |
|
145 |
ex1_iff: thm |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
146 |
} |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
147 |
|
19583
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
148 |
datatype fundef_result = |
c5fa77b03442
function-package: Changed record usage to make sml/nj happy...
krauss
parents:
19564
diff
changeset
|
149 |
FundefResult of |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
150 |
{ |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
151 |
f: term, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
152 |
G : term, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
153 |
R : term, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
154 |
completeness : thm, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
155 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
156 |
psimps : thm list, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
157 |
subset_pinduct : thm, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
158 |
simple_pinduct : thm, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
159 |
total_intro : thm, |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
160 |
dom_intros : thm list |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
161 |
} |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
162 |
|
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
163 |
datatype fundef_mresult = |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
164 |
FundefMResult of |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
165 |
{ |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
166 |
f: term, |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
167 |
G: term, |
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
168 |
R: term, |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
169 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
170 |
psimps : thm list, |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
171 |
subset_pinducts : thm list, |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
172 |
simple_pinducts : thm list, |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
173 |
cases : thm, |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
174 |
termination : thm, |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
175 |
domintros : thm list |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
176 |
} |
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
177 |
|
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
178 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
179 |
type fundef_spec = ((string * typ) * mixfix) list *((string * Attrib.src list) * term list) list list |
20270
3abe7dae681e
Function package can now do automatic splits of overlapping datatype patterns
krauss
parents:
19922
diff
changeset
|
180 |
type result_with_names = fundef_mresult * mutual_info * fundef_spec |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
181 |
|
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
182 |
structure FundefData = GenericDataFun |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
183 |
(struct |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
184 |
val name = "HOL/function_def/data"; |
19770
be5c23ebe1eb
HOL/Tools/function_package: Added support for mutual recursive definitions.
krauss
parents:
19617
diff
changeset
|
185 |
type T = string * result_with_names Symtab.table |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
186 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
187 |
val empty = ("", Symtab.empty); |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
188 |
val copy = I; |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
189 |
val extend = I; |
19617 | 190 |
fun merge _ ((l1,tab1),(l2,tab2)) = (l1, Symtab.merge (K true) (tab1, tab2)) |
19564
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 |
fun print _ _ = (); |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
193 |
end); |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
194 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
195 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
196 |
structure FundefCongs = GenericDataFun |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
197 |
(struct |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
198 |
val name = "HOL/function_def/congs" |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
199 |
type T = thm list |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
200 |
val empty = [] |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
201 |
val extend = I |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
202 |
fun merge _ (l1, l2) = l1 @ l2 |
20874 | 203 |
(* FIXME exponential blowup! cf. Library.merge, Drule.merge_rules *) |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
204 |
fun print _ _ = () |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
205 |
end); |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
206 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
207 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
208 |
fun add_fundef_data name fundef_data = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
209 |
FundefData.map (fn (_,tab) => (name, Symtab.update_new (name, fundef_data) tab)) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
210 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
211 |
fun get_fundef_data name thy = Symtab.lookup (snd (FundefData.get thy)) name |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
212 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
213 |
fun get_last_fundef thy = fst (FundefData.get thy) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
214 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
215 |
val map_fundef_congs = FundefCongs.map |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
216 |
val get_fundef_congs = FundefCongs.get |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
217 |
|
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
218 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
219 |
(* Configuration management *) |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
220 |
datatype fundef_opt |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
221 |
= Sequential |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
222 |
| Default of string |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
223 |
| Preprocessor of string |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
224 |
| Target of xstring |
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
225 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
226 |
datatype fundef_config |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
227 |
= FundefConfig of |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
228 |
{ |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
229 |
sequential: bool, |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
230 |
default: string, |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
231 |
preprocessor: string option, |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
232 |
target: xstring option |
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
233 |
} |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
234 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
235 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
236 |
val default_config = FundefConfig { sequential=false, default="%x. arbitrary", preprocessor=NONE, target=NONE } |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
237 |
val fun_config = FundefConfig { sequential=true, default="%x. arbitrary", preprocessor=NONE, target=NONE } |
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
238 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
239 |
fun apply_opt Sequential (FundefConfig {sequential, default, preprocessor, target}) = |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
240 |
FundefConfig {sequential=true, default=default, preprocessor=preprocessor, target=target } |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
241 |
| apply_opt (Default d) (FundefConfig {sequential, default, preprocessor, target}) = |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
242 |
FundefConfig {sequential=sequential, default=d, preprocessor=preprocessor, target=target } |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
243 |
| apply_opt (Preprocessor p) (FundefConfig {sequential, default, preprocessor, target}) = |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
244 |
FundefConfig {sequential=sequential, default=default, preprocessor=SOME p, target=target } |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
245 |
| apply_opt (Target t) (FundefConfig {sequential, default, preprocessor, target }) = |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
246 |
FundefConfig {sequential=sequential, default=default, preprocessor=preprocessor, target=SOME t } |
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
247 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
248 |
|
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
249 |
local structure P = OuterParse and K = OuterKeyword in |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
250 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
251 |
val opt_sequential = Scan.optional ((P.$$$ "(" |-- P.$$$ "sequential" --| P.$$$ ")") >> K true) false |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
252 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
253 |
val option_parser = (P.$$$ "sequential" >> K Sequential) |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
254 |
|| ((P.reserved "default" |-- P.term) >> Default) |
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
255 |
|| ((P.$$$ "in" |-- P.xname) >> Target) |
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
256 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
257 |
fun config_parser def = (Scan.optional (P.$$$ "(" |-- P.list1 option_parser --| P.$$$ ")") []) |
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
258 |
>> (fn opts => fold apply_opt opts def) |
20654
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
259 |
end |
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
260 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
261 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
262 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
263 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
264 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
265 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
266 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
267 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
268 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
269 |
|
d80502f0d701
1. Function package accepts a parameter (default "some_term"), which specifies the functions
krauss
parents:
20523
diff
changeset
|
270 |
|
21051
c49467a9c1e1
Switched function package to use the new package for inductive predicates.
krauss
parents:
20874
diff
changeset
|
271 |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
272 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
273 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
274 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
275 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
276 |
(* Common Abbreviations *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
277 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
278 |
structure FundefAbbrev = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
279 |
struct |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
280 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
281 |
fun implies_elim_swp x y = implies_elim y x |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
282 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
283 |
(* Some HOL things frequently used *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
284 |
val boolT = HOLogic.boolT |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
285 |
val mk_prod = HOLogic.mk_prod |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
286 |
val mk_mem = HOLogic.mk_mem |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
287 |
val mk_eq = HOLogic.mk_eq |
20523
36a59e5d0039
Major update to function package, including new syntax and the (only theoretical)
krauss
parents:
20289
diff
changeset
|
288 |
val eq_const = HOLogic.eq_const |
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
289 |
val Trueprop = HOLogic.mk_Trueprop |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
290 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
291 |
val mk_relT = HOLogic.mk_setT o HOLogic.mk_prodT |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
292 |
fun mk_relmem (x,y) R = Trueprop (mk_mem (mk_prod (x, y), R)) |
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 |
fun mk_subset T A B = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
295 |
let val sT = HOLogic.mk_setT T |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
296 |
in Const ("Orderings.less_eq", sT --> sT --> boolT) $ A $ B end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
297 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
298 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
299 |
(* with explicit types: Needed with loose bounds *) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
300 |
fun mk_relmemT xT yT (x,y) R = |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
301 |
let |
21237 | 302 |
val pT = HOLogic.mk_prodT (xT, yT) |
303 |
val RT = HOLogic.mk_setT pT |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
304 |
in |
21237 | 305 |
Const ("op :", [pT, RT] ---> boolT) |
306 |
$ (HOLogic.pair_const xT yT $ x $ y) |
|
307 |
$ R |
|
19564
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
308 |
end |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
309 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
310 |
fun free_to_var (Free (v,T)) = Var ((v,0),T) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
311 |
| free_to_var _ = raise Match |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
312 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
313 |
fun var_to_free (Var ((v,_),T)) = Free (v,T) |
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
314 |
| var_to_free _ = raise Match |
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 |
|
d3e2f532459a
First usable version of the new function definition package (HOL/function_packake/...).
krauss
parents:
diff
changeset
|
317 |
end |