import proveit
theory = proveit.Theory() # the theorem's theory
from proveit import x, y, defaults
from proveit.logic import Not
from proveit.numbers import greater_eq
from proveit.numbers.ordering import (
less_eq_def, less_or_greater_eq, max_def_bin)
%proving max_bin_args_commute
defaults.assumptions = max_bin_args_commute.conditions
max_def_bin
max_x_y_def = max_def_bin.instantiate({x: x, y: y})
max_y_x_def = max_def_bin.instantiate({x: y, y: x})
less_or_greater_eq
relation_choices = less_or_greater_eq.instantiate({x: x, y: y})
case_1_assumptions = defaults.assumptions+(relation_choices.operands[0],)
max_x_y_def.inner_expr().rhs.simplify(assumptions=case_1_assumptions)
max_y_x_def.inner_expr().rhs.simplify(assumptions=case_1_assumptions)
case_2_assumptions = defaults.assumptions+(relation_choices.operands[1],)
case_2_non_implication = max_x_y_def.inner_expr().rhs.simplify(assumptions=case_2_assumptions)
Then for later we seem to need this in implication form:
from proveit.logic import Implies
Implies(greater_eq(x, y), case_2_non_implication).prove()
The second part of Case 2 needs to be broken up into two pieces.
less_eq_def
x_ge_y_as_disjunction = less_eq_def.instantiate({x: y, y: x})
x_ge_y_as_disjunction.derive_right_via_equality(assumptions=case_2_assumptions)
case_2_a_assumptions = defaults.assumptions + (x_ge_y_as_disjunction.rhs.operands[0],)
max_y_x_def.inner_expr().rhs.simplify(assumptions=case_2_a_assumptions)
case_2_b_assumptions = defaults.assumptions + (x_ge_y_as_disjunction.rhs.operands[1],)
# Need this piece explicitly ---
# y >= x is not derived as an automatic side-effect from y = x
greater_eq(y, x).prove(assumptions=case_2_b_assumptions)
max_y_x_when_y_eq_x = max_y_x_def.inner_expr().rhs.simplify(assumptions=case_2_b_assumptions)
case_2_b_non_implication = max_y_x_when_y_eq_x.inner_expr().rhs.substitute(x,
assumptions=case_2_b_assumptions, auto_simplify=False)
Recall the full Case (2) conditions, and combine the two sub-cases of Case (2) into a single conclusion:
x_ge_y_as_disjunction
x_ge_y_as_disjunction.rhs.derive_via_singular_dilemma(
max_bin_args_commute.instance_expr,
assumptions=defaults.assumptions+(x_ge_y_as_disjunction.lhs,))
Now we're ready for combining Cases (1) and (2) using derive_via_singular_dilemma() and the default assumptions:
relation_choices.expr.derive_via_singular_dilemma(
max_bin_args_commute.instance_expr)
%qed