-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckSet.hs
More file actions
57 lines (43 loc) · 1.74 KB
/
CheckSet.hs
File metadata and controls
57 lines (43 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
module CheckSet where
import Test.QuickCheck
import Set
-- Properties that should be tautologies
singleton_contains x = x `member` singleton x
empty_not_contains x = x `notMember` empty
complement_opposite (Blind s) = forAll arbitrary $ \x ->
x `notMember` intersection s (complement s)
union_subsumes (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `member` union s t ==> x `member` s || x `member` t
union_excludes (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `notMember` s && x `notMember` t ==> x `notMember` union s t
intersection_includes (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `member` s && x `member` t ==> x `member` intersection s t
intersection_excludes (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `notMember` intersection s t ==> x `notMember` s || x `notMember` t
difference_excludes (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `member` t ==> x `notMember` difference s t
difference_includes (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `member` difference s t ==> x `member` s
difference_union (Blind s) (Blind t) = forAll arbitrary $ \x ->
x `notMember` union s t ==> x `notMember` difference s t
unions_equals (Blind ss) = forAll arbitrary $ \x ->
(x `member` unions ss) == any (x `member`) ss
main = do
putStrLn "singleton"
quickCheck singleton_contains
putStrLn "empty"
quickCheck empty_not_contains
putStrLn "complement"
quickCheck complement_opposite
putStrLn "union"
quickCheck union_subsumes
quickCheck union_excludes
putStrLn "intersection"
quickCheck intersection_includes
quickCheck intersection_excludes
putStrLn "difference"
quickCheck difference_includes
quickCheck difference_excludes
quickCheck difference_union
putStrLn "unions"
quickCheck unions_equals