2 {-# LANGUAGE PolyKinds #-}
5 module Logic.Theory.Eq (
12 import Data.Bool (Bool)
13 import Data.Bool qualified as Bool
14 import Data.Either (Either (..))
15 import Data.Eq qualified as Eq
18 data (==) x y = EqualAxiom
19 data (/=) x y = NotEqualAxiom
21 type role (==) nominal nominal
22 type role (/=) nominal nominal
24 instance Axiom (Associative (==) x y z)
25 instance Axiom (Associative (/=) x y z)
26 instance Axiom (Commutative (==) x y)
27 instance Axiom (Commutative (/=) x y)
29 (==) :: Eq.Eq a => x ::: a -> y ::: a -> (x == y) ::: Bool
30 (==) (Named x) (Named y) = EqualAxiom ... x Eq.== y
33 (/=) :: Eq.Eq a => x ::: a -> y ::: a -> (x /= y) ::: Bool
34 (/=) (Named x) (Named y) = NotEqualAxiom ... x Eq./= y
40 instance Provable ((x == y) ::: Bool) where
41 type ProofOf ((x == y) ::: Bool) = Either (Proof (x /= y)) (Proof (x == y))
42 prove (Named b) = case b of
43 Bool.False -> Left (proven NotEqualAxiom)
44 Bool.True -> Right (proven EqualAxiom)
46 instance Provable ((x /= y) ::: Bool) where
47 type ProofOf ((x /= y) ::: Bool) = Either (Proof (x == y)) (Proof (x /= y))
48 prove (Named b) = case b of
49 Bool.False -> Left (proven EqualAxiom)
50 Bool.True -> Right (proven NotEqualAxiom)