61 val add_batch_validator : |
61 val add_batch_validator : |
62 string * (Proof.context -> term list -> (int -> bool) list) |
62 string * (Proof.context -> term list -> (int -> bool) list) |
63 -> Context.generic -> Context.generic |
63 -> Context.generic -> Context.generic |
64 (* basic operations *) |
64 (* basic operations *) |
65 val message : Proof.context -> string -> unit |
65 val message : Proof.context -> string -> unit |
|
66 val verbose_message : Proof.context -> string -> unit |
66 val limit : Time.time -> (bool * bool) -> (unit -> 'a) -> (unit -> 'a) -> unit -> 'a |
67 val limit : Time.time -> (bool * bool) -> (unit -> 'a) -> (unit -> 'a) -> unit -> 'a |
67 val pretty_counterex : Proof.context -> bool -> |
68 val pretty_counterex : Proof.context -> bool -> |
68 ((bool * (string * term) list) * (term * term) list) option -> Pretty.T |
69 ((bool * (string * term) list) * (term * term) list) option -> Pretty.T |
69 (* testing terms and proof states *) |
70 (* testing terms and proof states *) |
70 val mk_batch_validator : Proof.context -> term list -> (int -> bool) list option |
71 val mk_batch_validator : Proof.context -> term list -> (int -> bool) list option |
290 if is_interactive then exc () else raise TimeLimit.TimeOut |
291 if is_interactive then exc () else raise TimeLimit.TimeOut |
291 else |
292 else |
292 f () |
293 f () |
293 |
294 |
294 fun message ctxt s = if Config.get ctxt quiet then () else Output.urgent_message s |
295 fun message ctxt s = if Config.get ctxt quiet then () else Output.urgent_message s |
295 |
296 |
|
297 fun verbose_message ctxt s = if not (Config.get ctxt quiet) andalso Config.get ctxt verbose |
|
298 then Output.urgent_message s else () |
|
299 |
296 fun test_terms ctxt (limit_time, is_interactive) insts goals = |
300 fun test_terms ctxt (limit_time, is_interactive) insts goals = |
297 case active_testers ctxt of |
301 case active_testers ctxt of |
298 [] => error "No active testers for quickcheck" |
302 [] => error "No active testers for quickcheck" |
299 | testers => limit (seconds (Config.get ctxt timeout)) (limit_time, is_interactive) |
303 | testers => |
|
304 limit (seconds (Config.get ctxt timeout)) (limit_time, is_interactive) |
300 (fn () => Par_List.get_some (fn tester => |
305 (fn () => Par_List.get_some (fn tester => |
301 tester ctxt (length testers > 1) insts goals |> |
306 tester ctxt (length testers > 1) insts goals |> |
302 (fn result => if exists found_counterexample result then SOME result else NONE)) testers) |
307 (fn result => if exists found_counterexample result then SOME result else NONE)) testers) |
303 (fn () => (message ctxt "Quickcheck ran out of time"; NONE)) (); |
308 (fn () => (message ctxt "Quickcheck ran out of time"; NONE)) (); |
304 |
309 |
305 fun test_goal (time_limit, is_interactive) (insts, eval_terms) i state = |
310 fun test_goal (time_limit, is_interactive) (insts, eval_terms) i state = |
306 let |
311 let |
307 val lthy = Proof.context_of state; |
312 val lthy = Proof.context_of state; |
308 val thy = Proof.theory_of state; |
313 val thy = Proof.theory_of state; |
|
314 val _ = message lthy "Quickchecking..." |
309 fun strip (Const ("all", _) $ Abs (_, _, t)) = strip t |
315 fun strip (Const ("all", _) $ Abs (_, _, t)) = strip t |
310 | strip t = t; |
316 | strip t = t; |
311 val {goal = st, ...} = Proof.raw_goal state; |
317 val {goal = st, ...} = Proof.raw_goal state; |
312 val (gi, frees) = Logic.goal_params (prop_of st) i; |
318 val (gi, frees) = Logic.goal_params (prop_of st) i; |
313 val some_locale = case (Option.map #target o Named_Target.peek) lthy |
319 val some_locale = case (Option.map #target o Named_Target.peek) lthy |