adding exhaustive instances for type constructor set
authorbulwahn
Thu, 12 Jan 2012 10:19:33 +0100
changeset 46193 55a4769d0abe
parent 46192 93eaaacc1955
child 46194 872f915e3a98
adding exhaustive instances for type constructor set
src/HOL/Quickcheck_Exhaustive.thy
--- a/src/HOL/Quickcheck_Exhaustive.thy	Thu Jan 12 00:14:20 2012 +0100
+++ b/src/HOL/Quickcheck_Exhaustive.thy	Thu Jan 12 10:19:33 2012 +0100
@@ -135,6 +135,33 @@
 
 end
 
+instantiation set :: (exhaustive) exhaustive
+begin
+
+fun exhaustive_set
+where
+  "exhaustive_set f i = (if i = 0 then None else (f {} orelse exhaustive_set (%A. f A orelse Quickcheck_Exhaustive.exhaustive (%x. if x \<in> A then None else f (insert x A)) (i - 1)) (i - 1)))"
+
+instance ..
+
+end
+
+definition (in term_syntax) "valterm_emptyset = Code_Evaluation.valtermify ({} :: ('a :: typerep) set)"
+definition (in term_syntax) "valtermify_insert x s = Code_Evaluation.valtermify insert {\<cdot>} (x :: ('a :: typerep * _)) {\<cdot>} s"
+
+instantiation set :: (full_exhaustive) full_exhaustive
+begin
+
+fun full_exhaustive_set 
+where
+  "full_exhaustive_set f i = (if i = 0 then None else (f valterm_emptyset orelse full_exhaustive_set (%A. f A orelse Quickcheck_Exhaustive.full_exhaustive (%x. if fst x \<in> fst A then None else f (valtermify_insert x A)) (i - 1)) (i - 1)))"
+
+instance ..
+
+end
+
+hide_const valterm_emptyset valtermify_insert
+
 instantiation "fun" :: ("{equal, exhaustive}", exhaustive) exhaustive
 begin