220 val t = HOLogic.mk_ST |
220 val t = HOLogic.mk_ST |
221 (map2 (fn (t, _) => fn (v, T') => ((t, @{typ Random.seed}), SOME ((v, termifyT T')))) tTs vs) |
221 (map2 (fn (t, _) => fn (v, T') => ((t, @{typ Random.seed}), SOME ((v, termifyT T')))) tTs vs) |
222 tc @{typ Random.seed} (SOME T, @{typ Random.seed}); |
222 tc @{typ Random.seed} (SOME T, @{typ Random.seed}); |
223 val tk = if is_rec |
223 val tk = if is_rec |
224 then if k = 0 then size |
224 then if k = 0 then size |
225 else @{term "Quickcheck.beyond :: code_numeral \<Rightarrow> code_numeral \<Rightarrow> code_numeral"} |
225 else @{term "Quickcheck_Random.beyond :: code_numeral \<Rightarrow> code_numeral \<Rightarrow> code_numeral"} |
226 $ HOLogic.mk_number @{typ code_numeral} k $ size |
226 $ HOLogic.mk_number @{typ code_numeral} k $ size |
227 else @{term "1::code_numeral"} |
227 else @{term "1::code_numeral"} |
228 in (is_rec, HOLogic.mk_prod (tk, t)) end; |
228 in (is_rec, HOLogic.mk_prod (tk, t)) end; |
229 fun sort_rec xs = |
229 fun sort_rec xs = |
230 map_filter (fn (true, t) => SOME t | _ => NONE) xs |
230 map_filter (fn (true, t) => SOME t | _ => NONE) xs |
231 @ map_filter (fn (false, t) => SOME t | _ => NONE) xs; |
231 @ map_filter (fn (false, t) => SOME t | _ => NONE) xs; |
232 val gen_exprss = tss |
232 val gen_exprss = tss |
233 |> (map o apfst) Type |
233 |> (map o apfst) Type |
234 |> map (fn (T, cs) => (T, (sort_rec o map (mk_consexpr T)) cs)); |
234 |> map (fn (T, cs) => (T, (sort_rec o map (mk_consexpr T)) cs)); |
235 fun mk_select (rT, xs) = |
235 fun mk_select (rT, xs) = |
236 mk_const @{const_name Quickcheck.collapse} [@{typ "Random.seed"}, termifyT rT] |
236 mk_const @{const_name Quickcheck_Random.collapse} [@{typ Random.seed}, termifyT rT] |
237 $ (mk_const @{const_name Random.select_weight} [random_resultT rT] |
237 $ (mk_const @{const_name Random.select_weight} [random_resultT rT] |
238 $ HOLogic.mk_list (HOLogic.mk_prodT (@{typ code_numeral}, random_resultT rT)) xs) |
238 $ HOLogic.mk_list (HOLogic.mk_prodT (@{typ code_numeral}, random_resultT rT)) xs) |
239 $ seed; |
239 $ seed; |
240 val auxs_lhss = map (fn t => t $ size $ size' $ seed) random_auxs; |
240 val auxs_lhss = map (fn t => t $ size $ size' $ seed) random_auxs; |
241 val auxs_rhss = map mk_select gen_exprss; |
241 val auxs_rhss = map mk_select gen_exprss; |
313 (@{const_name prod_case}, [T, @{typ "unit => term"}, liftT resultT @{typ Random.seed}]); |
313 (@{const_name prod_case}, [T, @{typ "unit => term"}, liftT resultT @{typ Random.seed}]); |
314 fun mk_scomp_split T t t' = |
314 fun mk_scomp_split T t t' = |
315 mk_scomp (mk_termtyp T) resultT @{typ Random.seed} t |
315 mk_scomp (mk_termtyp T) resultT @{typ Random.seed} t |
316 (mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
316 (mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
317 fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
317 fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
318 (Sign.mk_const thy (@{const_name Quickcheck.random}, [T]) $ Bound i); |
318 (Sign.mk_const thy (@{const_name Quickcheck_Random.random}, [T]) $ Bound i); |
319 in |
319 in |
320 lambda genuine_only |
320 lambda genuine_only |
321 (Abs ("n", @{typ code_numeral}, fold_rev mk_bindclause bounds (return $ check true))) |
321 (Abs ("n", @{typ code_numeral}, fold_rev mk_bindclause bounds (return $ check true))) |
322 end; |
322 end; |
323 |
323 |
331 val bounds = map_index (fn (i, ty) => |
331 val bounds = map_index (fn (i, ty) => |
332 (2 * (bound_max - i) + 1, 2 * (bound_max - i), 2 * i, ty)) Ts; |
332 (2 * (bound_max - i) + 1, 2 * (bound_max - i), 2 * i, ty)) Ts; |
333 val prop' = betapplys (prop, map (fn (i, _, _, _) => Bound i) bounds); |
333 val prop' = betapplys (prop, map (fn (i, _, _, _) => Bound i) bounds); |
334 val terms = HOLogic.mk_list @{typ term} (map (fn (_, i, _, _) => Bound i $ @{term "()"}) bounds) |
334 val terms = HOLogic.mk_list @{typ term} (map (fn (_, i, _, _) => Bound i $ @{term "()"}) bounds) |
335 val (assms, concl) = Quickcheck_Common.strip_imp prop' |
335 val (assms, concl) = Quickcheck_Common.strip_imp prop' |
336 val return = HOLogic.pair_const resultT @{typ "Random.seed"}; |
336 val return = HOLogic.pair_const resultT @{typ Random.seed}; |
337 fun mk_assms_report i = |
337 fun mk_assms_report i = |
338 HOLogic.mk_prod (@{term "None :: (bool * term list) option"}, |
338 HOLogic.mk_prod (@{term "None :: (bool * term list) option"}, |
339 HOLogic.mk_prod (HOLogic.mk_list HOLogic.boolT |
339 HOLogic.mk_prod (HOLogic.mk_list HOLogic.boolT |
340 (replicate i @{term True} @ replicate (length assms - i) @{term False}), |
340 (replicate i @{term True} @ replicate (length assms - i) @{term False}), |
341 @{term False})) |
341 @{term False})) |
359 (@{const_name prod_case}, [T, @{typ "unit => term"}, liftT resultT @{typ Random.seed}]); |
359 (@{const_name prod_case}, [T, @{typ "unit => term"}, liftT resultT @{typ Random.seed}]); |
360 fun mk_scomp_split T t t' = |
360 fun mk_scomp_split T t t' = |
361 mk_scomp (mk_termtyp T) resultT @{typ Random.seed} t |
361 mk_scomp (mk_termtyp T) resultT @{typ Random.seed} t |
362 (mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
362 (mk_split T $ Abs ("", T, Abs ("", @{typ "unit => term"}, t'))); |
363 fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
363 fun mk_bindclause (_, _, i, T) = mk_scomp_split T |
364 (Sign.mk_const thy (@{const_name Quickcheck.random}, [T]) $ Bound i); |
364 (Sign.mk_const thy (@{const_name Quickcheck_Random.random}, [T]) $ Bound i); |
365 in |
365 in |
366 lambda genuine_only |
366 lambda genuine_only |
367 (Abs ("n", @{typ code_numeral}, fold_rev mk_bindclause bounds (return $ check true))) |
367 (Abs ("n", @{typ code_numeral}, fold_rev mk_bindclause bounds (return $ check true))) |
368 end |
368 end |
369 |
369 |