src/HOL/Nominal/nominal_primrec.ML
changeset 31723 f5cafe803b55
parent 31177 c39994cb152a
child 31902 862ae16a799d
equal deleted inserted replaced
31717:d1f7b6245a75 31723:f5cafe803b55
     1 (*  Title:      HOL/Nominal/nominal_primrec.ML
     1 (*  Title:      HOL/Nominal/nominal_primrec.ML
     2     Author:     Norbert Voelker, FernUni Hagen
     2     Author:     Norbert Voelker, FernUni Hagen
     3     Author:     Stefan Berghofer, TU Muenchen
     3     Author:     Stefan Berghofer, TU Muenchen
     4 
     4 
     5 Package for defining functions on nominal datatypes by primitive recursion.
     5 Package for defining functions on nominal datatypes by primitive recursion.
     6 Taken from HOL/Tools/primrec_package.ML
     6 Taken from HOL/Tools/primrec.ML
     7 *)
     7 *)
     8 
     8 
     9 signature NOMINAL_PRIMREC =
     9 signature NOMINAL_PRIMREC =
    10 sig
    10 sig
    11   val add_primrec: term list option -> term option ->
    11   val add_primrec: term list option -> term option ->
   221   end;
   221   end;
   222 
   222 
   223 
   223 
   224 (* find datatypes which contain all datatypes in tnames' *)
   224 (* find datatypes which contain all datatypes in tnames' *)
   225 
   225 
   226 fun find_dts (dt_info : NominalPackage.nominal_datatype_info Symtab.table) _ [] = []
   226 fun find_dts (dt_info : Nominal.nominal_datatype_info Symtab.table) _ [] = []
   227   | find_dts dt_info tnames' (tname::tnames) =
   227   | find_dts dt_info tnames' (tname::tnames) =
   228       (case Symtab.lookup dt_info tname of
   228       (case Symtab.lookup dt_info tname of
   229           NONE => primrec_err (quote tname ^ " is not a nominal datatype")
   229           NONE => primrec_err (quote tname ^ " is not a nominal datatype")
   230         | SOME dt =>
   230         | SOME dt =>
   231             if tnames' subset (map (#1 o snd) (#descr dt)) then
   231             if tnames' subset (map (#1 o snd) (#descr dt)) then
   245     val fixes = List.take (fixes', length raw_fixes);
   245     val fixes = List.take (fixes', length raw_fixes);
   246     val (names_atts, spec') = split_list spec;
   246     val (names_atts, spec') = split_list spec;
   247     val eqns' = map unquantify spec'
   247     val eqns' = map unquantify spec'
   248     val eqns = fold_rev (process_eqn lthy (fn v => Variable.is_fixed lthy v
   248     val eqns = fold_rev (process_eqn lthy (fn v => Variable.is_fixed lthy v
   249       orelse exists (fn ((w, _), _) => v = Binding.name_of w) fixes)) spec' [];
   249       orelse exists (fn ((w, _), _) => v = Binding.name_of w) fixes)) spec' [];
   250     val dt_info = NominalPackage.get_nominal_datatypes (ProofContext.theory_of lthy);
   250     val dt_info = Nominal.get_nominal_datatypes (ProofContext.theory_of lthy);
   251     val lsrs :: lsrss = maps (fn (_, (_, _, eqns)) =>
   251     val lsrs :: lsrss = maps (fn (_, (_, _, eqns)) =>
   252       map (fn (_, (ls, _, rs, _, _)) => ls @ rs) eqns) eqns
   252       map (fn (_, (ls, _, rs, _, _)) => ls @ rs) eqns) eqns
   253     val _ =
   253     val _ =
   254       (if forall (curry eq_set lsrs) lsrss andalso forall
   254       (if forall (curry eq_set lsrs) lsrss andalso forall
   255          (fn (_, (_, _, (_, (ls, _, rs, _, _)) :: eqns)) =>
   255          (fn (_, (_, _, (_, (ls, _, rs, _, _)) :: eqns)) =>