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__)
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__)
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__)
from proveit.basiclogic import Implies, BOOLEANS, FALSE, inBool, compose, NotEquals from proveit.common import A # AnotF = (A != FALSE) AnotF = NotEquals(A, FALSE) # notAeqF = Not(A = FALSE) notAeqF = AnotF.unfold() # (A=TRUE or A=FALSE) assuming inBool(A) AeqT_or_AeqF = inBool(A).unfold() AeqT = AeqT_or_AeqF.operands[0] # Not(A=FALSE) and (A=TRUE or A=FALSE) assuming each compose(notAeqF, AeqT_or_AeqF).proven({AnotF, AeqT_or_AeqF}) # inBool(A=TRUE) AeqT.deduceInBool() # A assuming inBool(A), Not(A=FALSE) AeqT_or_AeqF.deriveLeftIfNotRight().deriveViaBooleanEquality().proven( {inBool(A), AnotF}) # forall_{A in BOOLEANS} Not(A=FALSE) => A Implies(AnotF, A).generalize(A, domain=BOOLEANS).qed(__file__)
from proveit.basiclogic import Implies, BOOLEANS, FALSE, in_bool, compose, NotEquals from proveit.common import A # Anot_f = (A != FALSE) Anot_f = NotEquals(A, FALSE) # not_aeq_f = Not(A = FALSE) not_aeq_f = Anot_f.unfold() # (A=TRUE or A=FALSE) assuming in_bool(A) AeqT_or_AeqF = in_bool(A).unfold() AeqT = AeqT_or_AeqF.operands[0] # Not(A=FALSE) and (A=TRUE or A=FALSE) assuming each compose(not_aeq_f, AeqT_or_AeqF).proven({Anot_f, AeqT_or_AeqF}) # in_bool(A=TRUE) AeqT.deduce_in_bool() # A assuming in_bool(A), Not(A=FALSE) AeqT_or_AeqF.derive_left_if_not_right().derive_via_boolean_equality().proven( {in_bool(A), Anot_f}) # forall_{A in BOOLEANS} Not(A=FALSE) => A Implies(Anot_f, A).generalize(A, domain=BOOLEANS).qed(__file__)
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__)
from proveit.basiclogic.booleans.theorems import true_not_false from proveit.basiclogic import FALSE, Implies, derive_stmt_eq_true, NotEquals from proveit.common import A, X # A=TRUE assuming A AeqT = derive_stmt_eq_true(A) # TRUE != FALSE true_not_false # (A != FALSE) assuming A Anot_f = AeqT.sub_left_side_into(NotEquals(X, FALSE), X).proven({A}) # forall_{A} A => (A != FALSE) Implies(A, Anot_f).generalize(A).qed(__file__)
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__)
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 import Implies, Not, FALSE, in_bool, Equals, NotEquals from proveit.common import A, B, X # in_bool(B=FALSE) Equals(B, FALSE).deduce_in_bool() # [Not(B=FALSE) => Not(A)] => [A => (B=FALSE)], using in_bool(B=FALSE) mid_point_back_half = Implies(Not(Equals(B, FALSE)), Not(A)).transposition() # [(B != FALSE) => Not(A)] => [Not(B=FALSE) => Not(A)] mid_point_front_half = NotEquals( B, FALSE).definition().rhs_statement_substitution(Implies(X, Not(A)), X).proven() # [(B != FALSE) => Not(A)] => [A => (B=FALSE)] mid_point = mid_point_front_half.apply_syllogism(mid_point_back_half).proven() # B assuming (B != FALSE) and in_bool(B) not_beq_f = NotEquals(B, FALSE) not_beq_f.derive_via_double_negation().proven({not_beq_f, in_bool(B)}) # [B => Not(A)] => [(B != FALSE) => Not(A)] assuming in_bool(B) from_hyp = Implies(Implies(B, Not(A)), Implies(not_beq_f, Not(A))).proven({in_bool(B)}) # Not(B) assuming B=FALSE BeqF = Equals(B, FALSE) BeqF.derive_via_boolean_equality().proven({BeqF}) # [A => (B=FALSE)] => [A => Not(B)] assuming in_bool(B) to_conclusion = Implies(Implies(A, BeqF), Implies(A, Not(B))).proven({in_bool(B)}) # [B => Not(A)] => [A=>Not(B)] assuming in_bool(B) transposition_expr = from_hyp.apply_syllogism(mid_point).apply_syllogism( to_conclusion).proven({in_bool(B)}) # forall_{A, B | in_bool(B)} [B => Not(A)] => [A=>Not(B)] transposition_expr.generalize((A, B), conditions=in_bool(B)).qed(__file__)
from proveit.basiclogic import Implies, Not, FALSE, inBool, Equals, NotEquals from proveit.common import A, B, X # inBool(B=FALSE) Equals(B, FALSE).deduceInBool() # [Not(B=FALSE) => Not(A)] => [A => (B=FALSE)], using inBool(B=FALSE) midPointBackHalf = Implies(Not(Equals(B, FALSE)), Not(A)).transposition() # [(B != FALSE) => Not(A)] => [Not(B=FALSE) => Not(A)] midPointFrontHalf = NotEquals(B, FALSE).definition().rhsStatementSubstitution(Implies(X, Not(A)), X).proven() # [(B != FALSE) => Not(A)] => [A => (B=FALSE)] midPoint = midPointFrontHalf.applySyllogism(midPointBackHalf).proven() # B assuming (B != FALSE) and inBool(B) notBeqF = NotEquals(B, FALSE) notBeqF.deriveViaDoubleNegation().proven({notBeqF, inBool(B)}) # [B => Not(A)] => [(B != FALSE) => Not(A)] assuming inBool(B) fromHyp = Implies(Implies(B, Not(A)), Implies(notBeqF, Not(A))).proven({inBool(B)}) # Not(B) assuming B=FALSE BeqF = Equals(B, FALSE) BeqF.deriveViaBooleanEquality().proven({BeqF}) # [A => (B=FALSE)] => [A => Not(B)] assuming inBool(B) toConclusion = Implies(Implies(A, BeqF), Implies(A, Not(B))).proven({inBool(B)}) # [B => Not(A)] => [A=>Not(B)] assuming inBool(B) transpositionExpr = fromHyp.applySyllogism(midPoint).applySyllogism(toConclusion).proven({inBool(B)}) # forall_{A, B | inBool(B)} [B => Not(A)] => [A=>Not(B)] transpositionExpr.generalize((A, B), conditions=inBool(B)).qed(__file__)