author | wenzelm |
Fri, 16 Mar 2012 18:20:12 +0100 | |
changeset 46961 | 5c6955f487e5 |
parent 45898 | b619242b0439 |
child 54742 | 7a86358a3c0b |
permissions | -rw-r--r-- |
45897
65cef0298158
clarified modules that contribute to datatype package;
wenzelm
parents:
45736
diff
changeset
|
1 |
(* Title: HOL/Tools/Datatype/primrec.ML |
39812 | 2 |
Author: Norbert Voelker, FernUni Hagen |
3 |
Author: Stefan Berghofer, TU Muenchen |
|
4 |
Author: Florian Haftmann, TU Muenchen |
|
5178 | 5 |
|
39812 | 6 |
Primitive recursive functions on datatypes. |
5178 | 7 |
*) |
8 |
||
31723
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
haftmann
parents:
31296
diff
changeset
|
9 |
signature PRIMREC = |
5178 | 10 |
sig |
29581 | 11 |
val add_primrec: (binding * typ option * mixfix) list -> |
35166 | 12 |
(Attrib.binding * term) list -> local_theory -> (term list * thm list) * local_theory |
30487
a14ff49d3083
simplified preparation and outer parsing of specification;
wenzelm
parents:
30455
diff
changeset
|
13 |
val add_primrec_cmd: (binding * string option * mixfix) list -> |
35166 | 14 |
(Attrib.binding * string) list -> local_theory -> (term list * thm list) * local_theory |
29581 | 15 |
val add_primrec_global: (binding * typ option * mixfix) list -> |
35166 | 16 |
(Attrib.binding * term) list -> theory -> (term list * thm list) * theory |
26679
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
17 |
val add_primrec_overloaded: (string * (string * typ) * bool) list -> |
29581 | 18 |
(binding * typ option * mixfix) list -> |
35166 | 19 |
(Attrib.binding * term) list -> theory -> (term list * thm list) * theory |
31269 | 20 |
val add_primrec_simple: ((binding * typ) * mixfix) list -> term list -> |
35166 | 21 |
local_theory -> (string * (term list * thm list)) * local_theory |
5178 | 22 |
end; |
23 |
||
31723
f5cafe803b55
discontinued ancient tradition to suffix certain ML module names with "_package"
haftmann
parents:
31296
diff
changeset
|
24 |
structure Primrec : PRIMREC = |
5178 | 25 |
struct |
26 |
||
25557 | 27 |
exception PrimrecError of string * term option; |
6359 | 28 |
|
25557 | 29 |
fun primrec_error msg = raise PrimrecError (msg, NONE); |
30 |
fun primrec_error_eqn msg eqn = raise PrimrecError (msg, SOME eqn); |
|
23765
997e5fe47532
Function unify_consts moved from OldInductivePackage to PrimrecPackage.
berghofe
parents:
22728
diff
changeset
|
31 |
|
997e5fe47532
Function unify_consts moved from OldInductivePackage to PrimrecPackage.
berghofe
parents:
22728
diff
changeset
|
32 |
|
5178 | 33 |
(* preprocessing of equations *) |
34 |
||
25559 | 35 |
fun process_eqn is_fixed spec rec_fns = |
5178 | 36 |
let |
25566 | 37 |
val (vs, Ts) = split_list (strip_qnt_vars "all" spec); |
25557 | 38 |
val body = strip_qnt_body "all" spec; |
43326
47cf4bc789aa
simplified Name.variant -- discontinued builtin fold_map;
wenzelm
parents:
42482
diff
changeset
|
39 |
val (vs', _) = fold_map Name.variant vs (Name.make_context (fold_aterms |
25566 | 40 |
(fn Free (v, _) => insert (op =) v | _ => I) body [])); |
41 |
val eqn = curry subst_bounds (map2 (curry Free) vs' Ts |> rev) body; |
|
25557 | 42 |
val (lhs, rhs) = HOLogic.dest_eq (HOLogic.dest_Trueprop eqn) |
43 |
handle TERM _ => primrec_error "not a proper equation"; |
|
5178 | 44 |
val (recfun, args) = strip_comb lhs; |
39812 | 45 |
val fname = |
46 |
(case recfun of |
|
47 |
Free (v, _) => |
|
48 |
if is_fixed v then v |
|
25557 | 49 |
else primrec_error "illegal head of function equation" |
39812 | 50 |
| _ => primrec_error "illegal head of function equation"); |
5178 | 51 |
|
52 |
val (ls', rest) = take_prefix is_Free args; |
|
53 |
val (middle, rs') = take_suffix is_Free rest; |
|
54 |
val rpos = length ls'; |
|
55 |
||
39812 | 56 |
val (constr, cargs') = |
57 |
if null middle then primrec_error "constructor missing" |
|
5178 | 58 |
else strip_comb (hd middle); |
59 |
val (cname, T) = dest_Const constr |
|
25557 | 60 |
handle TERM _ => primrec_error "ill-formed constructor"; |
7016
df54b5365477
- Now also supports arbitrarily branching datatypes.
berghofe
parents:
6729
diff
changeset
|
61 |
val (tname, _) = dest_Type (body_type T) handle TYPE _ => |
25557 | 62 |
primrec_error "cannot determine datatype associated with function" |
5178 | 63 |
|
20176 | 64 |
val (ls, cargs, rs) = |
65 |
(map dest_Free ls', map dest_Free cargs', map dest_Free rs') |
|
25557 | 66 |
handle TERM _ => primrec_error "illegal argument in pattern"; |
5178 | 67 |
val lfrees = ls @ rs @ cargs; |
68 |
||
12474 | 69 |
fun check_vars _ [] = () |
25557 | 70 |
| check_vars s vars = primrec_error (s ^ commas_quote (map fst vars)) eqn; |
5178 | 71 |
in |
22692 | 72 |
if length middle > 1 then |
25557 | 73 |
primrec_error "more than one non-variable in pattern" |
12474 | 74 |
else |
18964 | 75 |
(check_vars "repeated variable names in pattern: " (duplicates (op =) lfrees); |
12474 | 76 |
check_vars "extra variables on rhs: " |
39814 | 77 |
(Term.add_frees rhs [] |> subtract (op =) lfrees |
25559 | 78 |
|> filter_out (is_fixed o fst)); |
39812 | 79 |
(case AList.lookup (op =) rec_fns fname of |
15531 | 80 |
NONE => |
39812 | 81 |
(fname, (tname, rpos, [(cname, (ls, cargs, rs, rhs, eqn))])) :: rec_fns |
15531 | 82 |
| SOME (_, rpos', eqns) => |
17184 | 83 |
if AList.defined (op =) eqns cname then |
25557 | 84 |
primrec_error "constructor already occurred as pattern" |
5178 | 85 |
else if rpos <> rpos' then |
25557 | 86 |
primrec_error "position of recursive argument inconsistent" |
5178 | 87 |
else |
25557 | 88 |
AList.update (op =) |
39812 | 89 |
(fname, (tname, rpos, (cname, (ls, cargs, rs, rhs, eqn)) :: eqns)) |
90 |
rec_fns)) |
|
25557 | 91 |
end handle PrimrecError (msg, NONE) => primrec_error_eqn msg spec; |
5178 | 92 |
|
25557 | 93 |
fun process_fun descr eqns (i, fname) (fnames, fnss) = |
5178 | 94 |
let |
25557 | 95 |
val (_, (tname, _, constrs)) = nth descr i; |
5178 | 96 |
|
97 |
(* substitute "fname ls x rs" by "y ls rs" for (x, (_, y)) in subs *) |
|
98 |
||
21064 | 99 |
fun subst [] t fs = (t, fs) |
100 |
| subst subs (Abs (a, T, t)) fs = |
|
101 |
fs |
|
102 |
|> subst subs t |
|
103 |
|-> (fn t' => pair (Abs (a, T, t'))) |
|
104 |
| subst subs (t as (_ $ _)) fs = |
|
105 |
let |
|
106 |
val (f, ts) = strip_comb t; |
|
5178 | 107 |
in |
25557 | 108 |
if is_Free f |
109 |
andalso member (fn ((v, _), (w, _)) => v = w) eqns (dest_Free f) then |
|
5178 | 110 |
let |
25557 | 111 |
val (fname', _) = dest_Free f; |
112 |
val (_, rpos, _) = the (AList.lookup (op =) eqns fname'); |
|
27301
bf7d82193a2e
fixed bind error for malformed primrec specifications
haftmann
parents:
26679
diff
changeset
|
113 |
val (ls, rs) = chop rpos ts |
39812 | 114 |
val (x', rs') = |
115 |
(case rs of |
|
116 |
x' :: rs => (x', rs) |
|
117 |
| [] => primrec_error ("not enough arguments in recursive application\n" ^ |
|
118 |
"of function " ^ quote fname' ^ " on rhs")); |
|
27301
bf7d82193a2e
fixed bind error for malformed primrec specifications
haftmann
parents:
26679
diff
changeset
|
119 |
val (x, xs) = strip_comb x'; |
39812 | 120 |
in |
121 |
(case AList.lookup (op =) subs x of |
|
122 |
NONE => |
|
21064 | 123 |
fs |
124 |
|> fold_map (subst subs) ts |
|
125 |
|-> (fn ts' => pair (list_comb (f, ts'))) |
|
126 |
| SOME (i', y) => |
|
127 |
fs |
|
27301
bf7d82193a2e
fixed bind error for malformed primrec specifications
haftmann
parents:
26679
diff
changeset
|
128 |
|> fold_map (subst subs) (xs @ ls @ rs') |
25557 | 129 |
||> process_fun descr eqns (i', fname') |
39812 | 130 |
|-> (fn ts' => pair (list_comb (y, ts')))) |
5178 | 131 |
end |
132 |
else |
|
21064 | 133 |
fs |
134 |
|> fold_map (subst subs) (f :: ts) |
|
39812 | 135 |
|-> (fn f' :: ts' => pair (list_comb (f', ts'))) |
5178 | 136 |
end |
21064 | 137 |
| subst _ t fs = (t, fs); |
5178 | 138 |
|
139 |
(* translate rec equations into function arguments suitable for rec comb *) |
|
140 |
||
25557 | 141 |
fun trans eqns (cname, cargs) (fnames', fnss', fns) = |
17184 | 142 |
(case AList.lookup (op =) eqns cname of |
39812 | 143 |
NONE => (warning ("No equation for constructor " ^ quote cname ^ |
144 |
"\nin definition of function " ^ quote fname); |
|
39813 | 145 |
(fnames', fnss', (Const (@{const_name undefined}, dummyT)) :: fns)) |
39812 | 146 |
| SOME (ls, cargs', rs, rhs, eq) => |
147 |
let |
|
45736 | 148 |
val recs = filter (Datatype_Aux.is_rec_type o snd) (cargs' ~~ cargs); |
39812 | 149 |
val rargs = map fst recs; |
150 |
val subs = map (rpair dummyT o fst) |
|
151 |
(rev (Term.rename_wrt_term rhs rargs)); |
|
152 |
val (rhs', (fnames'', fnss'')) = subst (map2 (fn (x, y) => fn z => |
|
45736 | 153 |
(Free x, (Datatype_Aux.body_index y, Free z))) recs subs) rhs (fnames', fnss') |
39812 | 154 |
handle PrimrecError (s, NONE) => primrec_error_eqn s eq |
44241 | 155 |
in |
156 |
(fnames'', fnss'', fold_rev absfree (cargs' @ subs @ ls @ rs) rhs' :: fns) |
|
39812 | 157 |
end) |
5178 | 158 |
|
39812 | 159 |
in |
160 |
(case AList.lookup (op =) fnames i of |
|
15531 | 161 |
NONE => |
25557 | 162 |
if exists (fn (_, v) => fname = v) fnames then |
163 |
primrec_error ("inconsistent functions for datatype " ^ quote tname) |
|
5178 | 164 |
else |
165 |
let |
|
25557 | 166 |
val (_, _, eqns) = the (AList.lookup (op =) eqns fname); |
167 |
val (fnames', fnss', fns) = fold_rev (trans eqns) constrs |
|
39812 | 168 |
((i, fname) :: fnames, fnss, []) |
5178 | 169 |
in |
39812 | 170 |
(fnames', (i, (fname, #1 (snd (hd eqns)), fns)) :: fnss') |
5178 | 171 |
end |
25557 | 172 |
| SOME fname' => |
173 |
if fname = fname' then (fnames, fnss) |
|
174 |
else primrec_error ("inconsistent functions for datatype " ^ quote tname)) |
|
5178 | 175 |
end; |
176 |
||
6359 | 177 |
|
5178 | 178 |
(* prepare functions needed for definitions *) |
179 |
||
21064 | 180 |
fun get_fns fns ((i : int, (tname, _, constrs)), rec_name) (fs, defs) = |
39812 | 181 |
(case AList.lookup (op =) fns i of |
182 |
NONE => |
|
183 |
let |
|
39813 | 184 |
val dummy_fns = map (fn (_, cargs) => Const (@{const_name undefined}, |
45736 | 185 |
replicate (length cargs + length (filter Datatype_Aux.is_rec_type cargs)) |
39812 | 186 |
dummyT ---> HOLogic.unitT)) constrs; |
187 |
val _ = warning ("No function definition for datatype " ^ quote tname) |
|
188 |
in |
|
189 |
(dummy_fns @ fs, defs) |
|
190 |
end |
|
191 |
| SOME (fname, ls, fs') => (fs' @ fs, (fname, ls, rec_name, tname) :: defs)); |
|
5178 | 192 |
|
6359 | 193 |
|
5178 | 194 |
(* make definition *) |
195 |
||
25557 | 196 |
fun make_def ctxt fixes fs (fname, ls, rec_name, tname) = |
5178 | 197 |
let |
30451
11e5e8bb28f9
corrected type inference of primitive definitions
haftmann
parents:
30364
diff
changeset
|
198 |
val SOME (var, varT) = get_first (fn ((b, T), mx) => |
11e5e8bb28f9
corrected type inference of primitive definitions
haftmann
parents:
30364
diff
changeset
|
199 |
if Binding.name_of b = fname then SOME ((b, mx), T) else NONE) fixes; |
30364
577edc39b501
moved basic algebra of long names from structure NameSpace to Long_Name;
wenzelm
parents:
30280
diff
changeset
|
200 |
val def_name = Thm.def_name (Long_Name.base_name fname); |
30451
11e5e8bb28f9
corrected type inference of primitive definitions
haftmann
parents:
30364
diff
changeset
|
201 |
val raw_rhs = fold_rev (fn T => fn t => Abs ("", T, t)) (map snd ls @ [dummyT]) |
11e5e8bb28f9
corrected type inference of primitive definitions
haftmann
parents:
30364
diff
changeset
|
202 |
(list_comb (Const (rec_name, dummyT), fs @ map Bound (0 :: (length ls downto 1)))) |
39288 | 203 |
val rhs = singleton (Syntax.check_terms ctxt) (Type.constraint varT raw_rhs); |
33755
6dc1b67f2127
concealing internal definitions of primrec specifications
bulwahn
parents:
33726
diff
changeset
|
204 |
in (var, ((Binding.conceal (Binding.name def_name), []), rhs)) end; |
5178 | 205 |
|
6359 | 206 |
|
5178 | 207 |
(* find datatypes which contain all datatypes in tnames' *) |
208 |
||
45898 | 209 |
fun find_dts _ _ [] = [] |
39812 | 210 |
| find_dts dt_info tnames' (tname :: tnames) = |
17412 | 211 |
(case Symtab.lookup dt_info tname of |
39812 | 212 |
NONE => primrec_error (quote tname ^ " is not a datatype") |
45898 | 213 |
| SOME (dt : Datatype_Aux.info) => |
39812 | 214 |
if subset (op =) (tnames', map (#1 o snd) (#descr dt)) then |
215 |
(tname, dt) :: (find_dts dt_info tnames' tnames) |
|
216 |
else find_dts dt_info tnames' tnames); |
|
5178 | 217 |
|
25557 | 218 |
|
31262 | 219 |
(* distill primitive definition(s) from primrec specification *) |
25557 | 220 |
|
45898 | 221 |
fun distill ctxt fixes eqs = |
25557 | 222 |
let |
45898 | 223 |
val eqns = fold_rev (process_eqn (fn v => Variable.is_fixed ctxt v |
31262 | 224 |
orelse exists (fn ((w, _), _) => v = Binding.name_of w) fixes)) eqs []; |
25557 | 225 |
val tnames = distinct (op =) (map (#1 o snd) eqns); |
45898 | 226 |
val dts = find_dts (Datatype_Data.get_all (Proof_Context.theory_of ctxt)) tnames tnames; |
25557 | 227 |
val main_fns = map (fn (tname, {index, ...}) => |
228 |
(index, (fst o the o find_first (fn (_, x) => #1 x = tname)) eqns)) dts; |
|
22692 | 229 |
val {descr, rec_names, rec_rewrites, ...} = |
25557 | 230 |
if null dts then primrec_error |
231 |
("datatypes " ^ commas_quote tnames ^ "\nare not mutually recursive") |
|
18362
e8b7e0a22727
removed thms 'swap' and 'nth_map' from ML toplevel
haftmann
parents:
18358
diff
changeset
|
232 |
else snd (hd dts); |
25557 | 233 |
val (fnames, fnss) = fold_rev (process_fun descr eqns) main_fns ([], []); |
31262 | 234 |
val (fs, raw_defs) = fold_rev (get_fns fnss) (descr ~~ rec_names) ([], []); |
45898 | 235 |
val defs = map (make_def ctxt fixes fs) raw_defs; |
31262 | 236 |
val names = map snd fnames; |
237 |
val names_eqns = map fst eqns; |
|
39812 | 238 |
val _ = |
239 |
if eq_set (op =) (names, names_eqns) then () |
|
31262 | 240 |
else primrec_error ("functions " ^ commas_quote names_eqns ^ |
25557 | 241 |
"\nare not mutually recursive"); |
31262 | 242 |
val rec_rewrites' = map mk_meta_eq rec_rewrites; |
243 |
val prefix = space_implode "_" (map (Long_Name.base_name o #1) raw_defs); |
|
45898 | 244 |
fun prove ctxt defs = |
31262 | 245 |
let |
45898 | 246 |
val frees = fold (Variable.add_free_names ctxt) eqs []; |
31262 | 247 |
val rewrites = rec_rewrites' @ map (snd o snd) defs; |
248 |
fun tac _ = EVERY [rewrite_goals_tac rewrites, rtac refl 1]; |
|
45898 | 249 |
in map (fn eq => Goal.prove ctxt frees [] eq tac) eqs end; |
31262 | 250 |
in ((prefix, (fs, defs)), prove) end |
251 |
handle PrimrecError (msg, some_eqn) => |
|
39812 | 252 |
error ("Primrec definition error:\n" ^ msg ^ |
253 |
(case some_eqn of |
|
45898 | 254 |
SOME eqn => "\nin\n" ^ quote (Syntax.string_of_term ctxt eqn) |
31262 | 255 |
| NONE => "")); |
256 |
||
257 |
||
258 |
(* primrec definition *) |
|
259 |
||
31269 | 260 |
fun add_primrec_simple fixes ts lthy = |
31262 | 261 |
let |
45898 | 262 |
val ((prefix, (_, defs)), prove) = distill lthy fixes ts; |
31262 | 263 |
in |
264 |
lthy |
|
33766
c679f05600cd
adapted Local_Theory.define -- eliminated odd thm kind;
wenzelm
parents:
33755
diff
changeset
|
265 |
|> fold_map Local_Theory.define defs |
35166 | 266 |
|-> (fn defs => `(fn lthy => (prefix, (map fst defs, prove lthy defs)))) |
31262 | 267 |
end; |
268 |
||
269 |
local |
|
270 |
||
33726
0878aecbf119
eliminated slightly odd name space grouping -- now managed by Isar toplevel;
wenzelm
parents:
33671
diff
changeset
|
271 |
fun gen_primrec prep_spec raw_fixes raw_spec lthy = |
31262 | 272 |
let |
273 |
val (fixes, spec) = fst (prep_spec raw_fixes raw_spec lthy); |
|
274 |
fun attr_bindings prefix = map (fn ((b, attrs), _) => |
|
275 |
(Binding.qualify false prefix b, Code.add_default_eqn_attrib :: attrs)) spec; |
|
33552 | 276 |
fun simp_attr_binding prefix = |
45592 | 277 |
(Binding.qualify true prefix (Binding.name "simps"), @{attributes [simp, nitpick_simp]}); |
8480
50266d517b0c
Added new theory data slot for primrec equations.
berghofe
parents:
8432
diff
changeset
|
278 |
in |
25557 | 279 |
lthy |
31269 | 280 |
|> add_primrec_simple fixes (map snd spec) |
35756
cfde251d03a5
refining and adding Spec_Rules to definitional packages old_primrec, primrec, recdef, size and function
bulwahn
parents:
35166
diff
changeset
|
281 |
|-> (fn (prefix, (ts, simps)) => |
cfde251d03a5
refining and adding Spec_Rules to definitional packages old_primrec, primrec, recdef, size and function
bulwahn
parents:
35166
diff
changeset
|
282 |
Spec_Rules.add Spec_Rules.Equational (ts, simps) |
cfde251d03a5
refining and adding Spec_Rules to definitional packages old_primrec, primrec, recdef, size and function
bulwahn
parents:
35166
diff
changeset
|
283 |
#> fold_map Local_Theory.note (attr_bindings prefix ~~ map single simps) |
34952
bd7e347eb768
added registration of equational theorems from prim_rec and rec_def to Spec_Rules
bulwahn
parents:
33968
diff
changeset
|
284 |
#-> (fn simps' => Local_Theory.note (simp_attr_binding prefix, maps snd simps') |
35756
cfde251d03a5
refining and adding Spec_Rules to definitional packages old_primrec, primrec, recdef, size and function
bulwahn
parents:
35166
diff
changeset
|
285 |
#>> (fn (_, simps'') => (ts, simps'')))) |
31262 | 286 |
end; |
20841 | 287 |
|
288 |
in |
|
289 |
||
33726
0878aecbf119
eliminated slightly odd name space grouping -- now managed by Isar toplevel;
wenzelm
parents:
33671
diff
changeset
|
290 |
val add_primrec = gen_primrec Specification.check_spec; |
0878aecbf119
eliminated slightly odd name space grouping -- now managed by Isar toplevel;
wenzelm
parents:
33671
diff
changeset
|
291 |
val add_primrec_cmd = gen_primrec Specification.read_spec; |
20841 | 292 |
|
22692 | 293 |
end; |
19688 | 294 |
|
26679
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
295 |
fun add_primrec_global fixes specs thy = |
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
296 |
let |
38388 | 297 |
val lthy = Named_Target.theory_init thy; |
35166 | 298 |
val ((ts, simps), lthy') = add_primrec fixes specs lthy; |
42361 | 299 |
val simps' = Proof_Context.export lthy' lthy simps; |
35166 | 300 |
in ((ts, simps'), Local_Theory.exit_global lthy') end; |
26679
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
301 |
|
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
302 |
fun add_primrec_overloaded ops fixes specs thy = |
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
303 |
let |
38342
09d4a04d5c2e
moved overloading target formally to overloading.ML
haftmann
parents:
37145
diff
changeset
|
304 |
val lthy = Overloading.overloading ops thy; |
35166 | 305 |
val ((ts, simps), lthy') = add_primrec fixes specs lthy; |
42361 | 306 |
val simps' = Proof_Context.export lthy' lthy simps; |
35166 | 307 |
in ((ts, simps'), Local_Theory.exit_global lthy') end; |
26679
447f4872b7ee
Added add_primrec_global and add_primrec_overloaded functions (thanks to Markus).
berghofe
parents:
26556
diff
changeset
|
308 |
|
5178 | 309 |
|
6359 | 310 |
(* outer syntax *) |
311 |
||
24867 | 312 |
val _ = |
46961
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
45898
diff
changeset
|
313 |
Outer_Syntax.local_theory @{command_spec "primrec"} |
5c6955f487e5
outer syntax command definitions based on formal command_spec derived from theory header declarations;
wenzelm
parents:
45898
diff
changeset
|
314 |
"define primitive recursive functions on datatypes" |
39812 | 315 |
(Parse.fixes -- Parse_Spec.where_alt_specs |
316 |
>> (fn (fixes, specs) => add_primrec_cmd fixes specs #> snd)); |
|
6359 | 317 |
|
5178 | 318 |
end; |