from proveit.basiclogic.boolean.theorems import trueInBool, falseInBool
from proveit.basiclogic import TRUE, FALSE, BOOLEANS, Implies, Forall, compose
from proveit.common import A, P, PofA

# hypothesis = [forall_{A in BOOLEANS} P(A)]
hypothesis = Forall(A, PofA, domain=BOOLEANS)
# TRUE in BOOLEANS, FALSE in BOOLEANS
trueInBool, falseInBool
# P(TRUE) and P(FALSE) assuming hypothesis
conclusion = compose(hypothesis.specialize({A: TRUE}),
                     hypothesis.specialize({A: FALSE})).proven({hypothesis})
# forall_{P} [forall_{A in BOOLEANS} P(A)] => [P(TRUE) and P(FALSE)]
Implies(hypothesis, conclusion).generalize(P).qed(__file__)
Example #2
0
from proveit.basiclogic.boolean.axioms import existsDef
from proveit.basiclogic import Forall, NotEquals, Implies, TRUE, FALSE, deriveStmtEqTrue, In
from proveit.common import X, P, S, xEtc, yEtc, PxEtc, PyEtc, Qetc, etc_QxEtc, etc_QyEtc

inDomain = In(xEtc, S)  # ..x.. in S

# neverPy = [forall_{..y.. in S | ..Q(..y..)..} (P(..y..) != TRUE)]
neverPy = Forall(yEtc, NotEquals(PyEtc, TRUE), S, etc_QyEtc)
# (P(..x..) != TRUE) assuming ..Q(..x..).., neverPy
neverPy.specialize({yEtc: xEtc}).proven({etc_QxEtc, neverPy, inDomain})
# (TRUE != TRUE) assuming ..Q(..x..).., P(..x..), neverPy
trueNotEqTrue = deriveStmtEqTrue(PxEtc).subRightSideInto(
    NotEquals(X, TRUE), X).proven({etc_QxEtc, PxEtc, neverPy, inDomain})
# FALSE assuming ..Q(..x..).., P(..x..), neverPy
trueNotEqTrue.evaluation().deriveContradiction().deriveConclusion().proven(
    {etc_QxEtc, PxEtc, neverPy, inDomain})
# [forall_{..y.. in S | ..Q(..y..)..} (P(..y..) != TRUE)] in BOOLEANS
neverPy.deduceInBool().proven()
# Not(forall_{..y.. in S | ..Q(..y..)..} (P(..y..) != TRUE) assuming ..Q(..x..).., P(..x..)
Implies(neverPy,
        FALSE).deriveViaContradiction().proven({etc_QxEtc, PxEtc, inDomain})
# exists_{..y.. in S | ..Q(..y..)..} P(..y..) assuming Q(..x..), P(..x..)
existence = existsDef.specialize({
    xEtc: yEtc
}).deriveLeftViaEquivalence().proven({etc_QxEtc, PxEtc, inDomain})
# forall_{P, ..Q.., S} forall_{..x.. in S | ..Q(..x..)..} [P(..x..) => exists_{..y.. in S | ..Q(..y..)..} P(..y..)]
Implies(PxEtc, existence).generalize(xEtc, S, etc_QxEtc).generalize(
    (P, Qetc, S)).qed(__file__)
Example #3
0
from proveit.basiclogic import Forall, Implies
from proveit.common import P, S, xEtc, yEtc, Qetc, Retc, PxyEtc, etc_QxEtc, etc_RyEtc

# forall_{..x.., ..y.. in S | ..Q(..x..).., ..R(..y..)..} P(..x.., ..y..)
hypothesis = Forall((xEtc, yEtc), PxyEtc, S, (etc_QxEtc, etc_RyEtc))
# forall_{..x.. in S | ..Q(..x..)..} forall_{..y.. in S | ..R(..y..)..} P(..x.., ..y..)
conclusion = hypothesis.specialize().generalize(yEtc, S, etc_RyEtc).generalize(xEtc, S, etc_QxEtc).proven({hypothesis})
# forall_{P, ..Q.., ..R.., S} [forall_{..x.., ..y.. in S | ..Q(..x..).., ..R(..y..)..} P(..x.., ..y..) => forall_{..x.. in S | ..Q(..x..)..} forall_{..y.. in S | ..R(..y..)..} P(..x.., ..y..)]
Implies(hypothesis, conclusion).generalize((P, Qetc, Retc, S)).qed(__file__)
Example #4
0
from proveit.basiclogic import Forall, Iff, Equals, TRUE, deriveStmtEqTrue
from proveit.common import P, S, xEtc, PxEtc, Qetc, etc_QxEtc

# forallPx = [forall_{..x.. in S | ..Q(..x..)..} P(..x..)]
forallPx = Forall(xEtc, PxEtc, S, etc_QxEtc)
# forallPxEqT = [forall_{..x.. in S | ..Q(..x..)..} {P(..x..)=TRUE}]
forallPxEqT = Forall(xEtc, Equals(PxEtc, TRUE), S, etc_QxEtc)
# forallPxEqT assuming forallPx
deriveStmtEqTrue(forallPx.specialize()).generalize(xEtc, S, etc_QxEtc).proven({forallPx})
# forallPx assuming forallPxEqT
forallPxEqT.specialize().deriveViaBooleanEquality().generalize(xEtc, S, etc_QxEtc).proven({forallPxEqT})
# [forall_{..x.. in S | ..Q(..x..)..} P(..x..)] <=> [forall_{..x.. in S | ..Q(..x..)..} {P(..x..)=TRUE}]
iffForalls = Iff(forallPx, forallPxEqT).concludeViaComposition().proven()
# forallPx in BOOLEANS, forallPxEqT in BOOLEANS
for expr in (forallPx, forallPxEqT):
    expr.deduceInBool()
# forall_{P, ..Q.., S} [forall_{..x.. in S | ..Q(..x..)..} P(..x..)] = [forall_{..x.. in S | ..Q(..x..)..} {P(..x..)=TRUE}]
iffForalls.deriveEquality().generalize((P, Qetc, S)).qed(__file__)
from proveit.basiclogic.boolean.axioms import existsDef
from proveit.basiclogic import Exists, Forall, Not, NotEquals, Implies, In, TRUE, deriveStmtEqTrue
from proveit.common import P, S, X, xEtc, PxEtc, etc_QxEtc, Qetc

inDomain = In(xEtc, S)  # ..x.. in S
# existsNot = [exists_{..x.. in S | ..Q(..x..)..} Not(P(..x..))]
existsNot = Exists(xEtc, Not(PxEtc), S, etc_QxEtc)
# [Not(forall_{..x.. in S | ..Q(..x..)..} Not(P(..x..)) != TRUE] assuming existsNot
existsDef.specialize({
    PxEtc: Not(PxEtc)
}).deriveRightViaEquivalence().proven({existsNot})
# forall_{..x.. in S | ..Q(..x..)..} P(..x..)
forallPx = Forall(xEtc, PxEtc, S, etc_QxEtc)
# forall_{..x.. in S | ..Q(..x..)..} Not(P(..x..)) != TRUE
forallNotPxNotTrue = Forall(xEtc, NotEquals(Not(PxEtc), TRUE), S, etc_QxEtc)
# forallPx in BOOLEANS, forallNotPxNotTrue in BOOLEANS
for expr in (forallPx, forallNotPxNotTrue):
    expr.deduceInBool().proven()
# Not(TRUE) != TRUE
NotEquals(Not(TRUE), TRUE).proveByEval()
# forallNotPxNotTrue assuming forallPx, ..Q(..x..).., In(..x.., S)
deriveStmtEqTrue(forallPx.specialize()).lhsStatementSubstitution(
    NotEquals(Not(X), TRUE), X).deriveConclusion().generalize(
        xEtc, domain=S, conditions=etc_QxEtc).proven({forallPx, inDomain})
# Not(forallNotPxNotTrue) => Not(forallPx)
Implies(forallPx, forallNotPxNotTrue).transpose().proven()
# forall_{P, ..Q.., S} [exists_{..x.. in S | ..Q(..x..)..} Not(P(..x..))] => [Not(forall_{..x.. in S | ..Q(..x..)..} P(..x..)]
Implies(existsNot, Not(forallPx)).generalize((P, Qetc, S)).qed(__file__)
Example #6
0
from proveit.basiclogic import Forall, Implies
from proveit.common import P, S, xEtc, yEtc, Qetc, Retc, PxyEtc, etc_QxEtc, etc_RyEtc

# forall_{..x.. in S | ..Q(..x..)..} forall_{..y.. in S | ..R(..y..)..} P(..x.., ..y..)
hypothesis = Forall(xEtc, Forall(yEtc, PxyEtc, S, etc_RyEtc), S, etc_QxEtc)
# forall_{..x.., ..y.. in S | ..Q(..x..).., ..R(..y..)..} P(..x.., ..y..)
conclusion = hypothesis.specialize().specialize().generalize(
    (xEtc, yEtc), S, (etc_QxEtc, etc_RyEtc)).proven({hypothesis})
# forall_{P, ..Q.., ..R.., S} [forall_{..x.. in S | ..Q(..x..)..} forall_{..y.. in S | ..R(..y..)..} P(..x.., ..y..) => forall_{..x.., ..y.. in S | ..Q(..x..).., ..R(..y..)..} P(..x.., ..y..)]
Implies(hypothesis, conclusion).generalize((P, Qetc, Retc, S)).qed(__file__)
Example #7
0
from proveit.basiclogic import BOOLEANS, Forall, Iff, Implies, Equals
from proveit.common import A, B

# Note that proveByEval doesn't work for bundled Forall yet,
# but later we'll be able to do this kind of thing in one step.
# forall_{A in BOOLEANS, B in BOOLEANS} (A <=> B) => (A = B)
nestedVersion = Forall(A, Forall(B, Implies(Iff(A, B), Equals(A, B)), domain=BOOLEANS), domain=BOOLEANS).proveByEval()
# forall_{A in BOOLEANS, B in BOOLEANS} (A <=> B) => (A = B)
nestedVersion.specialize().specialize().generalize((A, B), domain=BOOLEANS).qed(__file__)