src/Tools/quickcheck.ML
changeset 73583 ed5226fdf89d
parent 67149 e61557884799
child 74508 3315c551fe6e
equal deleted inserted replaced
73582:dabe295c3f62 73583:ed5226fdf89d
   340 
   340 
   341 fun test_goal (time_limit, is_interactive) (insts, eval_terms) i state =
   341 fun test_goal (time_limit, is_interactive) (insts, eval_terms) i state =
   342   let
   342   let
   343     val ctxt = Proof.context_of state;
   343     val ctxt = Proof.context_of state;
   344     val thy = Proof.theory_of state;
   344     val thy = Proof.theory_of state;
   345 
       
   346     fun strip (Const (\<^const_name>\<open>Pure.all\<close>, _) $ Abs (_, _, t)) = strip t
       
   347       | strip t = t;
       
   348     val {goal = st, ...} = Proof.raw_goal state;
       
   349     val (gi, frees) = Logic.goal_params (Thm.prop_of st) i;
       
   350     val opt_locale = Named_Target.bottom_locale_of ctxt;
   345     val opt_locale = Named_Target.bottom_locale_of ctxt;
       
   346     fun axioms_of locale =
       
   347       (case fst (Locale.specification_of thy locale) of
       
   348         NONE => []
       
   349       | SOME t => the_default [] (all_axioms_of ctxt t));
       
   350     val config = locale_config_of (Config.get ctxt locale);
   351     val assms =
   351     val assms =
   352       if Config.get ctxt no_assms then []
   352       if Config.get ctxt no_assms then []
   353       else
   353       else
   354         (case opt_locale of
   354         (case opt_locale of
   355           NONE => Assumption.all_assms_of ctxt
   355           NONE => Assumption.all_assms_of ctxt
   356         | SOME locale => Assumption.local_assms_of ctxt (Locale.init locale thy));
   356         | SOME locale => Assumption.local_assms_of ctxt (Locale.init locale thy));
   357     val proto_goal = Logic.list_implies (map Thm.term_of assms, subst_bounds (frees, strip gi));
   357     val {goal = st, ...} = Proof.raw_goal state;
   358     fun axioms_of locale =
   358     val (gi, _) = Logic.goal_params (Thm.prop_of st) i;
   359       (case fst (Locale.specification_of thy locale) of
   359     val ((_, raw_goal), ctxt') = Variable.focus NONE gi ctxt;
   360         NONE => []
   360     val proto_goal = Logic.list_implies (map Thm.term_of assms, raw_goal);
   361       | SOME t => the_default [] (all_axioms_of ctxt t));
       
   362     val config = locale_config_of (Config.get ctxt locale);
       
   363     val goals =
   361     val goals =
   364       (case opt_locale of
   362       (case opt_locale of
   365         NONE => [(proto_goal, eval_terms)]
   363         NONE => [(proto_goal, eval_terms)]
   366       | SOME locale =>
   364       | SOME locale =>
   367           fold (fn c =>
   365           fold (fn c =>
   371               append (map (fn (_, phi) =>
   369               append (map (fn (_, phi) =>
   372                   (Morphism.term phi proto_goal, map (Morphism.term phi) eval_terms))
   370                   (Morphism.term phi proto_goal, map (Morphism.term phi) eval_terms))
   373                 (Locale.registrations_of (Context.Theory thy) (* FIXME !? *) locale))
   371                 (Locale.registrations_of (Context.Theory thy) (* FIXME !? *) locale))
   374             else I) config []);
   372             else I) config []);
   375     val _ =
   373     val _ =
   376       verbose_message ctxt
   374       verbose_message ctxt'
   377         (Pretty.string_of
   375         (Pretty.string_of
   378           (Pretty.big_list ("Checking goals: ") (map (Syntax.pretty_term ctxt o fst) goals)));
   376           (Pretty.big_list ("Checking goals: ") (map (Syntax.pretty_term ctxt' o fst) goals)));
   379   in
   377   in
   380     test_terms ctxt (time_limit, is_interactive) insts goals
   378     test_terms ctxt' (time_limit, is_interactive) insts goals
   381   end;
   379   end;
   382 
   380 
   383 
   381 
   384 (* pretty printing *)
   382 (* pretty printing *)
   385 
   383