1178 fun strip_horn A = (strip_imp_prems A, strip_imp_concl A); |
1178 fun strip_horn A = (strip_imp_prems A, strip_imp_concl A); |
1179 |
1179 |
1180 fun define_quickcheck_predicate t thy = |
1180 fun define_quickcheck_predicate t thy = |
1181 let |
1181 let |
1182 val (vs, t') = strip_abs t |
1182 val (vs, t') = strip_abs t |
1183 val vs' = Variable.variant_frees (Proof_Context.init_global thy) [] vs |
1183 val vs' = Variable.variant_frees (Proof_Context.init_global thy) [] vs (* FIXME proper context!? *) |
1184 val t'' = subst_bounds (map Free (rev vs'), t') |
1184 val t'' = subst_bounds (map Free (rev vs'), t') |
1185 val (prems, concl) = strip_horn t'' |
1185 val (prems, concl) = strip_horn t'' |
1186 val constname = "quickcheck" |
1186 val constname = "quickcheck" |
1187 val full_constname = Sign.full_bname thy constname |
1187 val full_constname = Sign.full_bname thy constname |
1188 val constT = map snd vs' ---> @{typ bool} |
1188 val constT = map snd vs' ---> @{typ bool} |
1189 val thy1 = Sign.add_consts_i [(Binding.name constname, constT, NoSyn)] thy |
1189 val thy1 = Sign.add_consts_i [(Binding.name constname, constT, NoSyn)] thy |
1190 val const = Const (full_constname, constT) |
1190 val const = Const (full_constname, constT) |
1191 val t = Logic.list_implies |
1191 val t = Logic.list_implies |
1192 (map HOLogic.mk_Trueprop (prems @ [HOLogic.mk_not concl]), |
1192 (map HOLogic.mk_Trueprop (prems @ [HOLogic.mk_not concl]), |
1193 HOLogic.mk_Trueprop (list_comb (const, map Free vs'))) |
1193 HOLogic.mk_Trueprop (list_comb (const, map Free vs'))) |
1194 val tac = fn _ => Skip_Proof.cheat_tac thy1 |
1194 val intro = |
1195 val intro = Goal.prove (Proof_Context.init_global thy1) (map fst vs') [] t tac |
1195 Goal.prove (Proof_Context.init_global thy1) (map fst vs') [] t |
|
1196 (fn _ => ALLGOALS Skip_Proof.cheat_tac) |
1196 in |
1197 in |
1197 ((((full_constname, constT), vs'), intro), thy1) |
1198 ((((full_constname, constT), vs'), intro), thy1) |
1198 end |
1199 end |
1199 |
1200 |
1200 end; |
1201 end; |