6 *) |
6 *) |
7 |
7 |
8 signature BNF_AXIOMATIZATION = |
8 signature BNF_AXIOMATIZATION = |
9 sig |
9 sig |
10 val bnf_axiomatization: (string -> bool) -> (binding option * (typ * sort)) list -> binding -> |
10 val bnf_axiomatization: (string -> bool) -> (binding option * (typ * sort)) list -> binding -> |
11 mixfix -> binding -> binding -> typ list -> local_theory -> BNF_Def.bnf * local_theory |
11 mixfix -> binding -> binding -> binding -> typ list -> local_theory -> |
|
12 BNF_Def.bnf * local_theory |
12 end |
13 end |
13 |
14 |
14 structure BNF_Axiomatization : BNF_AXIOMATIZATION = |
15 structure BNF_Axiomatization : BNF_AXIOMATIZATION = |
15 struct |
16 struct |
16 |
17 |
17 open BNF_Util |
18 open BNF_Util |
18 open BNF_Def |
19 open BNF_Def |
19 |
20 |
20 fun prepare_decl prepare_plugins prepare_constraint prepare_typ |
21 fun prepare_decl prepare_plugins prepare_constraint prepare_typ |
21 raw_plugins raw_vars b mx user_mapb user_relb user_witTs lthy = |
22 raw_plugins raw_vars b mx user_mapb user_relb user_predb user_witTs lthy = |
22 let |
23 let |
23 val plugins = prepare_plugins lthy raw_plugins; |
24 val plugins = prepare_plugins lthy raw_plugins; |
24 |
25 |
25 fun prepare_type_arg (set_opt, (ty, c)) = |
26 fun prepare_type_arg (set_opt, (ty, c)) = |
26 let val s = fst (dest_TFree (prepare_typ lthy ty)) in |
27 let val s = fst (dest_TFree (prepare_typ lthy ty)) in |
70 val Fbd = Const (Local_Theory.full_name lthy bdb, bdT); |
71 val Fbd = Const (Local_Theory.full_name lthy bdb, bdT); |
71 val Fwits = map2 (fn witb => fn witT => |
72 val Fwits = map2 (fn witb => fn witT => |
72 Const (Local_Theory.full_name lthy witb, witT)) witbs witTs; |
73 Const (Local_Theory.full_name lthy witb, witT)) witbs witTs; |
73 val (key, goals, (triv_tac_opt, wit_goalss), after_qed, lthy, _) = |
74 val (key, goals, (triv_tac_opt, wit_goalss), after_qed, lthy, _) = |
74 prepare_def Do_Inline (user_policy Note_Some) false I (K I) (K I) (SOME (map TFree deads)) |
75 prepare_def Do_Inline (user_policy Note_Some) false I (K I) (K I) (SOME (map TFree deads)) |
75 user_mapb user_relb user_setbs ((((((Binding.empty, T), Fmap), Fsets), Fbd), Fwits), NONE) |
76 user_mapb user_relb user_predb user_setbs |
|
77 (((((((Binding.empty, T), Fmap), Fsets), Fbd), Fwits), NONE), NONE) |
76 lthy; |
78 lthy; |
77 |
79 |
78 fun mk_wits_tac ctxt set_maps = TRYALL Goal.conjunction_tac THEN the triv_tac_opt ctxt set_maps; |
80 fun mk_wits_tac ctxt set_maps = TRYALL Goal.conjunction_tac THEN the triv_tac_opt ctxt set_maps; |
79 val wit_goals = map Logic.mk_conjunction_balanced wit_goalss; |
81 val wit_goals = map Logic.mk_conjunction_balanced wit_goalss; |
80 val all_goalss = map single goals @ (if nwits > 0 then wit_goalss else []); |
82 val all_goalss = map single goals @ (if nwits > 0 then wit_goalss else []); |
114 val parse_bnf_axiomatization_options = |
116 val parse_bnf_axiomatization_options = |
115 Scan.optional (@{keyword "("} |-- Plugin_Name.parse_filter --| @{keyword ")"}) (K (K true)); |
117 Scan.optional (@{keyword "("} |-- Plugin_Name.parse_filter --| @{keyword ")"}) (K (K true)); |
116 |
118 |
117 val parse_bnf_axiomatization = |
119 val parse_bnf_axiomatization = |
118 parse_bnf_axiomatization_options -- parse_type_args_named_constrained -- Parse.binding -- |
120 parse_bnf_axiomatization_options -- parse_type_args_named_constrained -- Parse.binding -- |
119 parse_witTs -- Parse.opt_mixfix -- parse_map_rel_bindings; |
121 parse_witTs -- Parse.opt_mixfix -- parse_map_rel_pred_bindings; |
120 |
122 |
121 val _ = |
123 val _ = |
122 Outer_Syntax.local_theory @{command_keyword bnf_axiomatization} "bnf declaration" |
124 Outer_Syntax.local_theory @{command_keyword bnf_axiomatization} "bnf declaration" |
123 (parse_bnf_axiomatization >> |
125 (parse_bnf_axiomatization >> |
124 (fn (((((plugins, bsTs), b), witTs), mx), (mapb, relb)) => |
126 (fn (((((plugins, bsTs), b), witTs), mx), (mapb, relb, predb)) => |
125 bnf_axiomatization_cmd plugins bsTs b mx mapb relb witTs #> snd)); |
127 bnf_axiomatization_cmd plugins bsTs b mx mapb relb predb witTs #> snd)); |
126 |
128 |
127 end; |
129 end; |