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)
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())
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__)
from proveit.basiclogic.equality.theorems import binary_substitution from proveit.basiclogic import Implies, And, Equals from proveit.common import a, b, c, f, x, y, fab # hypothesis = (x=a and y=b) hypothesis = And(Equals(x, a), Equals(y, b)) # [f(x, y) = f(a, b)] assuming hypothesis fxy_eq_fab = binary_substitution.instantiate().derive_conclusion().proven( {hypothesis}) # [f(a, b)=c] => [f(x, y)=c] assuming hypothesis conclusion = fxy_eq_fab.transitivity_impl(Equals(fab, c)).proven({hypothesis}) # forall_{f, x, y, a, b, c} [x=a and y=b] => {[f(a, b)=c] => [f(x, y)=c]} Implies(hypothesis, conclusion).generalize((f, x, y, a, b, c)).qed(__file__)
from proveit.basiclogic import Implies, And, Equals from proveit.common import a, b, f, x, y, fxy, fab # hypothesis = (x=a and y=b) hypothesis = And(Equals(x, a), Equals(y, b)) # f(x, y) = f(a, y) assuming hypothesis fxy_eq_fay = hypothesis.deriveLeft().substitution(fxy, x).proven({hypothesis}) # f(a, y) = f(a, b) assuming hypothesis fay_eq_fab = hypothesis.deriveRight().substitution(fab, b).proven({hypothesis}) # f(x, y) = f(a, b) assuming hypothesis conclusion = fxy_eq_fay.applyTransitivity(fay_eq_fab).proven({hypothesis}) # forall_{f, x, y, a, b} (x=a and y=b) => [f(x, y) = f(a, b)] Implies(hypothesis, conclusion).generalize((f, x, y, a, b)).qed(__file__)
from proveit.basiclogic import Forall, And, Or, Equals, TRUE, FALSE, BOOLEANS, in_bool 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).prove_by_eval().instantiate().proven( {in_bool(A), in_bool(B)}) # forall_{A, B in BOOLEANS} (A and B) in BOOLEANS in_bool(And(A, B)).conclude_as_folded().generalize( (A, B), domain=BOOLEANS).qed(__file__)
from proveit.basiclogic import And, Implies, Iff from proveit.common import A, B, C # hypothesis = (A <=> B) and (B <=> C) hypothesis = And(Iff(A, B), Iff(B, C)) AiffB, BiffC = hypothesis.decompose() # B assuming A <=> B and A AiffB.deriveRight().proven({AiffB, A}) # A => C assuming A <=> B, B <=> C Implies(A, BiffC.deriveRight()).proven({hypothesis}) # C assuming B <=> C and C BiffC.deriveLeft().proven({BiffC, C}) # C => A assuming A <=> B, B <=> C Implies(C, AiffB.deriveLeft()).proven({hypothesis}) # A <=> C assuming hypothesis AiffC = Iff(A, C).concludeViaComposition().proven({hypothesis}) # forall_{A, B, C} (A <=> B and B <=> C) => (A <=> C) Implies(hypothesis, AiffC).generalize((A, B, C)).qed(__file__)
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__)
from proveit.basiclogic import BOOLEANS, TRUE, FALSE, inBool, Implies, And, deriveStmtEqTrue, Equals from proveit.common import A, P, PofA from proveit.basiclogic.common import PofTrue, PofFalse # hypothesis = [P(TRUE) and P(FALSE)] hypothesis = And(PofTrue, PofFalse) # inBool(A=TRUE), inBool(A=FALSE), inBool(P(A) = TRUE) AeqT = Equals(A, TRUE) AeqF = Equals(A, FALSE) PofAeqT = Equals(PofA, TRUE) for eqExpr in (AeqT, AeqF, PofAeqT): eqExpr.deduceInBool() # P(TRUE), P(FALSE) assuming hypothesis for case in hypothesis.decompose(): case.proven({hypothesis}) # A=TRUE => P(A)=TRUE assuming hypothesis Implies(AeqT, deriveStmtEqTrue(AeqT.subLeftSideInto(PofA, A))).proven({hypothesis}) # A=FALSE => P(A)=TRUE assuming hypothesis Implies(AeqF, deriveStmtEqTrue(AeqF.subLeftSideInto(PofA, A))).proven({hypothesis}) # P(A) assuming hypothesis, (A in BOOLEANS) inBool(A).unfold().deriveCommonConclusion(PofAeqT).deriveViaBooleanEquality().proven({hypothesis, inBool(A)}) # forall_{P} P(TRUE) and P(FALSE) => forall_{A in BOOLEANS} P(A) Implies(hypothesis, PofA.generalize(A, domain=BOOLEANS)).generalize(P).qed(__file__)
from proveit.basiclogic import BOOLEANS, TRUE, FALSE, in_bool, Implies, And, derive_stmt_eq_true, Equals from proveit.common import A, P, PofA from proveit.basiclogic.common import PofTrue, PofFalse # hypothesis = [P(TRUE) and P(FALSE)] hypothesis = And(PofTrue, PofFalse) # in_bool(A=TRUE), in_bool(A=FALSE), in_bool(P(A) = TRUE) AeqT = Equals(A, TRUE) AeqF = Equals(A, FALSE) PofAeqT = Equals(PofA, TRUE) for eq_expr in (AeqT, AeqF, PofAeqT): eq_expr.deduce_in_bool() # P(TRUE), P(FALSE) assuming hypothesis for case in hypothesis.decompose(): case.proven({hypothesis}) # A=TRUE => P(A)=TRUE assuming hypothesis Implies(AeqT, derive_stmt_eq_true(AeqT.sub_left_side_into(PofA, A))).proven({hypothesis}) # A=FALSE => P(A)=TRUE assuming hypothesis Implies(AeqF, derive_stmt_eq_true(AeqF.sub_left_side_into(PofA, A))).proven({hypothesis}) # P(A) assuming hypothesis, (A in BOOLEANS) in_bool(A).unfold().derive_common_conclusion( PofAeqT).derive_via_boolean_equality().proven({hypothesis, in_bool(A)}) # forall_{P} P(TRUE) and P(FALSE) => forall_{A in BOOLEANS} P(A) Implies(hypothesis, PofA.generalize(A, domain=BOOLEANS)).generalize(P).qed(__file__)
from proveit.basiclogic.booleans.theorems import true_and_true from proveit.basiclogic import derive_stmt_eq_true, And, TRUE from proveit.common import A, B, X # A=TRUE assuming A AeqT = derive_stmt_eq_true(A).proven({A}) # B=TRUE assuming B BeqT = derive_stmt_eq_true(B).proven({B}) # TRUE AND TRUE true_and_true # (TRUE and B) assuming B via (TRUE and TRUE) BeqT.sub_left_side_into(And(TRUE, X), X).proven({B}) # (A and B) assuming A, B via (TRUE and TRUE) AeqT.sub_left_side_into(And(X, B), X).proven({A, B}) # forall_{A | A, B | B} (A and B) And(A, B).generalize((A, B), conditions=(A, B)).qed(__file__)