from proveit.basiclogic.boolean.theorems import trueConclusion from proveit.basiclogic import deriveStmtEqTrue, TRUE from proveit.common import A deriveStmtEqTrue(trueConclusion.specialize({A:TRUE})).qed(__file__)
from proveit.basiclogic.boolean.theorems import foldForallOverBool from proveit.basiclogic import Implies, deriveStmtEqTrue from proveit.common import P # P(TRUE) and P(FALSE) => forall_{A in BOOLEANS} P(A) folding = foldForallOverBool.specialize() # forall_{P} [P(TRUE) and P(FALSE)] => {[forall_{A in BOOLEANS} P(A)] = TRUE} Implies(folding.hypothesis, deriveStmtEqTrue( folding.deriveConclusion())).generalize(P).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.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__)
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__)
from proveit.basiclogic.boolean.axioms import iffDef from proveit.basiclogic.boolean.theorems import impliesTT from proveit.basiclogic import compose, TRUE, deriveStmtEqTrue from proveit.common import A, B # TRUE => TRUE TimplT = impliesTT.deriveViaBooleanEquality() # (TRUE => TRUE) and (TRUE => TRUE) = TRUE TimplTandTimplT_eq_T = deriveStmtEqTrue(compose(TimplT, TimplT)) # (TRUE <=> TRUE) = TRUE iffDef.specialize({ A: TRUE, B: TRUE }).applyTransitivity(TimplTandTimplT_eq_T).qed(__file__)
from proveit.basiclogic.boolean.axioms import implicitNotF from proveit.basiclogic import Not, Implies, Equals, FALSE, deriveStmtEqTrue from proveit.common import A # [Not(A) = TRUE] => [A = FALSE] implicitNotF.specialize().proven() # [Not(A) = TRUE] assuming Not(A) deriveStmtEqTrue(Not(A)).proven({Not(A)}) # forall_{A} Not(A) => [A=FALSE] Implies(Not(A), Equals(A, FALSE)).generalize(A).qed(__file__)
from proveit.basiclogic import Implies, Equals, deriveStmtEqTrue from proveit.common import x, y, P, Px, Py # hypothesis = (x=y) hypothesis = Equals(x, y) # P(x) = P(y) assuming (x=y) Px_eq_Py = hypothesis.substitution(Px, x).proven({hypothesis}) # P(x) assuming (x=y), P(y) deriveStmtEqTrue(Py).applyTransitivity( Px_eq_Py).deriveViaBooleanEquality().proven({hypothesis, Py}) # forall_{P, x, y} {(x = y) => [P(x) => P(y)]}, by (nested) hypothetical reasoning Implies(Equals(x, y), Implies(Py, Px)).generalize((P, x, y)).qed(__file__)
from proveit.basiclogic.boolean.theorems import selfImplication from proveit.basiclogic import deriveStmtEqTrue, FALSE from proveit.common import A deriveStmtEqTrue(selfImplication.specialize({A: FALSE})).qed(__file__)
from proveit.basiclogic import Implies, deriveStmtEqTrue from proveit.common import A Implies(A, deriveStmtEqTrue(A).concludeBooleanEquality().deriveReversed()).generalize(A).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.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__)
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.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.boolean.axioms import iffDef from proveit.basiclogic.boolean.theorems import impliesFF from proveit.basiclogic import compose, FALSE, deriveStmtEqTrue from proveit.common import A, B # FALSE => FALSE FimplF = impliesFF.deriveViaBooleanEquality() # (FALSE => FALSE) and (FALSE => FALSE) = TRUE FimplFandFimplF_eq_T = deriveStmtEqTrue(compose(FimplF, FimplF)) # (FALSE <=> FALSE) = TRUE iffDef.specialize({ A: FALSE, B: FALSE }).applyTransitivity(FimplFandFimplF_eq_T).qed(__file__)
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__)
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__)
from proveit.basiclogic.boolean.theorems import trueAndTrue from proveit.basiclogic import deriveStmtEqTrue, And, TRUE from proveit.common import A, B, X # A=TRUE assuming A AeqT = deriveStmtEqTrue(A).proven({A}) # B=TRUE assuming B BeqT = deriveStmtEqTrue(B).proven({B}) # TRUE AND TRUE trueAndTrue # (TRUE and B) assuming B via (TRUE and TRUE) BeqT.subLeftSideInto(And(TRUE, X), X).proven({B}) # (A and B) assuming A, B via (TRUE and TRUE) AeqT.subLeftSideInto(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__)