aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/library/lux/math/logic/continuous.lux
blob: 195601894740acdf3167a3458880f8d670759e5a (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
... https://en.wikipedia.org/wiki/Many-valued_logic
(.using
 [library
  [lux (.except false true or and not)
   [abstract
    [monoid (.only Monoid)]]
   [math
    [number
     ["/" rev (.open: "[1]#[0]" interval)]]]]])

(def: .public false Rev /#bottom)
(def: .public true  Rev /#top)

(with_template [<name> <chooser> <monoid> <identity>]
  [(def: .public <name>
     (-> Rev Rev Rev)
     <chooser>)

   (def: .public <monoid>
     (Monoid Rev)
     (implementation
      (def: identity <identity>)
      (def: composite <name>)))]

  [or  /.max disjunction ..false]
  [and /.min conjunction ..true]
  )

(def: .public (not input)
  (-> Rev Rev)
  (/.- input ..true))

(def: .public (implies consequent antecedent)
  (-> Rev Rev Rev)
  (or (not antecedent)
      consequent))

(def: .public (= left right)
  (-> Rev Rev Rev)
  (and (or (not left) right)
       (or left (not right))))