QJMKKLU2UF45IRLVJHSQQ6PHTLHHX34Z4ROJGQLBRQTMQ54D6G5AC 4L2YWRMCKZ56NCRC44XVDZQ5BEKHX26C4GQZ5TIL35Y33VKFTBCQC XNPLRKJ4ZK442XNJ5BC7TO3DKXGXFSOSGBZBPW5HZZDHY3IVD6FAC CO3C7GSZ2X62ALXW2EAWDHCRSXCNVKIIHCL47GYZ32OHZER4NLZQC NYMIFK2WBHU4G34QF4GZP63ATL2EQC6PLAQLWZMUTPDGDPQUEKVQC Y25HAVMY4WAD43DQ5PHLHUPDKW7X6DWJVP3VKYVQ3AE25S6ESSXAC 2DQ47UENKWPVS6XYO73Q2KCHTNG6GQVP2CKP24V2OQ4F4T3KAFMAC 4KXMGXQ6PTWVMINMKRCQE7DIJXUYMO7SVNR6AQ243QULY7IZLUYAC GEBWJGHFGLPFE6PGT5D7W3PL57NPMQRPDUK54GTN4344W6QT7DPAC 6D4TYQRJMN6QEKASHJ3ZN3E7TXF5IEQ3G4ATTZZ5AZC56VXMWFZAC RUIGRXTKM6BQ532W7KU3RKDXMRNRGDVGMA2ODMX2D2F3PCLF3GAQC WJJ6PMS6GYR5NIQI6Q6YH6WQSTJ3U56F3KZJOSYHTRAZ5MKIPXAAC QL75BDYCNRAF2NPJP3MJHUPM6JRIGJQWK2OG2NWKBOVZUZ75CHOAC import Builtinimport Algebra.Group.Magmaimport Algebra.Group.Semigroupimport Algebra.Group.Monoidimport Algebra.Lattice.JoinSemilatticeimport Algebra.Lattice.MeetSemilatticeimport Algebra.Relation.Equivalenceimport Algebra.Relation.Preorderimport Algebra.Relation.Orderimport Data.Either%default total---- Values--public exportdata Boolean = False | True---- Relation--data BooleanEquiv : (a, b : Boolean) -> Type whereBothFalse : BooleanEquiv False FalseBothTrue : BooleanEquiv True Truepublic exportUninhabited (BooleanEquiv False True) whereuninhabited BothFalse impossibleuninhabited BothTrue impossiblepublic exportUninhabited (BooleanEquiv True False) whereuninhabited BothFalse impossibleuninhabited BothTrue impossiblepublic exportEquivalence Boolean whereEquiv = BooleanEquivdecEquiv False False = Yes BothFalsedecEquiv True True = Yes BothTruedecEquiv False True = No absurddecEquiv True False = No absurddata BooleanLTE : (a, b : Boolean) -> Type whereFalseLTEAny : BooleanLTE False bTrueLTETrue : BooleanLTE True Truepublic exportUninhabited (BooleanLTE True False) whereuninhabited FalseLTEAny impossibleuninhabited TrueLTETrue impossiblepublic exportPreorder Boolean whereLTE = BooleanLTEdecLTE False _ = Yes FalseLTEAnydecLTE True False = No absurddecLTE True True = Yes TrueLTETrueproofReflexivity False = FalseLTEAnyproofReflexivity True = TrueLTETrueproofTransitivity False False _ FalseLTEAny FalseLTEAny = FalseLTEAnyproofTransitivity False True True FalseLTEAny TrueLTETrue = FalseLTEAnyproofTransitivity True True True TrueLTETrue TrueLTETrue = TrueLTETruedata BooleanLT : (a, b : Boolean) -> Type whereFalseLTTrue : BooleanLT False Truepublic exportUninhabited (BooleanLT False False) whereuninhabited FalseLTTrue impossiblepublic exportUninhabited (BooleanLT True _) whereuninhabited FalseLTTrue impossiblepublic exportOrder Boolean whereLT = BooleanLTdecLT False False = No absurddecLT False True = Yes FalseLTTruedecLT True _ = No absurdproofAntisymetry False False FalseLTEAny FalseLTEAny = BothFalseproofAntisymetry True True TrueLTETrue TrueLTETrue = BothTrueproofLTThenLTE FalseLTTrue = FalseLTEAnyproofLTEThenLTOrEquiv False False FalseLTEAny = Right BothFalseproofLTEThenLTOrEquiv False True FalseLTEAny = Left FalseLTTrueproofLTEThenLTOrEquiv True True TrueLTETrue = Right BothTrue---- Operations--not : Boolean -> Booleannot False = Truenot True = FalseproofNotInvolution : (a : Boolean) -> not (not a) = aproofNotInvolution False = ReflproofNotInvolution True = Reflpublic exportdisj : Boolean -> Boolean -> Booleandisj False False = Falsedisj _ _ = TrueexportproofDisjLeftIdentity : (a : Boolean) -> False `disj` a = aproofDisjLeftIdentity False = ReflproofDisjLeftIdentity True = ReflexportproofDisjRightIdentity : (a : Boolean) -> a `disj` False = aproofDisjRightIdentity False = ReflproofDisjRightIdentity True = ReflexportproofDisjLeftAnnihilation : (a : Boolean) -> True `disj` a = TrueproofDisjLeftAnnihilation False = ReflproofDisjLeftAnnihilation True = ReflexportproofDisjRightAnnihilation : (a : Boolean) -> a `disj` True = TrueproofDisjRightAnnihilation False = ReflproofDisjRightAnnihilation True = ReflexportproofDisjCommutative : (a, b : Boolean) -> a `disj` b = b `disj` aproofDisjCommutative False b =rewrite proofDisjLeftIdentity b inrewrite proofDisjRightIdentity b inReflproofDisjCommutative True b = rewrite proofDisjRightAnnihilation b in Refl
public export[BooleanDisjMagma] Magma Boolean where(<>) = disjpublic export[BooleanDisjCommutativeMagma] CommutativeMagma Boolean using BooleanDisjMagma whereproofCommutative = proofDisjCommutativepublic export[BooleanDisjSemigroup] Semigroup Boolean using BooleanDisjMagma whereproofAssociative False b c =rewrite proofDisjLeftIdentity b inrewrite proofDisjLeftIdentity (b `disj` c) inReflproofAssociative True b c = Reflpublic export[BooleanDisjCommutativeSemigroup] CommutativeSemigroup Boolean using BooleanDisjCommutativeMagma BooleanDisjSemigroup wherepublic export[BooleanDisjMonoid] Monoid Boolean using BooleanDisjSemigroup whereid = FalseproofLeftIdentity = proofDisjLeftIdentityproofRightIdentity = proofDisjRightIdentitypublic export[BooleanDisjCommutativeMonoid] CommutativeMonoid Boolean using BooleanDisjCommutativeSemigroup BooleanDisjMonoid wherepublic exportconj : Boolean -> Boolean -> Booleanconj True True = Trueconj _ _ = FalseexportproofConjLeftIdentity : (a : Boolean) -> True `conj` a = aproofConjLeftIdentity False = ReflproofConjLeftIdentity True = ReflexportproofConjRightIdentity : (a : Boolean) -> a `conj` True = aproofConjRightIdentity False = ReflproofConjRightIdentity True = ReflexportproofConjLeftAnnihilation : (a : Boolean) -> False `conj` a = FalseproofConjLeftAnnihilation False = ReflproofConjLeftAnnihilation True = ReflexportproofConjRightAnnihilation : (a : Boolean) -> a `conj` False = FalseproofConjRightAnnihilation False = ReflproofConjRightAnnihilation True = ReflexportproofConjCommutative : (a, b : Boolean) -> a `conj` b = b `conj` aproofConjCommutative False b = rewrite proofConjRightAnnihilation b in ReflproofConjCommutative True b =rewrite proofConjLeftIdentity b inrewrite proofConjRightIdentity b inReflpublic export[BooleanConjMagma] Magma Boolean where(<>) = conjpublic export[BooleanConjCommutativeMagma] CommutativeMagma Boolean using BooleanConjMagma whereproofCommutative = proofConjCommutativepublic export[BooleanConjSemigroup] Semigroup Boolean using BooleanConjMagma whereproofAssociative False b c = ReflproofAssociative True b c =rewrite proofConjLeftIdentity b inrewrite proofConjLeftIdentity (b `conj` c) inReflpublic export[BooleanConjMonoid] Monoid Boolean using BooleanConjSemigroup whereid = TrueproofLeftIdentity = proofConjLeftIdentityproofRightIdentity = proofConjRightIdentity---- Lattice--public exportMeetSemilattice Boolean where(/\) = conjproofIdempotence False = ReflproofIdempotence True = ReflproofAssociative = proofAssociative @{BooleanConjSemigroup}proofCommutative = proofConjCommutativeproofLowerBound False False = (FalseLTEAny, FalseLTEAny)proofLowerBound False True = (FalseLTEAny, FalseLTEAny)proofLowerBound True False = (FalseLTEAny, FalseLTEAny)proofLowerBound True True = (TrueLTETrue, TrueLTETrue)proofGreatestLowerBound False y z FalseLTEAny FalseLTEAny = FalseLTEAnyproofGreatestLowerBound True True True TrueLTETrue TrueLTETrue = TrueLTETruepublic exportJoinSemilattice Boolean where(\/) = disjproofIdempotence False = ReflproofIdempotence True = ReflproofAssociative = proofAssociative @{BooleanDisjSemigroup}proofCommutative = proofDisjCommutativeproofUpperBound False False = (FalseLTEAny, FalseLTEAny)proofUpperBound False True = (FalseLTEAny, TrueLTETrue)proofUpperBound True False = (TrueLTETrue, FalseLTEAny)proofUpperBound True True = (TrueLTETrue, TrueLTETrue)proofLeastUpperBound False False False FalseLTEAny FalseLTEAny = FalseLTEAnyproofLeastUpperBound True False False FalseLTEAny FalseLTEAny = FalseLTEAnyproofLeastUpperBound True False True FalseLTEAny TrueLTETrue = TrueLTETrueproofLeastUpperBound True True False TrueLTETrue FalseLTEAny = TrueLTETrueproofLeastUpperBound True True True TrueLTETrue TrueLTETrue = TrueLTETrue---- Util--public exportdecToBoolean : Dec t -> BooleandecToBoolean (Yes _) = TruedecToBoolean (No _) = False
import public Data.Boolean.Basicimport public Data.Boolean.Equivalenceimport public Data.Boolean.Orderimport public Data.Boolean.Groupimport public Data.Boolean.Lattice
module Data.Boolean.Orderimport Builtinimport Algebra.Relation.Equivalenceimport Algebra.Relation.Preorderimport Algebra.Relation.Orderimport public Data.Boolean.Basicimport public Data.Boolean.Equivalence%default totalpublic exportdata BooleanLTE : (a, b : Boolean) -> Type whereFalseLTEAny : BooleanLTE False bTrueLTETrue : BooleanLTE True Truepublic exportUninhabited (BooleanLTE True False) whereuninhabited FalseLTEAny impossibleuninhabited TrueLTETrue impossiblepublic exportPreorder Boolean whereLTE = BooleanLTEdecLTE False _ = Yes FalseLTEAnydecLTE True False = No absurddecLTE True True = Yes TrueLTETrueproofReflexivity False = FalseLTEAnyproofReflexivity True = TrueLTETrueproofTransitivity False False _ FalseLTEAny FalseLTEAny = FalseLTEAnyproofTransitivity False True True FalseLTEAny TrueLTETrue = FalseLTEAnyproofTransitivity True True True TrueLTETrue TrueLTETrue = TrueLTETruedata BooleanLT : (a, b : Boolean) -> Type whereFalseLTTrue : BooleanLT False Truepublic exportUninhabited (BooleanLT False False) whereuninhabited FalseLTTrue impossiblepublic exportUninhabited (BooleanLT True _) whereuninhabited FalseLTTrue impossiblepublic exportOrder Boolean whereLT = BooleanLTdecLT False False = No absurddecLT False True = Yes FalseLTTruedecLT True _ = No absurdproofAntisymetry False False FalseLTEAny FalseLTEAny = BothFalseproofAntisymetry True True TrueLTETrue TrueLTETrue = BothTrueproofLTThenLTE FalseLTTrue = FalseLTEAnyproofLTEThenLTOrEquiv False False FalseLTEAny = Right BothFalseproofLTEThenLTOrEquiv False True FalseLTEAny = Left FalseLTTrueproofLTEThenLTOrEquiv True True TrueLTETrue = Right BothTrue
module Data.Boolean.Latticeimport Builtinimport Algebra.Group.Magmaimport Algebra.Group.Semigroupimport Algebra.Lattice.MeetSemilatticeimport Algebra.Lattice.JoinSemilatticeimport Algebra.Relation.Preorderimport Algebra.Relation.Orderimport public Data.Boolean.Basicimport public Data.Boolean.Orderimport public Data.Boolean.Group%default totalpublic exportJoinSemilattice Boolean where(\/) = disjproofIdempotence False = ReflproofIdempotence True = ReflproofAssociative = proofAssociative @{BooleanDisjSemigroup}proofCommutative = proofDisjCommutativeproofUpperBound False False = (FalseLTEAny, FalseLTEAny)proofUpperBound False True = (FalseLTEAny, TrueLTETrue)proofUpperBound True False = (TrueLTETrue, FalseLTEAny)proofUpperBound True True = (TrueLTETrue, TrueLTETrue)proofLeastUpperBound False False False FalseLTEAny FalseLTEAny = FalseLTEAnyproofLeastUpperBound True False False FalseLTEAny FalseLTEAny = FalseLTEAnyproofLeastUpperBound True False True FalseLTEAny TrueLTETrue = TrueLTETrueproofLeastUpperBound True True False TrueLTETrue FalseLTEAny = TrueLTETrueproofLeastUpperBound True True True TrueLTETrue TrueLTETrue = TrueLTETruepublic exportMeetSemilattice Boolean where(/\) = conjproofIdempotence False = ReflproofIdempotence True = ReflproofAssociative = proofAssociative @{BooleanConjSemigroup}proofCommutative = proofConjCommutativeproofLowerBound False False = (FalseLTEAny, FalseLTEAny)proofLowerBound False True = (FalseLTEAny, FalseLTEAny)proofLowerBound True False = (FalseLTEAny, FalseLTEAny)proofLowerBound True True = (TrueLTETrue, TrueLTETrue)proofGreatestLowerBound False y z FalseLTEAny FalseLTEAny = FalseLTEAnyproofGreatestLowerBound True True True TrueLTETrue TrueLTETrue = TrueLTETrue
module Data.Boolean.Groupimport Builtinimport Algebra.Group.Magmaimport Algebra.Group.Semigroupimport Algebra.Group.Monoidimport public Data.Boolean.Basic%default totalpublic export[BooleanDisjMagma] Magma Boolean where(<>) = disjpublic export[BooleanDisjCommutativeMagma] CommutativeMagma Boolean using BooleanDisjMagma whereproofCommutative = proofDisjCommutativepublic export[BooleanDisjSemigroup] Semigroup Boolean using BooleanDisjMagma whereproofAssociative False b c =rewrite proofDisjLeftIdentity b inrewrite proofDisjLeftIdentity (b `disj` c) inReflproofAssociative True b c = Reflpublic export[BooleanDisjCommutativeSemigroup] CommutativeSemigroup Boolean using BooleanDisjCommutativeMagma BooleanDisjSemigroup wherepublic export[BooleanDisjMonoid] Monoid Boolean using BooleanDisjSemigroup whereid = FalseproofLeftIdentity = proofDisjLeftIdentityproofRightIdentity = proofDisjRightIdentitypublic export[BooleanDisjCommutativeMonoid] CommutativeMonoid Boolean using BooleanDisjCommutativeSemigroup BooleanDisjMonoid wherepublic export[BooleanConjMagma] Magma Boolean where(<>) = conjpublic export[BooleanConjCommutativeMagma] CommutativeMagma Boolean using BooleanConjMagma whereproofCommutative = proofConjCommutativepublic export[BooleanConjSemigroup] Semigroup Boolean using BooleanConjMagma whereproofAssociative False b c = ReflproofAssociative True b c =rewrite proofConjLeftIdentity b inrewrite proofConjLeftIdentity (b `conj` c) inReflpublic export[BooleanConjMonoid] Monoid Boolean using BooleanConjSemigroup whereid = TrueproofLeftIdentity = proofConjLeftIdentityproofRightIdentity = proofConjRightIdentity
module Data.Boolean.Equivalenceimport Builtinimport Algebra.Relation.Equivalenceimport public Data.Boolean.Basic%default totalpublic exportdata BooleanEquiv : (a, b : Boolean) -> Type whereBothFalse : BooleanEquiv False FalseBothTrue : BooleanEquiv True Truepublic exportUninhabited (BooleanEquiv False True) whereuninhabited BothFalse impossibleuninhabited BothTrue impossiblepublic exportUninhabited (BooleanEquiv True False) whereuninhabited BothFalse impossibleuninhabited BothTrue impossiblepublic exportEquivalence Boolean whereEquiv = BooleanEquivdecEquiv False False = Yes BothFalsedecEquiv True True = Yes BothTruedecEquiv False True = No absurddecEquiv True False = No absurd
module Data.Boolean.Basicimport Builtin%default totalpublic exportdata Boolean = False | True---- Negation / Complement--public exportnot : Boolean -> Booleannot False = Truenot True = FalseexportproofNotInvolution : (a : Boolean) -> not (not a) = aproofNotInvolution False = ReflproofNotInvolution True = Refl---- Disjunction / Inclusive OR--public exportdisj : Boolean -> Boolean -> Booleandisj False False = Falsedisj _ _ = TrueexportproofDisjLeftIdentity : (a : Boolean) -> False `disj` a = aproofDisjLeftIdentity False = ReflproofDisjLeftIdentity True = ReflexportproofDisjRightIdentity : (a : Boolean) -> a `disj` False = aproofDisjRightIdentity False = ReflproofDisjRightIdentity True = ReflexportproofDisjLeftAnnihilation : (a : Boolean) -> True `disj` a = TrueproofDisjLeftAnnihilation False = ReflproofDisjLeftAnnihilation True = ReflexportproofDisjRightAnnihilation : (a : Boolean) -> a `disj` True = TrueproofDisjRightAnnihilation False = ReflproofDisjRightAnnihilation True = ReflexportproofDisjCommutative : (a, b : Boolean) -> a `disj` b = b `disj` aproofDisjCommutative False b =rewrite proofDisjLeftIdentity b inrewrite proofDisjRightIdentity b inReflproofDisjCommutative True b = rewrite proofDisjRightAnnihilation b in Refl---- Conjunction / AND--public exportconj : Boolean -> Boolean -> Booleanconj True True = Trueconj _ _ = FalseexportproofConjLeftIdentity : (a : Boolean) -> True `conj` a = aproofConjLeftIdentity False = ReflproofConjLeftIdentity True = ReflexportproofConjRightIdentity : (a : Boolean) -> a `conj` True = aproofConjRightIdentity False = ReflproofConjRightIdentity True = ReflexportproofConjLeftAnnihilation : (a : Boolean) -> False `conj` a = FalseproofConjLeftAnnihilation False = ReflproofConjLeftAnnihilation True = ReflexportproofConjRightAnnihilation : (a : Boolean) -> a `conj` False = FalseproofConjRightAnnihilation False = ReflproofConjRightAnnihilation True = ReflexportproofConjCommutative : (a, b : Boolean) -> a `conj` b = b `conj` aproofConjCommutative False b = rewrite proofConjRightAnnihilation b in ReflproofConjCommutative True b =rewrite proofConjLeftIdentity b inrewrite proofConjRightIdentity b inRefl---- Util--public exportdecToBoolean : Dec t -> BooleandecToBoolean (Yes _) = TruedecToBoolean (No _) = False