src/HOL/Tools/Ctr_Sugar/ctr_sugar.ML
changeset 58188 cc71d2be4f0a
parent 58187 d2ddd401d74d
child 58189 9d714be4f028
equal deleted inserted replaced
58187:d2ddd401d74d 58188:cc71d2be4f0a
    44   val ctr_sugars_of_global: theory -> ctr_sugar list
    44   val ctr_sugars_of_global: theory -> ctr_sugar list
    45   val ctr_sugar_of_case: Proof.context -> string -> ctr_sugar option
    45   val ctr_sugar_of_case: Proof.context -> string -> ctr_sugar option
    46   val ctr_sugar_of_case_global: theory -> string -> ctr_sugar option
    46   val ctr_sugar_of_case_global: theory -> string -> ctr_sugar option
    47   val ctr_sugar_interpretation: string -> (ctr_sugar -> theory -> theory) ->
    47   val ctr_sugar_interpretation: string -> (ctr_sugar -> theory -> theory) ->
    48     (ctr_sugar -> local_theory -> local_theory) -> theory -> theory
    48     (ctr_sugar -> local_theory -> local_theory) -> theory -> theory
    49   val interpret_ctr_sugar: ctr_sugar -> local_theory -> local_theory
    49   val interpret_ctr_sugar: (string -> bool) -> ctr_sugar -> local_theory -> local_theory
    50   val register_ctr_sugar_raw: ctr_sugar -> local_theory -> local_theory
    50   val register_ctr_sugar_raw: ctr_sugar -> local_theory -> local_theory
    51   val register_ctr_sugar: ctr_sugar -> local_theory -> local_theory
    51   val register_ctr_sugar: (string -> bool) -> ctr_sugar -> local_theory -> local_theory
    52   val default_register_ctr_sugar_global: ctr_sugar -> theory -> theory
    52   val default_register_ctr_sugar_global: (string -> bool) -> ctr_sugar -> theory -> theory
    53 
    53 
    54   val mk_half_pairss: 'a list * 'a list -> ('a * 'a) list list
    54   val mk_half_pairss: 'a list * 'a list -> ('a * 'a) list list
    55   val join_halves: int -> 'a list list -> 'a list list -> 'a list * 'a list list list
    55   val join_halves: int -> 'a list list -> 'a list list -> 'a list * 'a list list list
    56 
    56 
    57   val mk_ctr: typ list -> term -> term
    57   val mk_ctr: typ list -> term -> term
   191 
   191 
   192 fun register_ctr_sugar_raw (ctr_sugar as {T = Type (s, _), ...}) =
   192 fun register_ctr_sugar_raw (ctr_sugar as {T = Type (s, _), ...}) =
   193   Local_Theory.declaration {syntax = false, pervasive = true}
   193   Local_Theory.declaration {syntax = false, pervasive = true}
   194     (fn phi => Data.map (Symtab.update (s, morph_ctr_sugar phi ctr_sugar)));
   194     (fn phi => Data.map (Symtab.update (s, morph_ctr_sugar phi ctr_sugar)));
   195 
   195 
   196 fun register_ctr_sugar ctr_sugar =
   196 fun register_ctr_sugar keep ctr_sugar =
   197   register_ctr_sugar_raw ctr_sugar #> interpret_ctr_sugar ctr_sugar;
   197   register_ctr_sugar_raw ctr_sugar #> interpret_ctr_sugar keep ctr_sugar;
   198 
   198 
   199 fun default_register_ctr_sugar_global (ctr_sugar as {T = Type (s, _), ...}) thy =
   199 fun default_register_ctr_sugar_global keep (ctr_sugar as {T = Type (s, _), ...}) thy =
   200   let val tab = Data.get (Context.Theory thy) in
   200   let val tab = Data.get (Context.Theory thy) in
   201     if Symtab.defined tab s then
   201     if Symtab.defined tab s then
   202       thy
   202       thy
   203     else
   203     else
   204       thy
   204       thy
   205       |> Context.theory_map (Data.put (Symtab.update_new (s, ctr_sugar) tab))
   205       |> Context.theory_map (Data.put (Symtab.update_new (s, ctr_sugar) tab))
   206       |> Ctr_Sugar_Interpretation.data_global ctr_sugar
   206       |> Ctr_Sugar_Interpretation.data_global keep ctr_sugar
   207   end;
   207   end;
   208 
   208 
   209 val isN = "is_";
   209 val isN = "is_";
   210 val unN = "un_";
   210 val unN = "un_";
   211 val notN = "not_";
   211 val notN = "not_";
  1043            exhaust_sels = exhaust_sel_thms, collapses = all_collapse_thms, expands = expand_thms,
  1043            exhaust_sels = exhaust_sel_thms, collapses = all_collapse_thms, expands = expand_thms,
  1044            split_sels = split_sel_thms, split_sel_asms = split_sel_asm_thms,
  1044            split_sels = split_sel_thms, split_sel_asms = split_sel_asm_thms,
  1045            case_eq_ifs = case_eq_if_thms}
  1045            case_eq_ifs = case_eq_if_thms}
  1046           |> morph_ctr_sugar (substitute_noted_thm noted);
  1046           |> morph_ctr_sugar (substitute_noted_thm noted);
  1047       in
  1047       in
  1048         (ctr_sugar, lthy' |> register_ctr_sugar ctr_sugar)
  1048         (ctr_sugar, lthy' |> register_ctr_sugar (K true) ctr_sugar)
  1049       end;
  1049       end;
  1050   in
  1050   in
  1051     (goalss, after_qed, lthy')
  1051     (goalss, after_qed, lthy')
  1052   end;
  1052   end;
  1053 
  1053