src/Pure/axclass.ML
changeset 15570 8d8c70b41bab
parent 15531 08c8dad8e399
child 15596 8665d08085df
equal deleted inserted replaced
15569:1b3115d1a8df 15570:8d8c70b41bab
    62 (* get axioms and theorems *)
    62 (* get axioms and theorems *)
    63 
    63 
    64 val is_def = Logic.is_equals o #prop o rep_thm;
    64 val is_def = Logic.is_equals o #prop o rep_thm;
    65 
    65 
    66 fun witnesses thy names thms =
    66 fun witnesses thy names thms =
    67   PureThy.get_thmss thy (map (rpair NONE) names) @ thms @ filter is_def (map snd (axioms_of thy));
    67   PureThy.get_thmss thy (map (rpair NONE) names) @ thms @ List.filter is_def (map snd (axioms_of thy));
    68 
    68 
    69 
    69 
    70 
    70 
    71 (** abstract syntax operations **)
    71 (** abstract syntax operations **)
    72 
    72 
   246     fun axm_sort (name, ax) =
   246     fun axm_sort (name, ax) =
   247       (case term_tfrees ax of
   247       (case term_tfrees ax of
   248         [] => []
   248         [] => []
   249       | [(_, S)] => if Sign.subsort class_sign ([class], S) then S else err_bad_axsort name class
   249       | [(_, S)] => if Sign.subsort class_sign ([class], S) then S else err_bad_axsort name class
   250       | _ => err_bad_tfrees name);
   250       | _ => err_bad_tfrees name);
   251     val axS = Sign.certify_sort class_sign (flat (map axm_sort axms));
   251     val axS = Sign.certify_sort class_sign (List.concat (map axm_sort axms));
   252 
   252 
   253     val int_axm = Logic.close_form o map_term_tfrees (K (aT axS));
   253     val int_axm = Logic.close_form o map_term_tfrees (K (aT axS));
   254     fun inclass c = Logic.mk_inclass (aT axS, c);
   254     fun inclass c = Logic.mk_inclass (aT axS, c);
   255 
   255 
   256     val intro_axm = Logic.list_implies
   256     val intro_axm = Logic.list_implies
   286 (* class_axms *)
   286 (* class_axms *)
   287 
   287 
   288 fun class_axms sign =
   288 fun class_axms sign =
   289   let val classes = Sign.classes sign in
   289   let val classes = Sign.classes sign in
   290     map (Thm.class_triv sign) classes @
   290     map (Thm.class_triv sign) classes @
   291     mapfilter (apsome #intro o lookup_axclass_info_sg sign) classes
   291     List.mapPartial (Option.map #intro o lookup_axclass_info_sg sign) classes
   292   end;
   292   end;
   293 
   293 
   294 
   294 
   295 (* intro_classes *)
   295 (* intro_classes *)
   296 
   296 
   324   (2) rewrite goals using user supplied definitions
   324   (2) rewrite goals using user supplied definitions
   325   (3) repeatedly resolve goals with user supplied non-definitions*)
   325   (3) repeatedly resolve goals with user supplied non-definitions*)
   326 
   326 
   327 fun axclass_tac thms =
   327 fun axclass_tac thms =
   328   let
   328   let
   329     val defs = filter is_def thms;
   329     val defs = List.filter is_def thms;
   330     val non_defs = filter_out is_def thms;
   330     val non_defs = filter_out is_def thms;
   331   in
   331   in
   332     intro_classes_tac [] THEN
   332     intro_classes_tac [] THEN
   333     TRY (rewrite_goals_tac defs) THEN
   333     TRY (rewrite_goals_tac defs) THEN
   334     TRY (REPEAT_FIRST (fn i => assume_tac i ORELSE resolve_tac non_defs i))
   334     TRY (REPEAT_FIRST (fn i => assume_tac i ORELSE resolve_tac non_defs i))
   336 
   336 
   337 
   337 
   338 (* old-style provers *)
   338 (* old-style provers *)
   339 
   339 
   340 fun prove mk_prop str_of sign prop thms usr_tac =
   340 fun prove mk_prop str_of sign prop thms usr_tac =
   341   (Tactic.prove sign [] [] (mk_prop prop) (K (axclass_tac thms THEN (if_none usr_tac all_tac)))
   341   (Tactic.prove sign [] [] (mk_prop prop) (K (axclass_tac thms THEN (getOpt (usr_tac,all_tac))))
   342     handle ERROR => error ("The error(s) above occurred while trying to prove " ^
   342     handle ERROR => error ("The error(s) above occurred while trying to prove " ^
   343      quote (str_of sign prop))) |> Drule.standard;
   343      quote (str_of sign prop))) |> Drule.standard;
   344 
   344 
   345 val prove_subclass = prove mk_classrel (fn sg => fn (c1, c2) =>
   345 val prove_subclass = prove mk_classrel (fn sg => fn (c1, c2) =>
   346   Pretty.string_of_classrel (Sign.pp sg) [c1, c2]);
   346   Pretty.string_of_classrel (Sign.pp sg) [c1, c2]);