import proveit
# Prepare this notebook for defining the theorems of a theory:
%theorems_notebook # Keep this at the top following 'import proveit'.
from proveit import ExprRange, IndexedVar
from proveit.logic import Equals, NotEquals, Implies, Not, And, Forall, FALSE, in_bool
from proveit import A, a, b, c, d, i, n, x, y, z, f, P, fa, fab, fx, fxy, Px, Py, Q
from proveit.core_expr_types import (x_1_to_n, x_1_to_np1, x_i, y_1_to_n, x_eq_y__1_to_n,
f__x_1_to_n, f__y_1_to_n, P__x_1_to_n, P__y_1_to_n)
from proveit.logic import PofTrue, PofFalse
from proveit.logic.equality import elementwise_equality
from proveit.numbers import one, Natural, NaturalPos, Add
%begin theorems
four_chain_transitivity = Forall((a, b, c, d), Equals(a, d), conditions=[Equals(a, b), Equals(b, c), Equals(c, d)])
transitivity_chain = Forall(
n, Forall(x_1_to_np1, Equals(IndexedVar(x, one), IndexedVar(x, Add(n, one))),
conditions=[ExprRange(i, Equals(x_i, IndexedVar(x, Add(i, one))),
one, n)]),
domain=NaturalPos)
sub_left_side_into = Forall((P, x, y), Px, conditions=[Py, Equals(x, y)])
lhs_via_equality = Forall((P, Q), P, conditions=[Q, Equals(P, Q)])
equals_reversal = Forall((x, y), Equals(y, x), conditions=[Equals(x, y)])
sub_right_side_into = Forall((P, x, y), Py, conditions=[Px, Equals(x, y)])
rhs_via_equality = Forall((P, Q), Q, conditions=[P, Equals(P, Q)])
substitute_in_true = Forall((P, x), PofTrue, conditions=[Px, x])
substitute_truth = Forall((P, x), Px, conditions=[PofTrue, x])
substitute_in_false = Forall((P, x), PofFalse, conditions=[Px, Not(x)])
substitute_falsehood = Forall((P, x), Px, conditions=[PofFalse, Not(x)])
unfold_not_equals = Forall((x, y), Not(Equals(x, y)), conditions=[NotEquals(x, y)])
fold_not_equals = Forall((x, y), NotEquals(x, y), conditions=[Not(Equals(x, y))])
$\neq$ is also symmetric:
not_equals_symmetry = Forall((x, y), NotEquals(y, x), conditions=[NotEquals(x, y)])
If two things are both equal and not equal, there is a contradiction:
not_equals_contradiction = Forall((x, y), FALSE, conditions=[Equals(x, y), NotEquals(x, y)])
sub_in_left_operands = Forall(n, Forall((P, x_1_to_n, y_1_to_n), P__x_1_to_n,
conditions=[P__y_1_to_n, x_eq_y__1_to_n]),
domain=Natural)
sub_in_right_operands = Forall(n, Forall((P, x_1_to_n, y_1_to_n), P__y_1_to_n,
conditions=[P__x_1_to_n, x_eq_y__1_to_n]),
domain=Natural)
sub_in_left_operands_via_tuple = Forall(n, Forall((P, x_1_to_n, y_1_to_n), P__x_1_to_n,
conditions=[P__y_1_to_n, Equals([x_1_to_n], [y_1_to_n])]),
domain=Natural)
sub_in_right_operands_via_tuple = Forall(n, Forall((P, x_1_to_n, y_1_to_n), P__y_1_to_n,
conditions=[P__x_1_to_n, Equals([x_1_to_n], [y_1_to_n])]),
domain=Natural)
multi_substitution = Forall(n, Forall((f, x_1_to_n, y_1_to_n),
Equals(f__x_1_to_n, f__y_1_to_n),
conditions=[elementwise_equality]),
domain=NaturalPos)
mult_sub_left_into = Forall(n, Forall((P, x_1_to_n, y_1_to_n), P__x_1_to_n,
conditions=[P__y_1_to_n, elementwise_equality]),
domain=Natural)
mult_sub_right_into = Forall(n, Forall((P, x_1_to_n, y_1_to_n), P__y_1_to_n,
conditions=[P__x_1_to_n, elementwise_equality]),
domain=Natural)
unary_evaluation = Forall((f, x, a, c), Implies(Equals(x, a), Implies(Equals(fa, c), Equals(fx, c))))
binary_substitution = Forall((f, x, y, a, b), Implies(And(Equals(x, a), Equals(y, b)), Equals(fxy, fab)))
binary_evaluation = Forall((f, x, y, a, b, c), Implies(And(Equals(x, a), Equals(y, b)), Implies(Equals(fab, c), Equals(fxy, c))))
# Proven
not_equals_is_bool = Forall((x, y), in_bool(NotEquals(x, y)))
contradiction_via_falsification = Forall(A, FALSE, conditions=[A, Equals(A, FALSE)])
%end theorems