Skip to content

Break up BooleanAlgebra #62

Closed
Closed
@paf31

Description

@paf31

cc @freebroccolo

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 Bounded a subclass of Ord
  • Copy the Bounded members into HeytingAlgebra

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] with min and max operations (Heyting but not Boolean)
  • Three-valued logic (Heyting but not Boolean)
  • In general, we can create a HeytingAlgebra from any Bounded 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions