Пример #1
0
def _defineAxioms():
    # Forall_X [()] in X**
    _firstAxiom =\
    nullsetInKleene = Forall(X, In(List(), KleeneRepetition(X)))
    # Forall_{A**, X} [A**] in X* => [A**, X] in X*
    concatenationInKleene = Forall([multiA, X],
                                   Implies(
                                       In(List(multiA), KleeneRepetition(X)),
                                       In(List(multiA, X),
                                          KleeneRepetition(X))))
    return _firstAxiom, locals()
def forallBoolEvalFalseDerivation(PofTrueVal, PofFalseVal):
    # hypothesis = [P(TRUE) = PofTrueVal] and [P(FALSE) in PofFalseVal]
    hypothesis = And(Equals(PofTrue, PofTrueVal),
                     Equals(PofFalse, PofFalseVal))
    # P(TRUE) in BOOLEANS assuming hypothesis
    hypothesis.deriveLeft().inBoolViaBooleanEquality().proven({hypothesis})
    # P(FALSE) in BOOLEANS assuming hypothesis
    hypothesis.deriveRight().inBoolViaBooleanEquality().proven({hypothesis})
    # forall_{A in BOOLEANS} P(A) in BOOLEANS assuming hypothesis
    Forall(A, inBool(PofA),
           domain=BOOLEANS).concludeAsFolded().proven({hypothesis})
    if PofTrueVal == FALSE:
        # Not(P(TRUE)) assuming hypothesis
        hypothesis.deriveLeft().deriveViaBooleanEquality().proven({hypothesis})
        example = TRUE
        # TRUE in BOOLEANS
        trueInBool
    elif PofFalseVal == FALSE:
        # Not(P(FALSE)) assuming hypothesis
        hypothesis.deriveRight().deriveViaBooleanEquality().proven(
            {hypothesis})
        example = FALSE
        # FALSE in BOOLEANS
        falseInBool
    # [forall_{A in BOOLEANS} P(A)] = FALSE assuming hypothesis
    conclusion = Exists(A, Not(PofA), domain=BOOLEANS).concludeViaExample(
        example).deriveNegatedForall().equateNegatedToFalse().proven(
            {hypothesis})
    # forall_{P} [(P(TRUE) = FALSE) and (P(FALSE) in BOOLEANS)] => {[forall_{A in BOOLEANS} P(A)] = FALSE}
    return Implies(hypothesis, conclusion).generalize(P)
Пример #3
0
def _defineTheorems():
    # Forall_{A**, B**} ([A**] in X*) and ([B**] in X*) => [A**, B**] in X**
    _firstAxiom = combining_in_kleene = Forall([multi_a, X],
                                               Implies(
                                                   In(List(multi_a),
                                                      KleeneRepetition(X)),
                                                   In(List(multi_a, X),
                                                      KleeneRepetition(X))))
    return None
Пример #4
0
from proveit.basiclogic import BOOLEANS, Forall, Iff, Implies, Equals
from proveit.common import A, B

# Note that prove_by_eval 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)
nested_version = Forall(A,
                        Forall(B,
                               Implies(Iff(A, B), Equals(A, B)),
                               domain=BOOLEANS),
                        domain=BOOLEANS).prove_by_eval()
# forall_{A in BOOLEANS, B in BOOLEANS} (A <=> B) => (A = B)
nested_version.instantiate().instantiate().generalize(
    (A, B), domain=BOOLEANS).qed(__file__)
Пример #5
0
from proveit.basiclogic import Forall, Iff, Equals, TRUE, derive_stmt_eq_true
from proveit.common import P, S, x_etc, Px_etc, Qetc, etc_Qx_etc

# forall_px = [forall_{..x.. in S | ..Q(..x..)..} P(..x..)]
forall_px = Forall(x_etc, Px_etc, S, etc_Qx_etc)
# forall_px_eq_t = [forall_{..x.. in S | ..Q(..x..)..} {P(..x..)=TRUE}]
forall_px_eq_t = Forall(x_etc, Equals(Px_etc, TRUE), S, etc_Qx_etc)
# forall_px_eq_t assuming forall_px
derive_stmt_eq_true(forall_px.instantiate()).generalize(
    x_etc, S, etc_Qx_etc).proven({forall_px})
# forall_px assuming forall_px_eq_t
forall_px_eq_t.instantiate().derive_via_boolean_equality().generalize(
    x_etc, S, etc_Qx_etc).proven({forall_px_eq_t})
# [forall_{..x.. in S | ..Q(..x..)..} P(..x..)] <=> [forall_{..x.. in S | ..Q(..x..)..} {P(..x..)=TRUE}]
iff_foralls = Iff(forall_px,
                  forall_px_eq_t).conclude_via_composition().proven()
# forall_px in BOOLEANS, forall_px_eq_t in BOOLEANS
for expr in (forall_px, forall_px_eq_t):
    expr.deduce_in_bool()
# forall_{P, ..Q.., S} [forall_{..x.. in S | ..Q(..x..)..} P(..x..)] =
# [forall_{..x.. in S | ..Q(..x..)..} {P(..x..)=TRUE}]
iff_foralls.derive_equality().generalize((P, Qetc, S)).qed(__file__)
Пример #6
0
from proveit.statement import Theorems
from proveit.expression import Lambda, Operation
from proveit.basiclogic import Forall, Equals, Implies, In
from .mapping_ops import Domain
from proveit.common import f, g, x, y, Q, fx, fy, gx, gy, Qx, Qy
from proveit.basiclogic.common import fx_eq_gx

mapping_theorems = Theorems(__package__, locals())

lambda_domain_equality = Forall((f, g, Q),
                                Equals(Domain(Lambda(x, fx, Qx)),
                                       Domain(Lambda(x, gx, Qx))))

# forall_{f, g, Q} {forall_{x | Q(x)} [f(x) = g(x)]} => {[(y | Q(y)) ->
# f(y)] = [(y | Q(y)) -> g(y)]
map_substitution = Forall((f, g, Q),
                          Implies(Forall(x, fx_eq_gx, Qx),
                                  Equals(Lambda(y, fy, Qy), Lambda(y, gy,
                                                                   Qy))))

# forall_{f, g} {forall_{x} [f(x) = g(x)]} => {[y -> f(y)] = [y -> g(y)]
map_over_all_substitution = Forall(
    (f, g), Implies(Forall(x, fx_eq_gx), Equals(Lambda(y, fy), Lambda(y, gy))))

mapping_theorems.finish(locals())
Пример #7
0
from proveit.basiclogic import Forall, Or, Equals, TRUE, FALSE, BOOLEANS, inBool
from proveit.common import A, B

# [(A or B) = TRUE] or [(A or B) = FALSE] assuming A, B in BOOLEANS
Forall(
    (A, B),
    Or(Equals(Or(A, B), TRUE), Equals(Or(A, B), FALSE)),
    domain=BOOLEANS).proveByEval().specialize().proven({inBool(A),
                                                        inBool(B)})
# forall_{A in BOOLEANS} (A or  B) in BOOLEANS
inBool(Or(A, B)).concludeAsFolded().generalize((A, B),
                                               domain=BOOLEANS).qed(__file__)
Пример #8
0
from proveit.statement import Axioms
from proveit.basiclogic import Forall, Equals, In, TRUE, Iff, Implies, And
from mappingOps import Domain, CoDomain
from proveit.common import f, g, x, y, Q, fx, fy, gx, Qx, Qy

fxMap = Lambda(x, fx)  # x -> f(x)
fxGivenQxMap = Lambda(x, fx, Qx)  # x -> f(x) | Q(x)
gxGivenQxMap = Lambda(x, gx, Qx)  # x -> g(x) | Q(x)
fDomain_eq_gDomain = Equals(Domain(f), Domain(g))  # Domain(f) = Domain(g)
fx_eq_gx = Equals(fx, gx)  # f(x) = g(x)
x_in_fDomain = In(x, Domain(f))  # x in Domain(f)
f_eq_g = Equals(f, g)  # f = g

mappingAxioms = Axioms(__package__, locals())

mapApplication = Forall((f, Q),
                        Forall(y, Equals(Operation(fxGivenQxMap, y), fy), Qy))

# forall_{f} [x -> f(x)] = [x -> f(x) | TRUE]
lambdaOverAllDef = Forall(f, Equals(Lambda(x, fx), Lambda(x, fx, TRUE)))

# forall_{f, Q} forall_{y} y in Domain(x -> f(x) | Q(x)) <=> Q(y)
lambdaDomainDef = Forall((f, Q), Forall(y, Iff(In(y, Domain(fxGivenQxMap)),
                                               Qy)))

# forall_{f, g} [Domain(f) = Domain(g) and forall_{x in Domain(f)} f(x) = g(x)] => (f = g)}
mapIsAsMapDoes = Forall(
    (f, g),
    Implies(And(fDomain_eq_gDomain, Forall(x, fx_eq_gx, x_in_fDomain)),
            f_eq_g))

mappingAxioms.finish(locals())
Пример #9
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__)
Пример #10
0
from proveit.basiclogic import Forall, Equals, In, TRUE, Iff, Implies, And
from .mapping_ops import Domain, CoDomain
from proveit.common import f, g, x, y, Q, fx, fy, gx, Qx, Qy

fx_map = Lambda(x, fx)  # x -> f(x)
fx_given_qx_map = Lambda(x, fx, Qx)  # x -> f(x) | Q(x)
gx_given_qx_map = Lambda(x, gx, Qx)  # x -> g(x) | Q(x)
f_domain_eq_gDomain = Equals(Domain(f), Domain(g))  # Domain(f) = Domain(g)
fx_eq_gx = Equals(fx, gx)  # f(x) = g(x)
x_in_f_domain = In(x, Domain(f))  # x in Domain(f)
f_eq_g = Equals(f, g)  # f = g

mapping_axioms = Axioms(__package__, locals())

map_application = Forall((f, Q),
                         Forall(y, Equals(Operation(fx_given_qx_map, y), fy),
                                Qy))

# forall_{f} [x -> f(x)] = [x -> f(x) | TRUE]
lambda_over_all_def = Forall(f, Equals(Lambda(x, fx), Lambda(x, fx, TRUE)))

# forall_{f, Q} forall_{y} y in Domain(x -> f(x) | Q(x)) <=> Q(y)
lambda_domain_def = Forall((f, Q),
                           Forall(y, Iff(In(y, Domain(fx_given_qx_map)), Qy)))

# forall_{f, g} [Domain(f) = Domain(g) and forall_{x in Domain(f)} f(x) =
# g(x)] => (f = g)}
map_is_as_map_does = Forall(
    (f, g),
    Implies(And(f_domain_eq_gDomain, Forall(x, fx_eq_gx, x_in_f_domain)),
            f_eq_g))
Пример #11
0
from proveit.basiclogic.booleans.axioms import exists_def
from proveit.basiclogic import Forall, NotEquals, Implies, TRUE, FALSE, derive_stmt_eq_true, In
from proveit.common import X, P, S, x_etc, y_etc, Px_etc, Py_etc, Qetc, etc_Qx_etc, etc_Qy_etc

in_domain = In(x_etc, S)  # ..x.. in S

# never_py = [forall_{..y.. in S | ..Q(..y..)..} (P(..y..) != TRUE)]
never_py = Forall(y_etc, NotEquals(Py_etc, TRUE), S, etc_Qy_etc)
# (P(..x..) != TRUE) assuming ..Q(..x..).., never_py
never_py.instantiate({y_etc: x_etc}).proven({etc_Qx_etc, never_py, in_domain})
# (TRUE != TRUE) assuming ..Q(..x..).., P(..x..), never_py
true_not_eq_true = derive_stmt_eq_true(Px_etc).sub_right_side_into(
    NotEquals(X, TRUE), X).proven({etc_Qx_etc, Px_etc, never_py, in_domain})
# FALSE assuming ..Q(..x..).., P(..x..), never_py
true_not_eq_true.evaluation().derive_contradiction().derive_conclusion(
).proven({etc_Qx_etc, Px_etc, never_py, in_domain})
# [forall_{..y.. in S | ..Q(..y..)..} (P(..y..) != TRUE)] in BOOLEANS
never_py.deduce_in_bool().proven()
# Not(forall_{..y.. in S | ..Q(..y..)..} (P(..y..) != TRUE) assuming
# ..Q(..x..).., P(..x..)
Implies(never_py, FALSE).derive_via_contradiction().proven(
    {etc_Qx_etc, Px_etc, in_domain})
# exists_{..y.. in S | ..Q(..y..)..} P(..y..) assuming Q(..x..), P(..x..)
existence = exists_def.instantiate({
    x_etc: y_etc
}).derive_left_via_equality().proven({etc_Qx_etc, Px_etc, in_domain})
# forall_{P, ..Q.., S} forall_{..x.. in S | ..Q(..x..)..} [P(..x..) =>
# exists_{..y.. in S | ..Q(..y..)..} P(..y..)]
Implies(Px_etc, existence).generalize(x_etc, S, etc_Qx_etc).generalize(
    (P, Qetc, S)).qed(__file__)
Пример #12
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__)
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__)
from proveit.basiclogic.booleans.theorems import exists_not_implies_not_forall
from proveit.basiclogic import Forall, Implies
from proveit.common import P, S, x_etc, Px_etc, Qetc, etc_Qx_etc

# hypothesis = forall_{..x.. in S | ..Q(..x..)..} P(..x..)
hypothesis = Forall(x_etc, Px_etc, S, etc_Qx_etc)
# [exists_{..x.. in S | ..Q(..x..)..} Not(P(..x..))] => [Not(forall_{..x.. in S | ..Q(..x..)..} P(..x..)]
exists_not_implies_not_forall_spec = exists_not_implies_not_forall.instantiate(
).proven()
# exists_{..x.. in S | ..Q(..x..)..} Not(P(..x..)) in BOOLEANS
exists_not_implies_not_forall_spec.hypothesis.deduce_in_bool()
# forall_{..x.. in S | ..Q(..x..)..} P(..x..) in BOOLEANS
exists_not_implies_not_forall_spec.conclusion.operand.deduce_in_bool()
# NotExists_{..x.. in S | ..Q(..x..)..} Not(P(..x..))
conclusion = exists_not_implies_not_forall_spec.transpose().derive_conclusion(
).derive_not_exists().proven({hypothesis})
# forall_{P, ..Q.., S} NotExists_{..x.. in S | ..Q(..x..)..} Not(P(..x..))
# => forall_{..x.. in S | ..Q(..x..)..} P(..x..)
Implies(hypothesis, conclusion).generalize((P, Qetc, S)).qed(__file__)
Пример #15
0
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__)
Пример #16
0
from proveit.basiclogic import Forall, Or, Equals, TRUE, FALSE, BOOLEANS, in_bool
from proveit.common import A, B

# [(A or B) = TRUE] or [(A or B) = FALSE] assuming A, B in BOOLEANS
Forall((A, B), Or(Equals(Or(A, B), TRUE), Equals(Or(A, B), FALSE)),
       domain=BOOLEANS).prove_by_eval().instantiate().proven({in_bool(A), in_bool(B)})
# forall_{A in BOOLEANS} (A or  B) in BOOLEANS
in_bool(Or(A, B)).conclude_as_folded().generalize(
    (A, B), domain=BOOLEANS).qed(__file__)
Пример #17
0
from proveit.basiclogic.booleans.axioms import exists_def, not_exists_def
from proveit.basiclogic import Forall, Not, NotEquals, TRUE
from proveit.common import X, P, S, x_etc, Qetc, Px_etc, etc_Qx_etc

# [exists_{..x.. in S | ..Q(..x..)..} P(..x..)] = not(forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))
exists_def_spec = exists_def.instantiate().proven()
# notexists_{..x.. in S | ..Q..(..x..)} P(..x..) = not[exists_{..x.. in S
# | ..Q(..x..)..} P(..x..)]
not_exists_def_spec = not_exists_def.instantiate().proven()
# rhs = forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE)
rhs = Forall(x_etc, NotEquals(Px_etc, TRUE), S, etc_Qx_etc)
# [forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE)] in BOOLEANS
rhs.deduce_in_bool().proven()
# not(not(forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))) =
# forall_{..x.. in S | ..Q(..x..)..} (P(..x..) != TRUE))
double_negated_forall = Not(
    Not(rhs)).deduce_double_negation_equiv().derive_reversed().proven()
# notexists_{..x.. in S | ..Q(..x..)..} P(..x..) = forall_{..x.. in S |
# ..Q(..x..)..} (P(..x..) != TRUE))
equiv = not_exists_def_spec.apply_transitivity(
    exists_def_spec.substitution(
        Not(X), X)).apply_transitivity(double_negated_forall).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__)
Пример #18
0
from proveit.statement import Theorems
from proveit.expression import Lambda, Operation
from proveit.basiclogic import Forall, Equals, Implies, In
from .mappingOps import Domain
from proveit.common import f, g, x, y, Q, fx, fy, gx, gy, Qx, Qy
from proveit.basiclogic.common import fx_eq_gx

mappingTheorems = Theorems(__package__, locals())

lambdaDomainEquality = Forall((f, g, Q),
                              Equals(Domain(Lambda(x, fx, Qx)),
                                     Domain(Lambda(x, gx, Qx))))

# forall_{f, g, Q} {forall_{x | Q(x)} [f(x) = g(x)]} => {[(y | Q(y)) -> f(y)] = [(y | Q(y)) -> g(y)]
mapSubstitution = Forall((f, g, Q),
                         Implies(Forall(x, fx_eq_gx, Qx),
                                 Equals(Lambda(y, fy, Qy), Lambda(y, gy, Qy))))

# forall_{f, g} {forall_{x} [f(x) = g(x)]} => {[y -> f(y)] = [y -> g(y)]
mapOverAllSubstitution = Forall((f, g),
                                Implies(Forall(x, fx_eq_gx),
                                        Equals(Lambda(y, fy), Lambda(y, gy))))

mappingTheorems.finish(locals())
Пример #19
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__)
Пример #20
0
from proveit.basiclogic import Forall, Implies
from proveit.common import P, S, x_etc, y_etc, Qetc, Retc, Pxy_etc, etc_Qx_etc, etc_Ry_etc

# forall_{..x.., ..y.. in S | ..Q(..x..).., ..R(..y..)..} P(..x.., ..y..)
hypothesis = Forall((x_etc, y_etc), Pxy_etc, S, (etc_Qx_etc, etc_Ry_etc))
# forall_{..x.. in S | ..Q(..x..)..} forall_{..y.. in S | ..R(..y..)..}
# P(..x.., ..y..)
conclusion = hypothesis.instantiate().generalize(
    y_etc, S, etc_Ry_etc).generalize(x_etc, S, etc_Qx_etc).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__)
Пример #21
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__)
from proveit.basiclogic.booleans.axioms import exists_def
from proveit.basiclogic import Exists, Forall, Not, NotEquals, Implies, In, TRUE, derive_stmt_eq_true
from proveit.common import P, S, X, x_etc, Px_etc, etc_Qx_etc, Qetc

in_domain = In(x_etc, S)  # ..x.. in S
# exists_not = [exists_{..x.. in S | ..Q(..x..)..} Not(P(..x..))]
exists_not = Exists(x_etc, Not(Px_etc), S, etc_Qx_etc)
# [Not(forall_{..x.. in S | ..Q(..x..)..} Not(P(..x..)) != TRUE] assuming exists_not
exists_def.instantiate({
    Px_etc: Not(Px_etc)
}).derive_right_via_equality().proven({exists_not})
# forall_{..x.. in S | ..Q(..x..)..} P(..x..)
forall_px = Forall(x_etc, Px_etc, S, etc_Qx_etc)
# forall_{..x.. in S | ..Q(..x..)..} Not(P(..x..)) != TRUE
forall_not_px_not_true = Forall(x_etc, NotEquals(Not(Px_etc), TRUE), S,
                                etc_Qx_etc)
# forall_px in BOOLEANS, forall_not_px_not_true in BOOLEANS
for expr in (forall_px, forall_not_px_not_true):
    expr.deduce_in_bool().proven()
# Not(TRUE) != TRUE
NotEquals(Not(TRUE), TRUE).prove_by_eval()
# forall_not_px_not_true assuming forall_px, ..Q(..x..).., In(..x.., S)
derive_stmt_eq_true(forall_px.instantiate()).lhs_statement_substitution(
    NotEquals(Not(X), TRUE), X).derive_conclusion().generalize(
        x_etc, domain=S, conditions=etc_Qx_etc).proven({forall_px, in_domain})
# Not(forall_not_px_not_true) => Not(forall_px)
Implies(forall_px, forall_not_px_not_true).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(exists_not, Not(forall_px)).generalize((P, Qetc, S)).qed(__file__)
Пример #23
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__)