from proveit import ExprTuple
from proveit import a, b, c, d, e, f, A,B,C,D,E,F,G,H, i, j, k, l, m,n
from proveit.core_expr_types import A_1_to_m, B_1_to_n,C_1_to_n
from proveit.logic import And, Or, Not, TRUE, FALSE, Equals, in_bool, Boolean
from proveit.numbers import zero, one, two, three,five,Add, Exp, subtract
%begin demonstrations
#And(A,B,C,D,E,F).derive_some_from_and(3, assumptions=[And(A,B,C,var_iter(D, one, one),E,F)])
#And(var_iter(A, one, five), var_iter(B, one, two), var_iter(C, one, three)).derive_some_from_and(1)
#And(A_1_to_m, B_1_to_n, C_1_to_n).derive_some_from_and(1)
Equals(Add(zero, Add(subtract(m, one), one)), Add(subtract(m, one), one))
#Equals(Add(zero, Add(subtract(m, one), one)), Add(subtract(m, one), one)).prove()
expr = And(a, b, c, d, e, f)
expr.copy().with_wrapping_at(3)
new_expr = expr.copy().with_wrapping_at(3)
expr
new_expr
expr = And(Or(a, b, c), Or(b, c, d), Or(d, e, f))
new_expr = expr.copy()
new_expr.inner_expr().operands[1].with_wrapping_at(3)
expr
print(expr==new_expr)
And(TRUE, TRUE).evaluation()
And(TRUE, TRUE, TRUE).evaluation()
Not(FALSE).prove()
And(TRUE, Not(FALSE), TRUE).evaluation()
And(TRUE, Not(FALSE), TRUE).prove()
And(TRUE, Not(FALSE), TRUE).evaluation()
Or(TRUE, FALSE).evaluation()
And(TRUE, Or(TRUE, FALSE)).evaluation()
And(TRUE, Or(TRUE, FALSE), FALSE).evaluation()
And(TRUE, TRUE).prove()
Not(And(TRUE, FALSE)).prove()
Not(And(FALSE,TRUE)).prove()
Not(And(FALSE,FALSE)).prove()
And(A,B).prove(assumptions=[A,B])
Not(And(A,B)).prove(assumptions=[in_bool(A), in_bool(B), Not(B)])
Not(And(A,B)).prove(assumptions=[in_bool(A), in_bool(B), Not(A)])
Not(And(A,B,C)).prove(assumptions=[Not(B)])
And(A,B).derive_any(0, assumptions=[And(A,B), *in_bool(A,B)])
And(A,B).derive_any(1, assumptions=[And(A,B), *in_bool(A,B)])
And(A,B).commutation(assumptions=in_bool(A, B))
And(A,B).commute(assumptions=[And(A, B)])
in_bool(D).prove(assumptions=[in_bool(And(A,B,C,D))])
from proveit.logic.booleans.conjunction import each_is_bool
expr = each_is_bool.instance_expr.explicit_conditions()[0].element
from proveit.logic import InSet
from proveit.numbers import Natural
expr.derive_any(1, assumptions=[InSet(m, Natural), InSet(n, Natural), expr])
expr.derive_some(0, assumptions=[InSet(m, Natural), InSet(n, Natural), expr])
and_C_1_to_n = expr.derive_some(2, assumptions=[InSet(m, Natural), InSet(n, Natural), expr])
and_C_1_to_n.derive_quantification(j)
from proveit.logic.booleans.conjunction import any_from_and
any_from_and
And(A,B,C).prove(assumptions=[A,C,B])
And(A,B,C,D,E,F,G).associate(2,length=2,assumptions=[And(A,B,And(C,D),E,F,G),And(A,B,C,D,E,F,G),in_bool(A), in_bool(B),in_bool(C),in_bool(D),in_bool(E),in_bool(F),in_bool(G)])
And(A,B,C,D,E).commute(1, 3, assumptions=[And(A,B,C,D,E), *in_bool(A,B,C,D,E)])
And(A,B,C,D,E).group_commute(0,1,length=3, assumptions=[And(A,B,C,D,E), *in_bool(A,B,C,D,E)])
expr = Or(A, B, And(C, D, E))
expr.inner_expr().operands[-1].commutation(0, -1, assumptions=in_bool(C, D, E))
kt = expr.inner_expr().operands[-1].associate(0, length=2, assumptions=[expr])
expr = kt.expr
expr = expr.inner_expr().operands[-1].disassociate(0, assumptions=[expr])
in_bool(And(A,B)).prove(assumptions=[in_bool(A), in_bool(B)])
in_bool(And(A,B,C,D)).prove(assumptions=[in_bool(A), in_bool(B), in_bool(C), in_bool(D)])
And(A,B).prove(assumptions=[Not(Or(Not(A), Not(B)))])
And(A,B,C).prove(assumptions=[Not(Or(Not(A), Not(B), Not(C)))])
Equals(And(TRUE, TRUE), TRUE).prove()
Equals(And(TRUE, FALSE), FALSE).prove()
Equals(And(FALSE, TRUE), FALSE).prove()
Equals(And(FALSE, FALSE), FALSE).prove()
in_bool(A).prove(assumptions=[in_bool(And(A,B))])
in_bool(B).prove(assumptions=[in_bool(And(A,B))])
Equals(And(FALSE, TRUE), FALSE).prove()
Equals(And(FALSE, FALSE), FALSE).prove()
in_bool(A).prove(assumptions=[in_bool(And(A,B))])
in_bool(B).prove(assumptions=[in_bool(And(A,B))])
And.conclude_over_expr_range()
¶from proveit import i, j, k, x, P, Q, Pk, Qx, ExprRange, Function, Lambda
from proveit.logic import Forall, InSet
from proveit.numbers import one, two, three, four, five, Add, Integer, Interval, LessEq
test_conj_over_expr_range_01 = And(ExprRange(x, Qx, j, k))
our_assumptions_01 = [InSet(i, Integer), InSet(j, Integer),
InSet(k, Integer), LessEq(j, Add(k, one)),
Forall(x, Qx, domain=Interval(j, k))]
test_conj_over_expr_range_01.conclude_over_expr_range(assumptions=our_assumptions_01)
A more concrete case …
test_conj_over_expr_range_02 = And(ExprRange(x, Qx, two, four))
our_assumptions_02 = [Function(Q, two), Function(Q, three), Function(Q, four),
Forall(x, Qx, domain=Interval(two, four))]
LessEq(two, five).prove()
Equals(Add(four, one), five).prove()
test_conj_over_expr_range_02.conclude_over_expr_range(assumptions=our_assumptions_02)
Equals(And(A, B, C, D), And(D, B, A, C)).prove(assumptions=in_bool(A, B, C, D))
Equals(And(A, C, B, D), And(D, B, C, A)).prove(assumptions=in_bool(A, B, C, D))
Equals(And(D, C, B, A), And(B, D, C, A)).prove(assumptions=in_bool(A, B, C, D))
This even works in a nested manner
Equals(And(D, C, Or(A, B), A), And(Or(B, A), D, C, A)).prove(assumptions=in_bool(A, B, C, D))
%end demonstrations