Closed
Description
We discussed modifying the BooleanAlgebra
hierarchy on IRC.
I'd like to support some simple overloading of the boolean operations, while not splitting things into a full hierarchy of Lattice
s, which I think would be fine in another library.
I propose:
- Split out
HeytingAlgebra
- Make
Bounded
a subclass ofOrd
- Copy the
Bounded
members intoHeytingAlgebra
as follows:
-- See https://en.wikipedia.org/wiki/Heyting_algebra#Bounded_lattice_with_an_implication_operation
--
-- a ==> a = tr
-- a && (a ==> b) = a ==> b
-- b && (a ==> b) = b
-- a ==> (b && c) = (a ==>b) && (a ==> c)
--
-- plus the laws for a bounded lattice
--
-- plus `not a = a ==> fa`
class HeytingAlgebra h where
tr :: h
fa :: h
implies :: h -> h -> h
conj :: h -> h -> h
disj :: h -> h -> h
not :: h -> h
infix ==> as implies -- for the purposes of writing out the laws above
infix && as conj
infix || as disj
-- adds the law of the excluded middle
class (HeytingAlgebra b) <= BooleanAlgebra b
This allows us to interpret the operations of Boolean algebra in a variety of settings:
Boolean
itself- Tuples
- Power sets of
Finite
types - The interval
[0, 1]
withmin
andmax
operations (Heyting but not Boolean) - Three-valued logic (Heyting but not Boolean)
- In general, we can create a
HeytingAlgebra
from anyBounded
type with an order-reversing involution.
etc.
The tricky bit is that there is obviously an interaction with the Ord
hierarchy here, but I'm trying to hide it in order to get something useable without refining the hierarchy too much, hence the formulation of HeytingAlgebra
in terms of implication and conjugation, instead of the underlying order.
Metadata
Metadata
Assignees
Labels
No labels