Nominal/nominal_atoms.ML
branchNominal2-Isabelle2016
changeset 3243 c4f31f1564b7
parent 3239 67370521c09c
child 3245 017e33849f4d
equal deleted inserted replaced
3242:4af8a92396ce 3243:c4f31f1564b7
    10 signature ATOM_DECL =
    10 signature ATOM_DECL =
    11 sig
    11 sig
    12   val add_atom_decl: (binding * (binding option)) -> theory -> theory
    12   val add_atom_decl: (binding * (binding option)) -> theory -> theory
    13 end;
    13 end;
    14 
    14 
    15 structure Atom_Decl :> ATOM_DECL =
    15 structure Atom_Decl : ATOM_DECL =
    16 struct
    16 struct
    17 
    17 
    18 val simp_attr = Attrib.internal (K Simplifier.simp_add)
    18 val simp_attr = Attrib.internal (K Simplifier.simp_add)
    19 
    19 
    20 fun atom_decl_set (str : string) : term =
    20 fun atom_decl_set (str : string) : term =
    30   let
    30   let
    31     val str = Sign.full_name thy name;
    31     val str = Sign.full_name thy name;
    32 
    32 
    33     (* typedef *)
    33     (* typedef *)
    34     val set = atom_decl_set str;
    34     val set = atom_decl_set str;
    35     fun tac _ = rtac @{thm exists_eq_simple_sort} 1;
    35     fun tac ctxt = resolve_tac ctxt @{thms exists_eq_simple_sort} 1;
    36     val ((full_tname, info as ({Rep_name, Abs_name, ...}, {type_definition, ...})), thy) =
    36     val ((full_tname, info as ({Rep_name, Abs_name, ...}, {type_definition, ...})), thy) =
    37       Typedef.add_typedef_global false (name, [], NoSyn) set NONE tac thy;
    37       Typedef.add_typedef_global {overloaded = false} (name, [], NoSyn) set NONE tac thy;
    38 
    38 
    39     (* definition of atom and permute *)
    39     (* definition of atom and permute *)
    40     val newT = #abs_type (fst info);
    40     val newT = #abs_type (fst info);
    41     val RepC = Const (Rep_name, newT --> @{typ atom});
    41     val RepC = Const (Rep_name, newT --> @{typ atom});
    42     val AbsC = Const (Abs_name, @{typ atom} --> newT);
    42     val AbsC = Const (Abs_name, @{typ atom} --> newT);
    66     val atom_def = singleton (Proof_Context.export lthy ctxt_thy) atom_ldef;
    66     val atom_def = singleton (Proof_Context.export lthy ctxt_thy) atom_ldef;
    67     val class_thm = @{thm at_class} OF [type_definition, atom_def, permute_def];
    67     val class_thm = @{thm at_class} OF [type_definition, atom_def, permute_def];
    68     val sort_thm = @{thm at_class_sort} OF [type_definition, atom_def]
    68     val sort_thm = @{thm at_class_sort} OF [type_definition, atom_def]
    69     val thy = lthy
    69     val thy = lthy
    70       |> snd o (Local_Theory.note ((sort_thm_name, [simp_attr]), [sort_thm]))
    70       |> snd o (Local_Theory.note ((sort_thm_name, [simp_attr]), [sort_thm]))
    71       |> Class.prove_instantiation_instance (K (rtac class_thm 1))
    71       |> Class.prove_instantiation_instance (fn ctxt => resolve_tac ctxt [class_thm] 1)
    72       |> Local_Theory.exit_global;
    72       |> Local_Theory.exit_global;
    73   in
    73   in
    74     thy
    74     thy
    75   end;
    75   end;
    76 
    76