コード例 #1
0
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)
コード例 #2
0
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__)
コード例 #3
0
ファイル: orContradiction.py プロジェクト: wdcraft01/Prove-It
from proveit.basiclogic.boolean.theorems import notOrFromNeither
from proveit.basiclogic import Not
from proveit.common import A, B

# (A or B) => FALSE assuming Not(A), Not(B)
AorB_impl_F = notOrFromNeither.specialize().deriveConclusion(
).deriveConclusion().deriveContradiction().deriveConclusion()
AorB_impl_F.generalize((A, B), conditions=(Not(A), Not(B))).qed(__file__)
コード例 #4
0
from proveit.basiclogic import Implies, Not, FALSE, in_bool
from proveit.common import A, B

# hypothesis = [Not(B) => Not(A)]
hypothesis = Implies(Not(B), Not(A))
# A=FALSE assuming Not(B)=>Not(A) and Not(B)
AeqF = Not(A).equate_negated_to_false().proven({hypothesis, Not(B)})
# FALSE assuming Not(B)=>Not(A), Not(B), and A
AeqF.derive_right_via_equality().proven({hypothesis, Not(B), A})
# B assuming in_bool(B), (Not(B)=>Not(A)), A
Implies(Not(B),
        FALSE).derive_via_contradiction().proven({in_bool(B), hypothesis, A})
# [Not(B) => Not(A)] => [A => B] by nested hypothetical reasoning assuming in_bool(B)
transposition_expr = Implies(hypothesis, Implies(A, B)).proven({in_bool(B)})
# forall_{A, B | in_bool(B)} [A => B] => [Not(B) => Not(A)]
transposition_expr.generalize((A, B), conditions=in_bool(B)).qed(__file__)
コード例 #5
0
from proveit.basiclogic import Implies, Not, Equals, NotEquals
from proveit.basiclogic.equality.axioms import equalsSymmetry
from proveit.common import x, y

# hypothesis = (x != y)
hypothesis = NotEquals(x, y)
# inBool(x=y)
Equals(x, y).deduceInBool()
# inBool(y=x)
Equals(y, x).deduceInBool()
# Not(x=y) => Not(y=x)
equalsSymmetry.specialize({x: y, y: x}).transpose().proven()
# Not(x=y) assuming (x != y)
NotEquals(x, y).unfold({hypothesis})
# (y != x) assuming Not(x = y)
y_neq_x = Not(Equals(y, x)).deriveNotEquals({Not(Equals(y, x))})
# forall_{x, y} (x != y) => (y != x)
y_neq_x.asImplication({hypothesis}).generalize((x, y)).qed(__file__)
コード例 #6
0
from proveit.basiclogic import Implies, Not, FALSE
from proveit.common import A

# FALSE assuming Not(A) and A
Not(A).equateNegatedToFalse().deriveRightViaEquivalence().proven({Not(A), A})
Implies(Not(A), Implies(A, FALSE)).generalize(A).qed(__file__)
コード例 #7
0
from proveit.basiclogic.booleans.axioms import implicit_not_f
from proveit.basiclogic import Not, Implies, Equals, FALSE, derive_stmt_eq_true
from proveit.common import A

# [Not(A) = TRUE] => [A = FALSE]
implicit_not_f.instantiate().proven()
# [Not(A) = TRUE] assuming Not(A)
derive_stmt_eq_true(Not(A)).proven({Not(A)})
# forall_{A} Not(A) => [A=FALSE]
Implies(Not(A), Equals(A, FALSE)).generalize(A).qed(__file__)
コード例 #8
0
ファイル: negationClosure.py プロジェクト: wdcraft01/Prove-It
from proveit.basiclogic import Forall, Or, Not, Equals, TRUE, FALSE, BOOLEANS, inBool
from proveit.common import A

# Not(A) = TRUE or Not(A) = FALSE assuming A in BOOLEANS
Forall(A, Or(Equals(Not(A), TRUE), Equals(Not(A), FALSE)),
       domain=BOOLEANS).proveByEval().specialize().proven({inBool(A)})
# forall_{A in BOOLEANS} Not(A) in BOOLEANS
inBool(Not(A)).concludeAsFolded().generalize(A, domain=BOOLEANS).qed(__file__)
コード例 #9
0
from proveit.basiclogic import Implies, Not, in_bool
from proveit.common import A, B

# Not(Not(B)) assuming B and in_bool(B)
not_not_b = Not(Not(B)).conclude_via_double_negation()
# [A=>B] => [A => Not(Not(B))] assuming in_bool(B)
inner_expr = Implies(Implies(A, B), Implies(A, not_not_b)).proven({in_bool(B)})
# forall_{A, B | in_bool(B)}  [A=>B] => [A => Not(Not(B))]
inner_expr.generalize((A, B), conditions=in_bool(B)).qed(__file__)
コード例 #10
0
from proveit.basiclogic.booleans.axioms import not_t
from proveit.basiclogic.booleans.theorems import not_from_eq_false
from proveit.basiclogic import Implies, Not, derive_stmt_eq_true
from proveit.common import A, X

# A=TRUE assuming A
AeqT = derive_stmt_eq_true(A)
# [Not(A)=FALSE] assuming A=TRUE
AeqT.substitution(Not(A)).apply_transitivity(not_t).proven({AeqT})
# [Not(A)=FALSE] => Not(Not(A))
not_from_eq_false.instantiate({A: Not(A)}).proven()
# forall_{A} A => Not(Not(A))
Implies(A, Not(Not(A))).generalize(A).qed(__file__)
コード例 #11
0
from proveit.basiclogic.boolean.theorems import doubleNegation, fromDoubleNegation
from proveit.basiclogic import BOOLEANS, inBool, Not, Iff
from proveit.common import A

# A => Not(Not(A))
doubleNegationImplied = doubleNegation.specialize().proven()
# Not(Not(A)) => A
impliesDoubleNegation = fromDoubleNegation.specialize().proven()
# [A => Not(Not(A))] in BOOLEANS if A in BOOLEANS
doubleNegationImplied.deduceInBool().proven({inBool(A)})
# [Not(Not(A)) => A] in BOOLEANS if A in BOOLEANS
impliesDoubleNegation.deduceInBool().proven({inBool(A)})
# forall_{A} A = Not(Not(A))
Iff(A, Not(Not(A))).concludeViaComposition().deriveEquality().generalize(
    A, domain=BOOLEANS).qed(__file__)
コード例 #12
0
from proveit.basiclogic.boolean.axioms import notT
from proveit.basiclogic import BOOLEANS, FALSE, inBool, Implies, And, Or, Not, deriveStmtEqTrue
from proveit.common import A, B, C, X

AorB = Or(A, B)
hypothesis = And(Implies(A, C), Implies(B, C))
ABCareBool = {inBool(A), inBool(B), inBool(C)}
# A=>C, B=>C assuming (A=>C and B=>C)
AimplC, _ = hypothesis.decompose()
# Not(A) assuming inBool(A), inBool(B), (A=>C and B=>C), Not(C)
AimplC.transpose().deriveConclusion().proven(
    {inBool(A), inBool(C), hypothesis,
     Not(C)})
# B assuming inBool(A, B, C), (A=>C and B=>C), (A or B), Not(C)
AorB.deriveRightIfNotLeft().proven(ABCareBool | {hypothesis, AorB, Not(C)})
# Not(TRUE) assuming inBool(A, B, C), (A=>C and B=>C), (A or B), Not(C)
deriveStmtEqTrue(C).subRightSideInto(
    Not(X), X).proven(ABCareBool | {hypothesis, AorB, Not(C)})
# FALSE assuming inBool(A, B, C), (A=>C and B=>C), (A or B), Not(C)
notT.deriveRightViaEquivalence().proven(
    ABCareBool | {hypothesis, AorB, Not(C)})
# Contradiction proof of C assuming (A=>C and B=>C), (A or B), inBool(A), and inBool(B)
Implies(Not(C),
        FALSE).deriveViaContradiction().proven(ABCareBool | {hypothesis, AorB})
# forall_{A, B, C in BOOLEANS} (A=>C and B=>C) => ((A or B) => C)
Implies(hypothesis, Implies(AorB, C)).generalize((A, B, C),
                                                 domain=BOOLEANS).qed(__file__)
コード例 #13
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__)
コード例 #14
0
from proveit.basiclogic.booleans.axioms import contradictory_validation
from proveit.basiclogic import Implies, Not, FALSE, in_bool, BOOLEANS
from proveit.common import A

# in_bool(Not(A)) assuming in_bool(A)
Not(A).deduce_in_bool().proven({in_bool(A)})
# [Not(Not(A)) => FALSE] => Not(A) assuming in_bool(A)
contradictory_validation.instantiate({A: Not(A)}).proven({in_bool(A)})
# A assuming Not(Not(A)) and in_bool(A)
Not(Not(A)).derive_via_double_negation().proven({in_bool(A), Not(Not(A))})
# forall_{A in BOOLEANS} [A => FALSE] => Not(A)
Implies(Implies(A, FALSE), Not(A)).generalize(A, domain=BOOLEANS).qed(__file__)
コード例 #15
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__)
コード例 #16
0
from proveit.basiclogic.booleans.axioms import or_f_f
from proveit.basiclogic.booleans.theorems import not_false
from proveit.basiclogic import Implies, Not, Or, FALSE
from proveit.common import A, B, X

# Not(A or B) = Not(F or B) assuming Not(A)
not_aor_b_eq_not_forB = Not(A).equate_negated_to_false().substitution(
    Not(Or(X, B)), X).proven({Not(A)})
# Not(A or B) = Not(F or F) assuming Not(A), Not(B)
not_aor_b_eq_not_forF = not_aor_b_eq_not_forB.apply_transitivity(
    Not(B).equate_negated_to_false().substitution(Not(Or(FALSE, X)),
                                                  X)).proven({Not(A),
                                                              Not(B)})
#  Not(A or B) = Not(F) assuming Not(A), Not(B)
not_aor_b_eq_not_f = not_aor_b_eq_not_forF.apply_transitivity(
    or_f_f.substitution(Not(X), X)).proven({Not(A), Not(B)})
# Not(FALSE)
not_false
# Not(A or B) assuming Not(A), Not(B)
not_aor_b = not_aor_b_eq_not_f.derive_left_via_equality().proven(
    {Not(A), Not(B)})
# forall_{A, B} Not(A) => [Not(B) => Not(A or B)]
Implies(Not(A), Implies(Not(B), not_aor_b)).generalize((A, B)).qed(__file__)
コード例 #17
0
from proveit.basiclogic import Implies, Not, FALSE
from proveit.common import A

# FALSE assuming Not(A) and A
Not(A).equate_negated_to_false(
).derive_right_via_equality().proven({Not(A), A})
Implies(Not(A), Implies(A, FALSE)).generalize(A).qed(__file__)
コード例 #18
0
from proveit.basiclogic.boolean.axioms import implicitNotF, implicitNotT
from proveit.basiclogic import Implies, Not, deriveStmtEqTrue
from proveit.common import A

# hypothesis: Not(Not(A))
hypothesis = Not(Not(A))
# [Not(Not(A)) = TRUE] assuming hypothesis
deriveStmtEqTrue(hypothesis).proven({hypothesis})
# [Not(A) = FALSE] assuming hypothesis
implicitNotF.specialize({A: Not(A)}).deriveConclusion().proven({hypothesis})
# A assuming hypothesis
implicitNotT.specialize().deriveConclusion().deriveViaBooleanEquality().proven(
    {hypothesis})
# forall_{A} Not(Not(A)) => A
Implies(Not(Not(A)), A).generalize(A).qed(__file__)
コード例 #19
0
from proveit.basiclogic.boolean.axioms import orFF
from proveit.basiclogic.boolean.theorems import notFalse
from proveit.basiclogic import Implies, Not, Or, FALSE
from proveit.common import A, B, X

# Not(A or B) = Not(F or B) assuming Not(A)
notAorB_eq_notForB = Not(A).equateNegatedToFalse().substitution(
    Not(Or(X, B)), X).proven({Not(A)})
# Not(A or B) = Not(F or F) assuming Not(A), Not(B)
notAorB_eq_notForF = notAorB_eq_notForB.applyTransitivity(
    Not(B).equateNegatedToFalse().substitution(Not(Or(FALSE, X)),
                                               X)).proven({Not(A),
                                                           Not(B)})
#  Not(A or B) = Not(F) assuming Not(A), Not(B)
notAorB_eq_notF = notAorB_eq_notForF.applyTransitivity(
    orFF.substitution(Not(X), X)).proven({Not(A), Not(B)})
# Not(FALSE)
notFalse
# Not(A or B) assuming Not(A), Not(B)
notAorB = notAorB_eq_notF.deriveLeftViaEquivalence().proven({Not(A), Not(B)})
# forall_{A, B} Not(A) => [Not(B) => Not(A or B)]
Implies(Not(A), Implies(Not(B), notAorB)).generalize((A, B)).qed(__file__)
コード例 #20
0
from proveit.basiclogic import Implies, Not
from proveit.common import A

# Not(Not(A)) assuming A
not_not_a = Not(Not(A)).conclude_via_double_negation()
Implies(A, not_not_a.equate_negated_to_false()).generalize(A).qed(__file__)
コード例 #21
0
from proveit.basiclogic import Implies, Not, Equals, NotEquals
from proveit.basiclogic.equality.axioms import equals_symmetry
from proveit.common import x, y

# hypothesis = (x != y)
hypothesis = NotEquals(x, y)
# in_bool(x=y)
Equals(x, y).deduce_in_bool()
# in_bool(y=x)
Equals(y, x).deduce_in_bool()
# Not(x=y) => Not(y=x)
equals_symmetry.instantiate({x: y, y: x}).transpose().proven()
# Not(x=y) assuming (x != y)
NotEquals(x, y).unfold({hypothesis})
# (y != x) assuming Not(x = y)
y_neq_x = Not(Equals(y, x)).derive_not_equals({Not(Equals(y, x))})
# forall_{x, y} (x != y) => (y != x)
y_neq_x.as_implication({hypothesis}).generalize((x, y)).qed(__file__)
コード例 #22
0
from proveit.basiclogic import Implies, Not
from proveit.common import A

# Not(Not(A)) assuming A
notNotA = Not(Not(A)).concludeViaDoubleNegation()
Implies(A,
        notNotA.equateNegatedToFalse().deriveReversed()).generalize(A).qed(
            __file__)
コード例 #23
0
from proveit.basiclogic.booleans.theorems import double_negate_conclusion
from proveit.basiclogic import Implies, Not, BOOLEANS, in_bool
from proveit.common import A, B

# [B => Not(Not(A))] => [Not(A)=>Not(B)] assuming in_bool(A), in_bool(B)
to_conclusion = Implies(B, Not(Not(A))).transposition()
# [B => A] => [B => Not(Not(A))] assuming in_bool(A)
from_hyp = double_negate_conclusion.instantiate({
    A: B,
    B: A
}).proven({in_bool(A)})
# [B => A] => [Not(A)=>Not(B)] assuming in_bool(A), in_bool(B)
transposition_expr = from_hyp.apply_syllogism(to_conclusion).proven(
    {in_bool(A), in_bool(B)})
# forall_{A, B in BOOLEANS} [B=>A] => [Not(A) => Not(B)]
transposition_expr.generalize((A, B), domain=BOOLEANS).qed(__file__)
コード例 #24
0
ファイル: doubleNegation.py プロジェクト: wdcraft01/Prove-It
from proveit.basiclogic.boolean.axioms import notT
from proveit.basiclogic.boolean.theorems import notFromEqFalse
from proveit.basiclogic import Implies, Not, deriveStmtEqTrue
from proveit.common import A, X

# A=TRUE assuming A
AeqT = deriveStmtEqTrue(A)
# [Not(A)=FALSE] assuming A=TRUE
AeqT.substitution(Not(A)).applyTransitivity(notT).proven({AeqT})
# [Not(A)=FALSE] => Not(Not(A))
notFromEqFalse.specialize({A: Not(A)}).proven()
# forall_{A} A => Not(Not(A))
Implies(A, Not(Not(A))).generalize(A).qed(__file__)
コード例 #25
0
from proveit.basiclogic import Implies, Not, FALSE, inBool
from proveit.common import A, B

# hypothesis = [Not(B) => Not(A)]
hypothesis = Implies(Not(B), Not(A))
# A=FALSE assuming Not(B)=>Not(A) and Not(B)
AeqF = Not(A).equateNegatedToFalse().proven({hypothesis, Not(B)})
# FALSE assuming Not(B)=>Not(A), Not(B), and A
AeqF.deriveRightViaEquivalence().proven({hypothesis, Not(B), A})
# B assuming inBool(B), (Not(B)=>Not(A)), A
Implies(Not(B), FALSE).deriveViaContradiction().proven({inBool(B), hypothesis, A})
# [Not(B) => Not(A)] => [A => B] by nested hypothetical reasoning assuming inBool(B)
transpositionExpr = Implies(hypothesis, Implies(A, B)).proven({inBool(B)})
# forall_{A, B | inBool(B)} [A => B] => [Not(B) => Not(A)]
transpositionExpr.generalize((A, B), conditions=inBool(B)).qed(__file__)
コード例 #26
0
from proveit.basiclogic.booleans.theorems import double_negation, from_double_negation
from proveit.basiclogic import BOOLEANS, in_bool, Not, Iff
from proveit.common import A

# A => Not(Not(A))
double_negation_implied = double_negation.instantiate().proven()
# Not(Not(A)) => A
implies_double_negation = from_double_negation.instantiate().proven()
# [A => Not(Not(A))] in BOOLEANS if A in BOOLEANS
double_negation_implied.deduce_in_bool().proven({in_bool(A)})
# [Not(Not(A)) => A] in BOOLEANS if A in BOOLEANS
implies_double_negation.deduce_in_bool().proven({in_bool(A)})
# forall_{A} A = Not(Not(A))
Iff(A, Not(Not(A))).conclude_via_composition().derive_equality().generalize(
    A, domain=BOOLEANS).qed(__file__)
コード例 #27
0
from proveit.basiclogic.booleans.axioms import implicit_not_f, implicit_not_t
from proveit.basiclogic import Implies, Not, derive_stmt_eq_true
from proveit.common import A

# hypothesis: Not(Not(A))
hypothesis = Not(Not(A))
# [Not(Not(A)) = TRUE] assuming hypothesis
derive_stmt_eq_true(hypothesis).proven({hypothesis})
# [Not(A) = FALSE] assuming hypothesis
implicit_not_f.instantiate(
    {A: Not(A)}).derive_conclusion().proven({hypothesis})
# A assuming hypothesis
implicit_not_t.instantiate().derive_conclusion(
).derive_via_boolean_equality().proven({hypothesis})
# forall_{A} Not(Not(A)) => A
Implies(Not(Not(A)), A).generalize(A).qed(__file__)
コード例 #28
0
from proveit.basiclogic.equality.axioms import not_equals_def
from proveit.basiclogic import Not, Equals, in_bool
from proveit.common import x, y, X

# Not(x = y) in BOOLEANS
Not(Equals(x, y)).deduce_in_bool().proven()
# forall_{x, y} (x != y) in BOOLEANS
not_equals_def.instantiate().sub_left_side_into(in_bool(X), X).generalize(
    (x, y)).qed(__file__)
コード例 #29
0
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__)
コード例 #30
0
from proveit.basiclogic.booleans.theorems import or_contradiction
from proveit.basiclogic import Implies, Not, Or, FALSE, in_bool
from proveit.common import A, B

# (A or B) => FALSE assuming Not(A), Not(B)
or_contradiction.instantiate().proven({Not(A), Not(B)})
# By contradiction: A assuming in_bool(A), A or B, Not(B)
Implies(Not(A), FALSE).derive_via_contradiction().proven(
    {in_bool(A), Or(A, B), Not(B)})
# forall_{A, B | in_bool(A), Not(B)} (A or B) => A
Implies(Or(A, B), A).generalize((A, B),
                                conditions=(in_bool(A), Not(B))).qed(__file__)