logo

Expression of type Conditional

from the theory of proveit.numbers.multiplication

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import Conditional, ExprRange, IndexedVar, Variable, a, b, i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, InSet
from proveit.numbers import LessEq, Mult, RealNonNeg, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(LessEq(Mult(a_1_to_i, x, b_1_to_j), Mult(a_1_to_i, y, b_1_to_j)), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RealNonNeg), one, i), ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), RealNonNeg), one, j), LessEq(x, y)))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left\{\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot x\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) \leq \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot y\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) \textrm{ if } \left(a_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(a_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(a_{i} \in \mathbb{R}^{\ge 0}\right), \left(b_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(b_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(b_{j} \in \mathbb{R}^{\ge 0}\right) ,  x \leq y\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 16
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9, 10
6Operationoperator: 12
operands: 11
7Operationoperator: 12
operands: 13
8ExprRangelambda_map: 14
start_index: 27
end_index: 25
9ExprRangelambda_map: 15
start_index: 27
end_index: 28
10Operationoperator: 16
operands: 17
11ExprTuple18, 22, 19
12Literal
13ExprTuple18, 23, 19
14Lambdaparameter: 38
body: 20
15Lambdaparameter: 38
body: 21
16Literal
17ExprTuple22, 23
18ExprRangelambda_map: 24
start_index: 27
end_index: 25
19ExprRangelambda_map: 26
start_index: 27
end_index: 28
20Operationoperator: 30
operands: 29
21Operationoperator: 30
operands: 31
22Variable
23Variable
24Lambdaparameter: 38
body: 32
25Variable
26Lambdaparameter: 38
body: 33
27Literal
28Variable
29ExprTuple32, 34
30Literal
31ExprTuple33, 34
32IndexedVarvariable: 35
index: 38
33IndexedVarvariable: 36
index: 38
34Literal
35Variable
36Variable
37ExprTuple38
38Variable