-
Notifications
You must be signed in to change notification settings - Fork 91
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 Lattices, which I think would be fine in another library.
I propose:
- Split out
HeytingAlgebra - Make
Boundeda subclass ofOrd - Copy the
Boundedmembers 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 bThis allows us to interpret the operations of Boolean algebra in a variety of settings:
Booleanitself- Tuples
- Power sets of
Finitetypes - The interval
[0, 1]withminandmaxoperations (Heyting but not Boolean) - Three-valued logic (Heyting but not Boolean)
- In general, we can create a
HeytingAlgebrafrom anyBoundedtype 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