-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathProperties.fs
109 lines (82 loc) · 2.32 KB
/
Properties.fs
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
module Properties
open FsCheck
open FsCheck.Xunit
[<Property>]
let ``Idepotent Property`` i =
idempotent abs i
[<Property>]
let ``PointSymmatric Property`` i =
pointSymmetric (fun x -> pown x 3) i
[<Property>]
let ``ReflectionSymmetric Property`` i =
reflectionSymmetric (fun x -> pown x 2) i
[<Property>]
let ``MonotonicIncreading Property`` i =
monotonicIncreasing floor i
[<Property>]
let ``MonotonicIncreading' Property`` i =
monotonicIncreasing' ((+) 1) i
[<Property>]
let ``MonotonicDecreasing Property`` i =
monotonicDecreasing (negate >> float >> floor) i
[<Property>]
let ``MonotonicDecreasing' Property`` x y =
monotonicDecreasing' ((-) 1) x y
[<Property>]
let ``Involutary Property`` i =
involutory negate i
[<Property>]
let ``Inverts Property`` i =
inverts (fun x -> x - 2) ((+) 2) i
[<Property>]
let ``Commutative Property`` x y =
commutative' (+) x y
[<Property>]
let ``Map Reduce Commutative Property`` xs =
xs <> [] ==> lazy
commutative (List.take 1) (List.map ((+) 1)) xs
[<Property>]
let ``Associative Property`` x y z =
associative (+) x y z
[<Property>]
let ``DistributesLeftOver Property`` x y z =
distributesLeftOver (*) (+) x y z
[<Property>]
let ``DistributesRightOver Property`` x y z =
distributesRightOver (*) (+) x y z
[<Property>]
let ``DistributesOver Property`` x y z =
distributesOver (*) (+) x y z
let append1 xs = 1 :: xs
[<Property>]
let ``Inflating Property`` i =
inflating append1 i
[<Property>]
let ``Inflating' Property`` i =
inflating' append1 i
[<Property>]
let ``Deflating Property`` (xs : int list) =
List.length xs > 1 ==> lazy
deflating List.tail xs
[<Property>]
let ``Deflating' Property`` (xs : string list) =
List.length xs > 1 ==> lazy
deflating List.tail xs
[<Property>]
let ``Cycles Property`` x =
let g x = 1 - x
cycles g 2 x
[<Property>]
let ``InvariatesOver Property`` (xs : int list) =
List.rev |> invariates List.length <| xs
[<Property>]
let ``FixedBy Property`` x y = fixedBy (*) 0 x y
[<Property>]
let ``Endomorphism Property`` i = endomorphism ((*) 7) abs i
[<Property>]
let ``Endomorphism2 Property`` x y =
endomorphism2 (fun x -> pown x 2) (*) x y
[<Property>]
let ``Endomorphism3 Property`` x y z =
let (++) x y z = x + y + z
endomorphism3 negate (++) x y z