aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/lux/abstract/equivalence.lux
blob: 21b425f3d2065c0cc537270c62203f691c7e7c2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(.using
 [library
  [lux "*"
   ["_" test {"+" Test}]
   [abstract
    [monad {"+" do}]]
   [data
    ["[0]" bit ("[1]#[0]" equivalence)]]
   [math
    ["[0]" random {"+" Random}]]]]
 [\\library
  ["[0]" / {"+" Equivalence}]])

(def: .public (spec (open "/#[0]") random)
  (All (_ a) (-> (Equivalence a) (Random a) Test))
  (do random.monad
    [left random
     right random]
    (<| (_.for [/.Equivalence])
        (all _.and
             (_.property "Reflexivity"
               (/#= left left))
             (_.property "Symmetry"
               (bit#= (/#= left right) (/#= right left)))))))