Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Lattices & algebras
Synopsis
- type Lattice a = (Eq a, Semilattice L a, Extremal L a, Semilattice R a, Extremal R a)
- type Semilattice k a = Connection k (a, a) a
- type HeytingL = Heyting L
- (\\) :: Heyting L a => a -> a -> a
- non :: Heyting L a => a -> a
- equiv :: Heyting L a => a -> a -> a
- boundary :: Heyting L a => a -> a
- booleanL :: Heyting L a => Conn L a a
- heytingL :: Lattice a => (a -> a -> a) -> a -> Conn L a a
- type HeytingR = Heyting R
- (//) :: Heyting R a => a -> a -> a
- neg :: Heyting R a => a -> a
- iff :: Heyting R a => a -> a -> a
- middle :: Heyting R a => a -> a
- booleanR :: Heyting R a => Conn R a a
- heytingR :: Lattice a => (a -> a -> a) -> a -> Conn R a a
- (\/) :: Semilattice L a => a -> a -> a
- (/\) :: Semilattice R a => a -> a -> a
- glb :: Triple (a, a) a => a -> a -> a -> a
- lub :: Triple (a, a) a => a -> a -> a -> a
- true :: Lattice a => a
- false :: Lattice a => a
- class Lattice a => Heyting k a where
- type Biheyting a = (HeytingL a, HeytingR a)
- class Biheyting a => Symmetric a where
- symmetricL :: Symmetric a => a -> ConnL a a
- symmetricR :: Symmetric a => a -> ConnR a a
- class Symmetric a => Boolean a where
Types
type Semilattice k a = Connection k (a, a) a Source #
Semilattices.
A complete is a partially ordered set in which every two elements have a unique join (least upper bound or supremum) and a unique meet (greatest lower bound or infimum).
These operations may in turn be defined by the lower and upper adjoints to the unique function a -> (a, a).
Associativity
x\/
(y\/
z) = (x\/
y)\/
z x/\
(y/\
z) = (x/\
y)/\
z
Commutativity
x\/
y = y\/
x x/\
y = y/\
x
Idempotency
x\/
x = x x/\
x = x
Absorption
(x\/
y)/\
y = y (x/\
y)\/
y = y
See Absorption.
Note that distributivity is _not_ a requirement for a complete. However when a is distributive we have;
glb
x y z =lub
x y z
HeytingL
(\\) :: Heyting L a => a -> a -> a infixl 8 Source #
Logical co-implication:
\( a \Rightarrow b = \wedge \{x \mid a \leq b \vee x \} \)
Laws:
x \\ y <= z <=> x <= y \/ z x \\ y >= (x /\ z) \\ y x >= y => x \\ z >= y \\ z x >= x \\ y x >= y <=> y \\ x = false x \\ (y /\ z) >= x \\ y z \\ (x \/ y) = z \\ x \\ y (y \/ z) \\ x = y \\ x \/ z \\ x x \/ y \\ x = x \/ y
>>>
False \\ False
False>>>
False \\ True
False>>>
True \\ False
True>>>
True \\ True
False
For many collections (e.g. Set
) \\
coincides with the native \\
operator.
>>>
:set -XOverloadedLists
>>>
[GT,EQ] Set.\\ [LT]
fromList [EQ,GT]>>>
[GT,EQ] \\ [LT]
fromList [EQ,GT]
non :: Heyting L a => a -> a Source #
Logical co-negation.
non
x =true
\\
x
Laws:
non false = true non true = false x >= non (non x) non (x /\ y) >= non x non (y \\ x) = non (non x) \/ non y non (x /\ y) = non x \/ non y x \/ non x = true non (non (non x)) = non x non (non (x /\ non x)) = false
boundary :: Heyting L a => a -> a Source #
The co-Heyting boundary operator.
x = boundary x \/ (non . non) x boundary (x /\ y) = (boundary x /\ y) \/ (x /\ boundary y) -- (Leibniz rule) boundary (x \/ y) \/ boundary (x /\ y) = boundary x \/ boundary y
booleanL :: Heyting L a => Conn L a a Source #
An adjunction between a co-Heyting algebra and its Boolean sub-algebra.
Double negation is a join-preserving comonad.
heytingL :: Lattice a => (a -> a -> a) -> a -> Conn L a a Source #
Default constructor for a co-Heyting algebra.
HeytingR
(//) :: Heyting R a => a -> a -> a infixr 8 Source #
Logical implication:
\( a \Rightarrow b = \vee \{x \mid x \wedge a \leq b \} \)
Laws:
x /\ y <= z <=> x <= y // z x // y <= x // (y \/ z) x <= y => z // x <= z // y y <= x // (x /\ y) x <= y <=> x // y = true (x \/ z) // y <= x // y (x /\ y) // z = x // y // z x // (y /\ z) = x // y /\ x // z x /\ x // y = x /\ y
>>>
False // False
True>>>
False // True
True>>>
True // False
False>>>
True // True
True
neg :: Heyting R a => a -> a Source #
Logical negation.
neg
x = x//
false
Laws:
neg false = true neg true = false x <= neg (neg x) neg (x \/ y) <= neg x neg (x // y) = neg (neg x) /\ neg y neg (x \/ y) = neg x /\ neg y x /\ neg x = false neg (neg (neg x)) = neg x neg (neg (x \/ neg x)) = true
Some logics may in addition obey De Morgan conditions.
iff :: Heyting R a => a -> a -> a Source #
Intuitionistic equivalence.
When a=Bool this is 'if-and-only-if'.
booleanR :: Heyting R a => Conn R a a Source #
An adjunction between a Heyting algebra and its Boolean sub-algebra.
Double negation is a meet-preserving monad.
heytingR :: Lattice a => (a -> a -> a) -> a -> Conn R a a Source #
Default constructor for a Heyting algebra.
Heyting
(\/) :: Semilattice L a => a -> a -> a infixr 5 Source #
Semigroup operation on a join-semilattice.
(\/) = curry $ lowerL forked
(/\) :: Semilattice R a => a -> a -> a infixr 6 Source #
Semigroup operation on a meet-semilattice.
(/\) = curry $ upperR forked
glb :: Triple (a, a) a => a -> a -> a -> a Source #
Greatest lower bound operator.
glb x x y = x glb x y z = glb z x y glb x x y = x glb x y z = glb x z y glb (glb x w y) w z = glb x w (glb y w z)
>>>
glb 1.0 9.0 7.0
7.0>>>
glb 1.0 9.0 (0.0 / 0.0)
9.0>>>
glb (fromList [1..3]) (fromList [3..5]) (fromList [5..7]) :: Set Int
fromList [3,5]
lub :: Triple (a, a) a => a -> a -> a -> a Source #
Least upper bound operator.
The order dual of glb
.
>>>
lub 1.0 9.0 7.0
7.0>>>
lub 1.0 9.0 (0.0 / 0.0)
1.0
true :: Lattice a => a Source #
The unique top element of a bounded lattice
x /\ true = x x \/ true = true
false :: Lattice a => a Source #
The unique bottom element of a bounded lattice
x /\ false = false x \/ false = x
class Lattice a => Heyting k a where Source #
Heyting algebras
A Heyting algebra is a bounded, distributive complete equipped with an implication operation.
- The complete of closed subsets of a trueological space is the primordial example of a HeytingL (co-Heyting) algebra.
- The dual complete of open subsets of a trueological space is likewise the primordial example of a HeytingR algebra.
Heyting 'L:
Co-implication to a is the lower adjoint of disjunction with a:
x \\ a <= y <=> x <= y \/ a
Note that co-Heyting algebras needn't obey the law of non-contradiction:
EQ /\ non EQ = EQ /\ GT \\ EQ = EQ /\ GT = EQ /= LT
See https://ncatlab.org/nlab/show/co-Heyting+algebra
Heyting 'R:
Implication from a is the upper adjoint of conjunction with a:
x <= a // y <=> a /\ x <= y
Similarly, Heyting algebras needn't obey the law of the excluded middle:
EQ \/ neg EQ = EQ \/ EQ // LT = EQ \/ LT = EQ /= GT
heyting :: a -> Conn k a a Source #
The defining connection of a (co-)Heyting algebra.
heyting @'L x = ConnL (\\ x) (\/ x) heyting @'R x = ConnR (x /\) (x //)
Instances
Symmetric
class Biheyting a => Symmetric a where Source #
Symmetric Heyting algebras
A symmetric Heyting algebra is a De Morgan bi-Heyting algebra with an idempotent, antitone negation operator.
Laws:
x <= y => not y <= not x -- antitone not . not = id -- idempotence x \\ y = not (not y // not x) x // y = not (not y \\ not x)
and:
converseR x <= converseL x
with equality occurring iff a is a Boolean
algebra.
Symmetric negation.
not . not = id neg . neg = converseR . converseL non . non = converseL . converseR neg . non = converseR . converseR non . neg = converseL . converseL
neg = converseR . not = not . converseL non = not . converseR = converseL . not x \\ y = not (not y // not x) x // y = not (not y \\ not x)
xor :: a -> a -> a infixl 4 Source #
Exclusive or.
xor x y = (x \/ y) /\ (not x \/ not y)
Left converse operator.
Right converse operator.
Instances
Symmetric Bool Source # | |
Symmetric Ordering Source # | |
Symmetric () Source # | |
Symmetric IntSet Source # | |
Finite a => Symmetric (Predicate a) Source # | |
(Finite a, Symmetric a) => Symmetric (Endo a) Source # | |
(Total a, Finite a) => Symmetric (Set a) Source # | |
(Finite a, Symmetric b) => Symmetric (a -> b) Source # | |
(Symmetric a, Symmetric b) => Symmetric (a, b) Source # | |
(Finite a, Symmetric b) => Symmetric (Op b a) Source # | |
symmetricL :: Symmetric a => a -> ConnL a a Source #
Default constructor for a co-Heyting algebra.
symmetricR :: Symmetric a => a -> ConnR a a Source #
Default constructor for a Heyting algebra.
Boolean
class Symmetric a => Boolean a where Source #
Boolean algebras.
Boolean algebras are symmetric Heyting algebras that satisfy both the law of excluded middle and the law of law of non-contradiction:
x \/ neg x = true x /\ non x = false
If a is Boolean we also have:
non = not = neg
Nothing
Instances
Boolean Bool Source # | |
Boolean () Source # | |
Defined in Data.Lattice | |
Boolean IntSet Source # | |
Finite a => Boolean (Predicate a) Source # | |
(Finite a, Boolean a) => Boolean (Endo a) Source # | |
(Total a, Finite a) => Boolean (Set a) Source # | |
(Finite a, Boolean b) => Boolean (a -> b) Source # | |
Defined in Data.Lattice | |
(Boolean a, Boolean b) => Boolean (a, b) Source # | |
Defined in Data.Lattice | |
(Finite a, Boolean b) => Boolean (Op b a) Source # | |