Exemplo n.º 1
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__)
Exemplo n.º 2
0
from proveit.basiclogic.booleans.axioms import exists_def
from proveit.basiclogic import Equals, Or
from proveit.common import P, S, X, Qetc

# exists_{..x.. in S | ..Q(..x..)..} P(..x..) = not(forall_{..x.. |
# ..Q(..x..)..} P(..x..) != TRUE)
exists_def_spec = exists_def.instantiate().proven()
# [not(forall_{..x.. in S | ..Q(..x..)..} P(..x..) != TRUE) = TRUE] or [not(forall_{..x.. in S| ..Q(..x..)..} P(..x..) != TRUE) = FALSE]
rhs_true, rhs_false = exists_def_spec.rhs.deduce_in_bool().unfold().proven(
).operands
# exists_{..x.. in S | ..Q(..x..)..} P(..x..) in BOOLEANS assuming
# [not(forall_{..x.. in S | ..Q(..x..)..} P(..x..) != TRUE) = TRUE]
exists_in_bool_spec = rhs_true.sub_right_side_into(
    Equals(exists_def_spec.lhs, X),
    X).in_bool_via_boolean_equality().proven({rhs_true})
# exists_{..x.. | ..Q(..x..)..} P(..x..) in BOOLEANS assuming
# [not(forall_{..x.. in S | ..Q..(..x..)} P(..x..) != TRUE) = FALSE]
rhs_false.sub_right_side_into(Equals(exists_def_spec.lhs, X),
                              X).in_bool_via_boolean_equality().proven(
                                  {rhs_false})
# deduce rhs_true, rhs_fals, exists_in_bool_spec all in BOOLEANS
for expr in (rhs_true, rhs_false, exists_in_bool_spec):
    expr.deduce_in_bool()
# forall_{P, ..Q.., S} exists_{..x.. | ..Q(..x..)..} P(..x..) in BOOLEANS
Or(rhs_true,
   rhs_false).derive_common_conclusion(exists_in_bool_spec).generalize(
       (P, Qetc, S)).qed(__file__)
Exemplo n.º 3
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__)
Exemplo n.º 4
0
from proveit.basiclogic.booleans.axioms import or_f_t, false_not_true
from proveit.basiclogic.booleans.theorems import false_eq_false
from proveit.basiclogic import FALSE, in_bool, Or, Equals, derive_stmt_eq_true
from proveit.common import X

# [FALSE or TRUE]
or_f_t.derive_via_boolean_equality().proven()
# [FALSE or FALSE=FALSE] via [FALSE or TRUE] and FALSE=FALSE
derive_stmt_eq_true(false_eq_false).sub_left_side_into(Or(FALSE, X),
                                                       X).proven()
# [FALSE=TRUE or FALSE=FALSE] via [FALSE or FALSE=FALSE] and Not(FALSE=TRUE)
false_not_true.unfold().equate_negated_to_false().sub_left_side_into(
    Or(X, Equals(FALSE, FALSE)), X).proven()
# in_bool(FALSE) via [FALSE=TRUE or FALSE=FALSE]
in_bool(FALSE).conclude_as_folded().qed(__file__)
Exemplo n.º 5
0
from proveit.basiclogic import Forall, Implies, Or, Equals, TRUE, FALSE, BOOLEANS, inBool
from proveit.common import A, B

# [(A=>B) = TRUE] or [(A=>B) = FALSE] assuming A, B in BOOLEANS
Forall(
    (A, B),
    Or(Equals(Implies(A, B), TRUE), Equals(Implies(A, B), FALSE)),
    domain=BOOLEANS).proveByEval().specialize().proven({inBool(A),
                                                        inBool(B)})
# forall_{A in BOOLEANS} (A => B) in BOOLEANS
inBool(Implies(A, B)).concludeAsFolded().generalize(
    (A, B), domain=BOOLEANS).qed(__file__)
Exemplo n.º 6
0
from proveit.basiclogic.boolean.axioms import boolsDef
from proveit.basiclogic.set.axioms import singletonDef
from proveit.basiclogic import Implies, In, inBool, Singleton, Union, Equals, TRUE, FALSE, Or
from proveit.common import x, y, A, X

# hypothesis = (A=TRUE or A=FALSE)
hypothesis = Or(Equals(A, TRUE), Equals(A, FALSE))
# (A=TRUE) or (A in {FALSE}) assuming hypothesis
singletonDef.specialize({
    x: A,
    y: FALSE
}).subLeftSideInto(Or(Equals(A, TRUE), X), X).proven({hypothesis})
# (A in {TRUE}) or (A in {FALSE}) assuming hypothesis
singletonDef.specialize({
    x: A,
    y: TRUE
}).subLeftSideInto(Or(X, In(A, Singleton(FALSE))), X).proven({hypothesis})
# [A in ({TRUE} union {FALSE})] assuming hypothesis
In(A, Union(Singleton(TRUE), Singleton(FALSE))).concludeAsFolded()
# (A in BOOLEANS) assuming hypothesis
boolsDef.subLeftSideInto(In(A, X), X).proven({hypothesis})
# forall_{A} (A=TRUE or A=FALSE) => inBool(A)
Implies(hypothesis, inBool(A)).generalize(A).qed(__file__)
Exemplo n.º 7
0
from proveit.basiclogic.boolean.axioms import orFT, falseNotTrue
from proveit.basiclogic.boolean.theorems import falseEqFalse
from proveit.basiclogic import FALSE, inBool, Or, Equals, deriveStmtEqTrue
from proveit.common import X

# [FALSE or TRUE]
orFT.deriveViaBooleanEquality().proven()
# [FALSE or FALSE=FALSE] via [FALSE or TRUE] and FALSE=FALSE
deriveStmtEqTrue(falseEqFalse).subLeftSideInto(Or(FALSE, X), X).proven()
# [FALSE=TRUE or FALSE=FALSE] via [FALSE or FALSE=FALSE] and Not(FALSE=TRUE)
falseNotTrue.unfold().equateNegatedToFalse().subLeftSideInto(
    Or(X, Equals(FALSE, FALSE)), X).proven()
# inBool(FALSE) via [FALSE=TRUE or FALSE=FALSE]
inBool(FALSE).concludeAsFolded().qed(__file__)
Exemplo n.º 8
0
from proveit.basiclogic import Forall, Iff, Or, Equals, TRUE, FALSE, BOOLEANS, in_bool
from proveit.common import A, B

# [(A<=>B) = TRUE] or [(A<=>B) = FALSE] assuming A, B in BOOLEANS
Forall((A, B), Or(Equals(Iff(A, B), TRUE), Equals(Iff(A, B), FALSE)),
       domain=BOOLEANS).prove_by_eval().instantiate().proven({in_bool(A), in_bool(B)})
# forall_{A in BOOLEANS} (A <=> B) in BOOLEANS
in_bool(Iff(A, B)).conclude_as_folded().generalize(
    (A, B), domain=BOOLEANS).qed(__file__)
Exemplo n.º 9
0
from proveit.basiclogic.boolean.axioms import orTF
from proveit.basiclogic.boolean.theorems import trueNotFalse, trueEqTrue
from proveit.basiclogic import TRUE, FALSE, inBool, Or, Equals, deriveStmtEqTrue
from proveit.common import X

# [TRUE or FALSE]
orTF.deriveViaBooleanEquality().proven()
# [TRUE or TRUE=FALSE] via [TRUE or FALSE] and TRUE != FALSE
trueNotFalse.unfold().equateNegatedToFalse().subLeftSideInto(Or(TRUE, X), X).proven()
# [TRUE=TRUE or TRUE=FALSE] via [TRUE or TRUE=FALSE] and TRUE=TRUE
deriveStmtEqTrue(trueEqTrue).subLeftSideInto(Or(X, Equals(TRUE, FALSE)), X).proven()
# inBool(TRUE) via [TRUE=TRUE or TRUE=FALSE]
inBool(TRUE).concludeAsFolded().qed(__file__)
Exemplo n.º 10
0
from proveit.basiclogic.boolean.theorems import orContradiction
from proveit.basiclogic import Implies, Not, Or, FALSE, inBool
from proveit.common import A, B

# (A or B) => FALSE assuming Not(A), Not(B)
orContradiction.specialize().proven({Not(A), Not(B)})
# By contradiction: B assuming inBool(B), (A or B), Not(A)
Implies(Not(B),
        FALSE).deriveViaContradiction().proven({inBool(B),
                                                Or(A, B),
                                                Not(A)})
# forall_{A, B | Not(A), inBool(B)} (A or B) => B
Implies(Or(A, B), B).generalize((A, B),
                                conditions=(Not(A), inBool(B))).qed(__file__)
Exemplo n.º 11
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__)
Exemplo n.º 12
0
from proveit.basiclogic import Forall, Iff, Or, Equals, TRUE, FALSE, BOOLEANS, inBool
from proveit.common import A, B

# [(A<=>B) = TRUE] or [(A<=>B) = FALSE] assuming A, B in BOOLEANS
Forall(
    (A, B),
    Or(Equals(Iff(A, B), TRUE), Equals(Iff(A, B), FALSE)),
    domain=BOOLEANS).proveByEval().specialize().proven({inBool(A),
                                                        inBool(B)})
# forall_{A in BOOLEANS} (A <=> B) in BOOLEANS
inBool(Iff(A, B)).concludeAsFolded().generalize((A, B),
                                                domain=BOOLEANS).qed(__file__)
Exemplo n.º 13
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: B assuming in_bool(B), (A or B), Not(A)
Implies(Not(B), FALSE).derive_via_contradiction().proven(
    {in_bool(B), Or(A, B), Not(A)})
# forall_{A, B | Not(A), in_bool(B)} (A or B) => B
Implies(Or(A, B), B).generalize((A, B),
                                conditions=(Not(A), in_bool(B))).qed(__file__)
Exemplo n.º 14
0
from proveit.basiclogic.booleans.axioms import not_t
from proveit.basiclogic import BOOLEANS, FALSE, in_bool, Implies, And, Or, Not, derive_stmt_eq_true
from proveit.common import A, B, C, X

AorB = Or(A, B)
hypothesis = And(Implies(A, C), Implies(B, C))
ABCareBool = {in_bool(A), in_bool(B), in_bool(C)}
# A=>C, B=>C assuming (A=>C and B=>C)
AimplC, _ = hypothesis.decompose()
# Not(A) assuming in_bool(A), in_bool(B), (A=>C and B=>C), Not(C)
AimplC.transpose().derive_conclusion().proven(
    {in_bool(A), in_bool(C), hypothesis, Not(C)})
# B assuming in_bool(A, B, C), (A=>C and B=>C), (A or B), Not(C)
AorB.derive_right_if_not_left().proven(ABCareBool | {hypothesis, AorB, Not(C)})
# Not(TRUE) assuming in_bool(A, B, C), (A=>C and B=>C), (A or B), Not(C)
derive_stmt_eq_true(C).sub_right_side_into(
    Not(X), X).proven(
        ABCareBool | {
            hypothesis, AorB, Not(C)})
# FALSE assuming in_bool(A, B, C), (A=>C and B=>C), (A or B), Not(C)
not_t.derive_right_via_equality().proven(
    ABCareBool | {hypothesis, AorB, Not(C)})
# Contradiction proof of C assuming (A=>C and B=>C), (A or B), in_bool(A),
# and in_bool(B)
Implies(
    Not(C),
    FALSE).derive_via_contradiction().proven(
        ABCareBool | {
            hypothesis,
            AorB})
# forall_{A, B, C in BOOLEANS} (A=>C and B=>C) => ((A or B) => C)
Exemplo n.º 15
0
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__)
Exemplo n.º 16
0
from proveit.basiclogic.booleans.axioms import or_t_f
from proveit.basiclogic.booleans.theorems import true_not_false, true_eq_true
from proveit.basiclogic import TRUE, FALSE, in_bool, Or, Equals, derive_stmt_eq_true
from proveit.common import X

# [TRUE or FALSE]
or_t_f.derive_via_boolean_equality().proven()
# [TRUE or TRUE=FALSE] via [TRUE or FALSE] and TRUE != FALSE
true_not_false.unfold().equate_negated_to_false().sub_left_side_into(
    Or(TRUE, X), X).proven()
# [TRUE=TRUE or TRUE=FALSE] via [TRUE or TRUE=FALSE] and TRUE=TRUE
derive_stmt_eq_true(true_eq_true).sub_left_side_into(
    Or(X, Equals(TRUE, FALSE)), X).proven()
# in_bool(TRUE) via [TRUE=TRUE or TRUE=FALSE]
in_bool(TRUE).conclude_as_folded().qed(__file__)
Exemplo n.º 17
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__)
Exemplo n.º 18
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__)
Exemplo n.º 19
0
from proveit.basiclogic import Forall, And, Or, Equals, TRUE, FALSE, BOOLEANS, inBool
from proveit.common import A, B

# [(A and B) = TRUE] or [(A and B) = FALSE] assuming A, B in BOOLEANS
Forall(
    (A, B),
    Or(Equals(And(A, B), TRUE), Equals(And(A, B), FALSE)),
    domain=BOOLEANS).proveByEval().specialize().proven({inBool(A),
                                                        inBool(B)})
# forall_{A, B in BOOLEANS} (A and B) in BOOLEANS
inBool(And(A, B)).concludeAsFolded().generalize((A, B),
                                                domain=BOOLEANS).qed(__file__)
Exemplo n.º 20
0
from proveit.basiclogic.boolean.axioms import boolsDef
from proveit.basiclogic.set.axioms import singletonDef
from proveit.basiclogic import Implies, In, inBool, Singleton, Equals, TRUE, FALSE, Or
from proveit.common import x, y, A, X

# [A in ({TRUE} union {FALSE})] assuming inBool(A)
AinTunionF = boolsDef.subRightSideInto(In(A, X), X).proven({inBool(A)})
# (A in {TRUE}) or (A in {FALSE}) assuming inBool(A)
AinTunionF.unfold().proven({inBool(A)})
# A=TRUE or (A in {FALSE}) assuming inBool(A)
singletonDef.specialize({x:A, y:TRUE}).subRightSideInto(Or(X, In(A, Singleton(FALSE))), X).proven({inBool(A)})
# A=TRUE or A=FALSE assuming inBool(A)
conclusion = singletonDef.specialize({x:A, y:FALSE}).subRightSideInto(Or(Equals(A, TRUE), X), X).proven({inBool(A)})
# forall_{A} inBool(A) => (A=TRUE or A=FALSE)
Implies(inBool(A), conclusion).generalize(A).qed(__file__)
Exemplo n.º 21
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__)
Exemplo n.º 22
0
from proveit.basiclogic.boolean.axioms import existsDef
from proveit.basiclogic import Equals, Or
from proveit.common import P, S, X, Qetc

# exists_{..x.. in S | ..Q(..x..)..} P(..x..) = not(forall_{..x.. | ..Q(..x..)..} P(..x..) != TRUE)
existsDefSpec = existsDef.specialize().proven()
# [not(forall_{..x.. in S | ..Q(..x..)..} P(..x..) != TRUE) = TRUE] or [not(forall_{..x.. in S| ..Q(..x..)..} P(..x..) != TRUE) = FALSE]
rhsTrue, rhsFalse = existsDefSpec.rhs.deduceInBool().unfold().proven().operands
# exists_{..x.. in S | ..Q(..x..)..} P(..x..) in BOOLEANS assuming [not(forall_{..x.. in S | ..Q(..x..)..} P(..x..) != TRUE) = TRUE]
existsInBoolSpec = rhsTrue.subRightSideInto(Equals(
    existsDefSpec.lhs, X), X).inBoolViaBooleanEquality().proven({rhsTrue})
# exists_{..x.. | ..Q(..x..)..} P(..x..) in BOOLEANS assuming [not(forall_{..x.. in S | ..Q..(..x..)} P(..x..) != TRUE) = FALSE]
rhsFalse.subRightSideInto(Equals(existsDefSpec.lhs, X),
                          X).inBoolViaBooleanEquality().proven({rhsFalse})
# deduce rhsTrue, rhsFals, existsInBoolSpec all in BOOLEANS
for expr in (rhsTrue, rhsFalse, existsInBoolSpec):
    expr.deduceInBool()
# forall_{P, ..Q.., S} exists_{..x.. | ..Q(..x..)..} P(..x..) in BOOLEANS
Or(rhsTrue, rhsFalse).deriveCommonConclusion(existsInBoolSpec).generalize(
    (P, Qetc, S)).qed(__file__)