Exemplo n.º 1
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__)
Exemplo n.º 2
0
from proveit.basiclogic.boolean.axioms import existsDef, notExistsDef
from proveit.basiclogic import Forall, Not, NotEquals, TRUE
from proveit.common import X, P, S, xEtc, Qetc, PxEtc, etc_QxEtc

# [exists_{..x.. in S | ..Q(..x..)..} P(..x..)] = not(forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))
existsDefSpec = existsDef.specialize().proven()
# notexists_{..x.. in S | ..Q..(..x..)} P(..x..) = not[exists_{..x.. in S | ..Q(..x..)..} P(..x..)]
notExistsDefSpec = notExistsDef.specialize().proven()
# rhs = forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE)
rhs = Forall(xEtc, NotEquals(PxEtc, TRUE), S, etc_QxEtc)
# [forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE)] in BOOLEANS
rhs.deduceInBool().proven()
# not(not(forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))) = forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))
doubleNegatedForall = Not(Not(rhs)).deduceDoubleNegationEquiv().deriveReversed().proven()
# notexists_{..x.. in S | ..Q(..x..)..} P(..x..) = forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))
equiv = notExistsDefSpec.applyTransitivity(existsDefSpec.substitution(Not(X), X)).applyTransitivity(doubleNegatedForall).proven()
# forall_{P, ..Q..} [notexists_{..x.. in S | ..Q(..x..)..} P(..x..) = forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE)]
equiv.generalize((P, Qetc, S)).qed(__file__)