import proveit
theory = proveit.Theory() # the theorem's theory
from proveit import x, y, defaults
from proveit.logic import Equals, InSet
from proveit.numbers import greater_eq, Less, Real
from proveit.numbers.ordering import less_eq_def, max_def_bin
%proving max_y_ge_x
defaults.assumptions = max_y_ge_x.conditions
max_def_bin
max_x_y = max_def_bin.instantiate({x: x, y: y}, auto_simplify=False)
less_eq_def
y_ge_x_def = less_eq_def.instantiate({x: x, y: y})
y_ge_x_def.derive_right_via_equality()
max_x_y_is_y_if_x_less_y = max_x_y.inner_expr().rhs.simplify(assumptions=[InSet(x, Real), InSet(y, Real), Less(x, y)])
greater_eq(x, y).prove(assumptions=[InSet(x, Real), InSet(y, Real), Equals(x, y)])
max_x_y_when_x_eq_y = max_x_y.inner_expr().rhs.simplify(assumptions=[InSet(x, Real), InSet(y, Real), Equals(x, y)])
# Use the fact that x = y to substitute
max_x_y_when_x_eq_y.inner_expr().rhs.substitute(y, assumptions=[Equals(x, y)], auto_simplify=False)
or_version_of_thm = y_ge_x_def.rhs.derive_via_singular_dilemma(
max_x_y_is_y_if_x_less_y.expr)
%qed