Copyright | (c) Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Documentation.SBV.Examples.KnuckleDragger.ShefferStroke
Description
Inspired by https://www.philipzucker.com/cody_sheffer/, proving that the axioms of sheffer stroke (i.e., nand in traditional boolean logic), imply it is a boolean algebra.
Synopsis
- class BooleanAlgebra α where
- data BooleanAlgebraProof = BooleanAlgebraProof {
- le_refl :: Proof
- le_trans :: Proof
- lt_iff_le_not_le :: Proof
- le_antisymm :: Proof
- le_sup_left :: Proof
- le_sup_right :: Proof
- sup_le :: Proof
- inf_le_left :: Proof
- inf_le_right :: Proof
- le_inf :: Proof
- le_sup_inf :: Proof
- inf_compl_le_bot :: Proof
- top_le_sup_compl :: Proof
- le_top :: Proof
- bot_le :: Proof
- sdiff_eq :: Proof
- himp_eq :: Proof
- data Stroke
- type SStroke = SBV Stroke
- (⏐) :: SStroke -> SStroke -> SStroke
- ﬧﬧ :: BooleanAlgebra a => a -> a
- sheffer1 :: KD Proof
- sheffer2 :: KD Proof
- sheffer3 :: KD Proof
- shefferBooleanAlgebra :: IO BooleanAlgebraProof
Generalized Boolean Algebras
class BooleanAlgebra α where Source #
Capture what it means to be a boolean algebra. We follow Lean's definition, as much as we can: https://leanprover-community.github.io/mathlib_docs/order/boolean_algebra.html. Since there's no way in Haskell to capture properties together with a class, we'll represent the properties separately.
Methods
(⨆) :: α -> α -> α infixl 6 Source #
(⨅) :: α -> α -> α infixl 7 Source #
(≤) :: α -> α -> SBool infix 4 Source #
Instances
BooleanAlgebra SStroke Source # | The boolean algebra of the sheffer stroke. |
Defined in Documentation.SBV.Examples.KnuckleDragger.ShefferStroke Methods ﬧ :: SStroke -> SStroke Source # (⨆) :: SStroke -> SStroke -> SStroke Source # (⨅) :: SStroke -> SStroke -> SStroke Source # (≤) :: SStroke -> SStroke -> SBool Source # (<) :: SStroke -> SStroke -> SBool Source # (\\) :: SStroke -> SStroke -> SStroke Source # |
data BooleanAlgebraProof Source #
Proofs needed for a boolean-algebra. Again, we follow Lean's definition here. Since we cannot put these in the class definition above, we will keep them in a simple data-structure.
Constructors
BooleanAlgebraProof | |
Fields
|
Instances
Show BooleanAlgebraProof Source # | A somewhat prettier printer for a BooleanAlgebra proof |
Defined in Documentation.SBV.Examples.KnuckleDragger.ShefferStroke Methods showsPrec :: Int -> BooleanAlgebraProof -> ShowS # show :: BooleanAlgebraProof -> String # showList :: [BooleanAlgebraProof] -> ShowS # |
The sheffer stroke
The abstract type for the domain.
Instances
ﬧﬧ :: BooleanAlgebra a => a -> a Source #
Double-negation
Sheffer's stroke defines a boolean algebra
shefferBooleanAlgebra :: IO BooleanAlgebraProof Source #
Prove that Sheffer stroke axioms imply it is a boolean algebra. We have:
>>>
shefferBooleanAlgebra
Axiom: ﬧﬧa == a Axiom: a ⏐ (b ⏐ ﬧb) == ﬧa Axiom: ﬧ(a ⏐ (b ⏐ c)) == (ﬧb ⏐ a) ⏐ (ﬧc ⏐ a) Lemma: a | b = b | a Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Step : 7 Q.E.D. Result: Q.E.D. Lemma: a | a′ = b | b′ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Result: Q.E.D. Lemma: a ⊔ b = b ⊔ a Q.E.D. Lemma: a ⊓ b = b ⊓ a Q.E.D. Lemma: a ⊔ ⲳ = a Q.E.D. Lemma: a ⊓ т = a Q.E.D. Lemma: a ⊔ (b ⊓ c) = (a ⊔ b) ⊓ (a ⊔ c) Q.E.D. Lemma: a ⊓ (b ⊔ c) = (a ⊓ b) ⊔ (a ⊓ c) Q.E.D. Lemma: a ⊔ aᶜ = т Q.E.D. Lemma: a ⊓ aᶜ = ⲳ Q.E.D. Lemma: a ⊔ т = т Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Result: Q.E.D. Lemma: a ⊓ ⲳ = ⲳ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Result: Q.E.D. Lemma: a ⊔ (a ⊓ b) = a Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Result: Q.E.D. Lemma: a ⊓ (a ⊔ b) = a Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Result: Q.E.D. Lemma: a ⊓ a = a Step : 1 Q.E.D. Step : 2 Q.E.D. Result: Q.E.D. Lemma: a ⊔ a' = т → a ⊓ a' = ⲳ → a' = aᶜ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Asms : 6 Q.E.D. Step : 6 Q.E.D. Step : 7 Q.E.D. Step : 8 Q.E.D. Step : 9 Q.E.D. Asms : 10 Q.E.D. Step : 10 Q.E.D. Step : 11 Q.E.D. Result: Q.E.D. Lemma: aᶜᶜ = a Q.E.D. Lemma: aᶜ = bᶜ → a = b Q.E.D. Lemma: a ⊔ bᶜ = т → a ⊓ bᶜ = ⲳ → a = b Q.E.D. Lemma: a ⊔ (aᶜ ⊔ b) = т Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Result: Q.E.D. Lemma: a ⊓ (aᶜ ⊓ b) = ⲳ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Result: Q.E.D. Lemma: (a ⊔ b)ᶜ = aᶜ ⊓ bᶜ Q.E.D. Lemma: (a ⨅ b)ᶜ = aᶜ ⨆ bᶜ Q.E.D. Lemma: (a ⊔ (b ⊔ c)) ⊔ aᶜ = т Q.E.D. Lemma: b ⊓ (a ⊔ (b ⊔ c)) = b Q.E.D. Lemma: b ⊔ (a ⊓ (b ⊓ c)) = b Q.E.D. Lemma: (a ⊔ (b ⊔ c)) ⊔ bᶜ = т Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Step : 7 Q.E.D. Step : 8 Q.E.D. Step : 9 Q.E.D. Result: Q.E.D. Lemma: (a ⊔ (b ⊔ c)) ⊔ cᶜ = т Q.E.D. Lemma: (a ⊔ b ⊔ c)ᶜ ⊓ a = ⲳ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Step : 7 Q.E.D. Step : 8 Q.E.D. Step : 9 Q.E.D. Result: Q.E.D. Lemma: (a ⊔ b ⊔ c)ᶜ ⊓ b = ⲳ Q.E.D. Lemma: (a ⊔ b ⊔ c)ᶜ ⊓ c = ⲳ Q.E.D. Lemma: (a ⊔ (b ⊔ c)) ⊔ ((a ⊔ b) ⊔ c)ᶜ = т Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Step : 7 Q.E.D. Step : 8 Q.E.D. Result: Q.E.D. Lemma: (a ⊔ (b ⊔ c)) ⊓ ((a ⊔ b) ⊔ c)ᶜ = ⲳ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Step : 4 Q.E.D. Step : 5 Q.E.D. Step : 6 Q.E.D. Step : 7 Q.E.D. Step : 8 Q.E.D. Step : 9 Q.E.D. Step : 10 Q.E.D. Step : 11 Q.E.D. Step : 12 Q.E.D. Result: Q.E.D. Lemma: a ⊔ (b ⊔ c) = (a ⊔ b) ⊔ c Q.E.D. Lemma: a ⊓ (b ⊓ c) = (a ⊓ b) ⊓ c Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Result: Q.E.D. Lemma: a ≤ b → b ≤ a → a = b Asms : 1 Q.E.D. Step : 1 Q.E.D. Step : 2 Q.E.D. Asms : 3 Q.E.D. Step : 3 Q.E.D. Result: Q.E.D. Lemma: a ≤ a Q.E.D. Lemma: a ≤ b → b ≤ c → a ≤ c Asms : 1 Q.E.D. Step : 1 Q.E.D. Asms : 2 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Asms : 4 Q.E.D. Step : 4 Q.E.D. Result: Q.E.D. Lemma: a < b ↔ a ≤ b ∧ ¬b ≤ a Q.E.D. Lemma: a ≤ a ⊔ b Q.E.D. Lemma: b ≤ a ⊔ b Q.E.D. Lemma: a ≤ c → b ≤ c → a ⊔ b ≤ c Asms : 1 Q.E.D. Step : 1 Q.E.D. Step : 2 Q.E.D. Result: Q.E.D. Lemma: a ⊓ b ≤ a Q.E.D. Lemma: a ⊓ b ≤ b Q.E.D. Lemma: a ≤ b → a ≤ c → a ≤ b ⊓ c Asms : 1 Q.E.D. Step : 1 Q.E.D. Asms : 2 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Result: Q.E.D. Lemma: (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ y ⊓ z Q.E.D. Lemma: x ⊓ xᶜ ≤ ⊥ Q.E.D. Lemma: ⊤ ≤ x ⊔ xᶜ Q.E.D. Lemma: a ≤ ⊤ Step : 1 Q.E.D. Step : 2 Q.E.D. Step : 3 Q.E.D. Result: Q.E.D. Lemma: ⊥ ≤ a Step : 1 Q.E.D. Step : 2 Q.E.D. Result: Q.E.D. Lemma: x \ y = x ⊓ yᶜ Q.E.D. Lemma: x ⇨ y = y ⊔ xᶜ Q.E.D. BooleanAlgebraProof { le_refl : [Proven] a ≤ a le_trans : [Proven] a ≤ b → b ≤ c → a ≤ c lt_iff_le_not_le: [Proven] a < b ↔ a ≤ b ∧ ¬b ≤ a le_antisymm : [Proven] a ≤ b → b ≤ a → a = b le_sup_left : [Proven] a ≤ a ⊔ b le_sup_right : [Proven] b ≤ a ⊔ b sup_le : [Proven] a ≤ c → b ≤ c → a ⊔ b ≤ c inf_le_left : [Proven] a ⊓ b ≤ a inf_le_right : [Proven] a ⊓ b ≤ b le_inf : [Proven] a ≤ b → a ≤ c → a ≤ b ⊓ c le_sup_inf : [Proven] (x ⊔ y) ⊓ (x ⊔ z) ≤ x ⊔ y ⊓ z inf_compl_le_bot: [Proven] x ⊓ xᶜ ≤ ⊥ top_le_sup_compl: [Proven] ⊤ ≤ x ⊔ xᶜ le_top : [Proven] a ≤ ⊤ bot_le : [Proven] ⊥ ≤ a sdiff_eq : [Proven] x \ y = x ⊓ yᶜ himp_eq : [Proven] x ⇨ y = y ⊔ xᶜ }