Copyright | (c) Justin Le 2018 |
---|---|
License | BSD3 |
Maintainer | justin@jle.im |
Stability | experimental |
Portability | non-portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Logical and algebraic connectives for predicates, as well as common logical combinators.
Synopsis
- data Evident :: Predicate k
- type Impossible = Not Evident :: Predicate k
- data Not :: Predicate k -> Predicate k
- decideNot :: forall p a. Decision (p @@ a) -> Decision (Not p @@ a)
- data (&&&) :: Predicate k -> Predicate k -> Predicate k
- decideAnd :: forall p q a. Decision (p @@ a) -> Decision (q @@ a) -> Decision ((p &&& q) @@ a)
- data (|||) :: Predicate k -> Predicate k -> Predicate k
- decideOr :: forall p q a. Decision (p @@ a) -> Decision (q @@ a) -> Decision ((p ||| q) @@ a)
- type (^||) p q = p ||| (Not p &&& q)
- type (||^) p q = (p &&& Not q) ||| q
- type (^^^) p q = (p &&& Not q) ||| (Not p &&& q)
- decideXor :: forall p q a. Decision (p @@ a) -> Decision (q @@ a) -> Decision ((p ^^^ q) @@ a)
- data (==>) :: Predicate k -> Predicate k -> Predicate k
- proveImplies :: Prove q -> Prove (p ==> q)
- type Implies p q = Provable (p ==> q)
- type (<==>) p q = p ==> ((q &&& q) ==> p)
- type Equiv p q = Provable (p <==> q)
- compImpl :: forall p q r. (p --> q) -> (q --> r) -> p --> r
- explosion :: Impossible --> p
- atom :: p --> Evident
- complementation :: forall p. (p &&& Not p) --> Impossible
- doubleNegation :: forall p. Decidable p => Not (Not p) --> p
- tripleNegation :: forall p. Not (Not (Not p)) --> Not p
- negateTwice :: p --> Not (Not p)
- contrapositive :: (p --> q) -> Not q --> Not p
- contrapositive' :: forall p q. Decidable q => (Not q --> Not p) -> p --> q
- projAndFst :: (p &&& q) --> p
- projAndSnd :: (p &&& q) --> q
- injOrLeft :: forall p q. p --> (p ||| q)
- injOrRight :: forall p q. q --> (p ||| q)
Top and bottom
data Evident :: Predicate k Source #
Instances
type Impossible = Not Evident :: Predicate k Source #
The always-false predicate
Could also be defined as
, but this defintion gives
us a free ConstSym1
VoidDecidable
instance.
Impossible
::Predicate
k
Logical connectives
data Not :: Predicate k -> Predicate k Source #
is the predicate that Not
pp
is not true.
Instances
decideNot :: forall p a. Decision (p @@ a) -> Decision (Not p @@ a) Source #
Decide
based on decisions of Not
pp
.
data (&&&) :: Predicate k -> Predicate k -> Predicate k infixr 3 Source #
p
is a predicate that both &&&
qp
and q
are true.
Instances
(Decidable p, Decidable q) => Decidable (p &&& q :: TyFun k1 Type -> Type) Source # | |
Decidable ((p &&& p) ==> p :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Decidable ((p &&& q) ==> p :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Decidable ((p &&& q) ==> q :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
(Provable p, Provable q) => Provable (p &&& q :: TyFun k1 Type -> Type) Source # | |
Provable ((p &&& Not p) ==> (Impossible :: Predicate k1) :: TyFun k1 Type -> Type) Source # | Since: 0.1.3.0 |
Defined in Data.Type.Predicate.Logic | |
Provable ((p &&& p) ==> p :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Provable ((p &&& q) ==> p :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Provable ((p &&& q) ==> q :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
(Auto p a, Auto q a) => Auto (p &&& q :: TyFun k Type -> Type) (a :: k) Source # | |
type Apply (p &&& q :: TyFun k1 Type -> Type) (a :: k1) Source # | |
decideAnd :: forall p q a. Decision (p @@ a) -> Decision (q @@ a) -> Decision ((p &&& q) @@ a) Source #
Decide p
based on decisions of &&&
qp
and q
.
data (|||) :: Predicate k -> Predicate k -> Predicate k infixr 2 Source #
p
is a predicate that either |||
qp
and q
are true.
Instances
Decidable (p ==> (p ||| p) :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Decidable (p ==> (p ||| q) :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Decidable (q ==> (p ||| q) :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
(Decidable p, Decidable q) => Decidable (p ||| q :: TyFun k1 Type -> Type) Source # | Prefers |
Provable (p ==> (p ||| p) :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Provable (p ==> (p ||| q) :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
Provable (q ==> (p ||| q) :: TyFun k1 Type -> Type) Source # | Since: 0.1.1.0 |
type Apply (p ||| q :: TyFun k1 Type -> Type) (a :: k1) Source # | |
decideOr :: forall p q a. Decision (p @@ a) -> Decision (q @@ a) -> Decision ((p ||| q) @@ a) Source #
Decide p
based on decisions of |||
qp
and q
.
Prefers p
over q
.
type (^||) p q = p ||| (Not p &&& q) Source #
Left-biased "or". In proofs, prioritize a proof of the left side over a proof of the right side.
Since: 0.1.2.0
type (||^) p q = (p &&& Not q) ||| q Source #
Right-biased "or". In proofs, prioritize a proof of the right side over a proof of the left side.
Since: 0.1.2.0
type (^^^) p q = (p &&& Not q) ||| (Not p &&& q) Source #
p
is a predicate that either ^^^
qp
and q
are true, but not
both.
decideXor :: forall p q a. Decision (p @@ a) -> Decision (q @@ a) -> Decision ((p ^^^ q) @@ a) Source #
Decide p
based on decisions of ^^^
qp
and q
.
data (==>) :: Predicate k -> Predicate k -> Predicate k infixr 1 Source #
p ==> q
is true if q
is provably true under the condition that p
is true.
Instances
type (<==>) p q = p ==> ((q &&& q) ==> p) infixr 1 Source #
Two-way implication, or logical equivalence
Logical deductions
explosion :: Impossible --> p Source #
From Impossible
a
, you can prove anything. Essentially
a lifted version of absurd
.
complementation :: forall p. (p &&& Not p) --> Impossible Source #
doubleNegation :: forall p. Decidable p => Not (Not p) --> p Source #
Logical double negation. Only possible if p
is Decidable
.
This is because in constructivist logic, not (not p) does not imply p.
However, p implies not (not p) (see negateTwice
), and not (not (not
p)) implies not p (see tripleNegation
)
tripleNegation :: forall p. Not (Not (Not p)) --> Not p Source #
In constructivist logic, not (not (not p)) implies not p.
Since: 0.1.4.0
negateTwice :: p --> Not (Not p) Source #
In constructivist logic, p implies not (not p).
Since: 0.1.4.0
contrapositive' :: forall p q. Decidable q => (Not q --> Not p) -> p --> q Source #
Reverse direction of contrapositive
. Only possible if q
is
Decidable
on its own, without the help of p
, which makes this much
less useful.