def _defineTheorems(): # Forall_{A**, B**} ([A**] in X*) and ([B**] in X*) => [A**, B**] in X** _firstAxiom = combining_in_kleene = Forall([multi_a, X], Implies( In(List(multi_a), KleeneRepetition(X)), In(List(multi_a, X), KleeneRepetition(X)))) return None
def _defineAxioms(): # Forall_X [()] in X** _firstAxiom =\ nullsetInKleene = Forall(X, In(List(), KleeneRepetition(X))) # Forall_{A**, X} [A**] in X* => [A**, X] in X* concatenationInKleene = Forall([multiA, X], Implies( In(List(multiA), KleeneRepetition(X)), In(List(multiA, X), KleeneRepetition(X)))) return _firstAxiom, locals()
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.expression import Operation, Lambda from proveit.statement import Axioms 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))
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 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__)
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__)
from proveit.basiclogic.booleans.axioms import bools_def from proveit.basiclogic.set.axioms import singleton_def from proveit.basiclogic import Implies, In, in_bool, 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 singleton_def.instantiate({ x: A, y: FALSE }).sub_left_side_into(Or(Equals(A, TRUE), X), X).proven({hypothesis}) # (A in {TRUE}) or (A in {FALSE}) assuming hypothesis singleton_def.instantiate({ x: A, y: TRUE }).sub_left_side_into(Or(X, In(A, Singleton(FALSE))), X).proven({hypothesis}) # [A in ({TRUE} union {FALSE})] assuming hypothesis In(A, Union(Singleton(TRUE), Singleton(FALSE))).conclude_as_folded() # (A in BOOLEANS) assuming hypothesis bools_def.sub_left_side_into(In(A, X), X).proven({hypothesis}) # forall_{A} (A=TRUE or A=FALSE) => in_bool(A) Implies(hypothesis, in_bool(A)).generalize(A).qed(__file__)
from proveit.expression import Operation, Lambda from proveit.statement import Axioms from proveit.basiclogic import Forall, Equals, In, TRUE, Iff, Implies, And from .mapping_ops import Domain, CoDomain from proveit.common import f, g, x, y, Q, fx, fy, gx, Qx, Qy fx_map = Lambda(x, fx) # x -> f(x) fx_given_qx_map = Lambda(x, fx, Qx) # x -> f(x) | Q(x) gx_given_qx_map = Lambda(x, gx, Qx) # x -> g(x) | Q(x) f_domain_eq_gDomain = Equals(Domain(f), Domain(g)) # Domain(f) = Domain(g) fx_eq_gx = Equals(fx, gx) # f(x) = g(x) x_in_f_domain = In(x, Domain(f)) # x in Domain(f) f_eq_g = Equals(f, g) # f = g mapping_axioms = Axioms(__package__, locals()) map_application = Forall((f, Q), Forall(y, Equals(Operation(fx_given_qx_map, y), fy), Qy)) # forall_{f} [x -> f(x)] = [x -> f(x) | TRUE] lambda_over_all_def = 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) lambda_domain_def = Forall((f, Q), Forall(y, Iff(In(y, Domain(fx_given_qx_map)), Qy))) # forall_{f, g} [Domain(f) = Domain(g) and forall_{x in Domain(f)} f(x) = # g(x)] => (f = g)} map_is_as_map_does = Forall( (f, g),