equal
deleted
inserted
replaced
54 case head_of t of |
54 case head_of t of |
55 Const (s, _) => s |
55 Const (s, _) => s |
56 | Free (s, _) => s |
56 | Free (s, _) => s |
57 | _ => error "Cannot extract name of constructor"; |
57 | _ => error "Cannot extract name of constructor"; |
58 |
58 |
59 fun prepare_sugar prep_term (((raw_ctrs, raw_caseof), raw_disc_names), raw_sel_namess) |
59 fun prepare_sugar prep_term ((raw_ctrs, raw_caseof), (raw_disc_names, raw_sel_namess)) |
60 no_defs_lthy = |
60 no_defs_lthy = |
61 let |
61 let |
62 (* TODO: sanity checks on arguments *) |
62 (* TODO: sanity checks on arguments *) |
63 |
63 |
64 (* TODO: normalize types of constructors w.r.t. each other *) |
64 (* TODO: normalize types of constructors w.r.t. each other *) |
401 end; |
401 end; |
402 in |
402 in |
403 (goals, after_qed, lthy') |
403 (goals, after_qed, lthy') |
404 end; |
404 end; |
405 |
405 |
406 val parse_binding_list = Parse.$$$ "[" |-- Parse.list Parse.binding --| Parse.$$$ "]"; |
406 val parse_bindings = Parse.$$$ "[" |-- Parse.list Parse.binding --| Parse.$$$ "]"; |
|
407 |
|
408 val parse_bindingss = Parse.$$$ "[" |-- Parse.list parse_bindings --| Parse.$$$ "]"; |
407 |
409 |
408 val bnf_sugar_cmd = (fn (goalss, after_qed, lthy) => |
410 val bnf_sugar_cmd = (fn (goalss, after_qed, lthy) => |
409 Proof.theorem NONE after_qed (map (map (rpair [])) goalss) lthy) oo |
411 Proof.theorem NONE after_qed (map (map (rpair [])) goalss) lthy) oo |
410 prepare_sugar Syntax.read_term; |
412 prepare_sugar Syntax.read_term; |
411 |
413 |
412 val _ = |
414 val _ = |
413 Outer_Syntax.local_theory_to_proof @{command_spec "bnf_sugar"} "adds sugar on top of a BNF" |
415 Outer_Syntax.local_theory_to_proof @{command_spec "bnf_sugar"} "adds sugar on top of a BNF" |
414 (((Parse.$$$ "[" |-- Parse.list Parse.term --| Parse.$$$ "]") -- Parse.term -- |
416 (((Parse.$$$ "[" |-- Parse.list Parse.term --| Parse.$$$ "]") -- Parse.term -- |
415 parse_binding_list -- (Parse.$$$ "[" |-- Parse.list parse_binding_list --| Parse.$$$ "]")) |
417 Scan.optional (parse_bindings -- Scan.optional parse_bindingss []) ([], [])) |
416 >> bnf_sugar_cmd); |
418 >> bnf_sugar_cmd); |
417 |
419 |
418 end; |
420 end; |