src/Pure/Isar/code.ML
changeset 47555 978bd14ad065
parent 47437 4625ee486ff6
child 48068 04aeda922be2
equal deleted inserted replaced
47554:10c92d6a3caf 47555:978bd14ad065
   946                  (Pretty.block o Pretty.breaks)
   946                  (Pretty.block o Pretty.breaks)
   947                     (Pretty.str (string_of_const thy c)
   947                     (Pretty.str (string_of_const thy c)
   948                       :: Pretty.str "of"
   948                       :: Pretty.str "of"
   949                       :: map (Pretty.quote o Syntax.pretty_typ_global thy) tys)) cos)
   949                       :: map (Pretty.quote o Syntax.pretty_typ_global thy) tys)) cos)
   950       );
   950       );
   951     fun ignored_cases NONE = "<ignored>"
   951     fun pretty_caseparam NONE = "<ignored>"
   952       | ignored_cases (SOME c) = string_of_const thy c
   952       | pretty_caseparam (SOME c) = string_of_const thy c
   953     fun pretty_case (const, ((_, (_, [])), _)) = Pretty.str (string_of_const thy const)
   953     fun pretty_case (const, ((_, (_, [])), _)) = Pretty.str (string_of_const thy const)
   954       | pretty_case (const, ((_, (_, cos)), _)) = (Pretty.block o Pretty.breaks) [
   954       | pretty_case (const, ((_, (_, cos)), _)) = (Pretty.block o Pretty.breaks) [
   955           Pretty.str (string_of_const thy const), Pretty.str "with",
   955           Pretty.str (string_of_const thy const), Pretty.str "with",
   956           (Pretty.block o Pretty.commas o map (Pretty.str o ignored_cases)) cos];
   956           (Pretty.block o Pretty.commas o map (Pretty.str o pretty_caseparam)) cos];
   957     val functions = the_functions exec
   957     val functions = the_functions exec
   958       |> Symtab.dest
   958       |> Symtab.dest
   959       |> (map o apsnd) (snd o fst)
   959       |> (map o apsnd) (snd o fst)
   960       |> sort (string_ord o pairself fst);
   960       |> sort (string_ord o pairself fst);
   961     val datatypes = the_types exec
   961     val datatypes = the_types exec
  1087   in Skip_Proof.prove_global thy (x :: y :: zs) [prem] concl tac end;
  1087   in Skip_Proof.prove_global thy (x :: y :: zs) [prem] concl tac end;
  1088 
  1088 
  1089 fun add_case thm thy =
  1089 fun add_case thm thy =
  1090   let
  1090   let
  1091     val (case_const, (k, cos)) = case_cert thm;
  1091     val (case_const, (k, cos)) = case_cert thm;
  1092     val _ = case map_filter I cos |> filter_out (is_constr thy)
  1092     val _ = case (filter_out (is_constr thy) o map_filter I) cos
  1093      of [] => ()
  1093      of [] => ()
  1094       | cs => error ("Non-constructor(s) in case certificate: " ^ commas_quote cs);
  1094       | cs => error ("Non-constructor(s) in case certificate: " ^ commas_quote cs);
  1095     val entry = (1 + Int.max (1, length cos), (k, cos));
  1095     val entry = (1 + Int.max (1, length cos), (k, cos));
  1096     fun register_case cong = (map_cases o apfst)
  1096     fun register_case cong = (map_cases o apfst)
  1097       (Symtab.update (case_const, (entry, cong)));
  1097       (Symtab.update (case_const, (entry, cong)));