338 if b then @{term True} else @{term False}) |
338 if b then @{term True} else @{term False}) |
339 val If = |
339 val If = |
340 @{term "If :: bool => term list option * (bool list * bool) => term list option * (bool list * bool) => term list option * (bool list * bool)"} |
340 @{term "If :: bool => term list option * (bool list * bool) => term list option * (bool list * bool) => term list option * (bool list * bool)"} |
341 val concl_check = If $ concl $ |
341 val concl_check = If $ concl $ |
342 HOLogic.mk_prod (@{term "None :: term list option"}, mk_concl_report true) $ |
342 HOLogic.mk_prod (@{term "None :: term list option"}, mk_concl_report true) $ |
343 HOLogic.mk_prod (@{term "Some :: term list => term list option"} $ terms, mk_concl_report false) |
343 HOLogic.mk_prod (@{term "Some :: term list => term list option"} $ terms, mk_concl_report false) |
344 val check = fold_rev (fn (i, assm) => fn t => If $ assm $ t $ mk_assms_report i) |
344 val check = fold_rev (fn (i, assm) => fn t => If $ assm $ t $ mk_assms_report i) |
345 (map_index I assms) concl_check |
345 (map_index I assms) concl_check |
|
346 val check' = @{term "Quickcheck.catch_match :: term list option * bool list * bool => |
|
347 term list option * bool list * bool => term list option * bool list * bool"} $ check $ |
|
348 (if Config.get ctxt Quickcheck.potential then |
|
349 HOLogic.mk_prod (@{term "Some :: term list => term list option"} $ terms, mk_concl_report false) |
|
350 else |
|
351 HOLogic.mk_prod (@{term "None :: term list option"}, mk_concl_report true)) |
346 fun liftT T sT = sT --> HOLogic.mk_prodT (T, sT); |
352 fun liftT T sT = sT --> HOLogic.mk_prodT (T, sT); |
347 fun mk_termtyp T = HOLogic.mk_prodT (T, @{typ "unit => term"}); |
353 fun mk_termtyp T = HOLogic.mk_prodT (T, @{typ "unit => term"}); |
348 fun mk_scomp T1 T2 sT f g = Const (@{const_name scomp}, |
354 fun mk_scomp T1 T2 sT f g = Const (@{const_name scomp}, |
349 liftT T1 sT --> (T1 --> liftT T2 sT) --> liftT T2 sT) $ f $ g; |
355 liftT T1 sT --> (T1 --> liftT T2 sT) --> liftT T2 sT) $ f $ g; |
350 fun mk_split T = Sign.mk_const thy |
356 fun mk_split T = Sign.mk_const thy |
354 mk_scomp (mk_termtyp T) @{typ "term list option * (bool list * bool)"} @{typ Random.seed} t |
360 mk_scomp (mk_termtyp T) @{typ "term list option * (bool list * bool)"} @{typ Random.seed} t |
355 (mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
361 (mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
356 fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
362 fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
357 (Sign.mk_const thy (@{const_name Quickcheck.random}, [T]) $ Bound i); |
363 (Sign.mk_const thy (@{const_name Quickcheck.random}, [T]) $ Bound i); |
358 in |
364 in |
359 Abs ("n", @{typ code_numeral}, fold_rev mk_bindclause bounds (return $ check)) |
365 Abs ("n", @{typ code_numeral}, fold_rev mk_bindclause bounds (return $ check')) |
360 end |
366 end |
361 |
367 |
362 val mk_parametric_generator_expr = Quickcheck_Common.gen_mk_parametric_generator_expr |
368 val mk_parametric_generator_expr = Quickcheck_Common.gen_mk_parametric_generator_expr |
363 ((mk_generator_expr, |
369 ((mk_generator_expr, |
364 absdummy @{typ code_numeral} @{term "Pair None :: Random.seed => (bool * term list) option * Random.seed"}), |
370 absdummy @{typ code_numeral} @{term "Pair None :: Random.seed => (bool * term list) option * Random.seed"}), |