logo

Expression of type Conditional

from the theory of proveit.numbers.addition

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, c, i, j
from proveit.core_expr_types import a_1_to_i, c_1_to_j
from proveit.logic import And, Forall, InSet
from proveit.numbers import Add, Real, RealNonNeg, greater_eq, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [b], instance_expr = greater_eq(Add(a_1_to_i, b, c_1_to_j), b), domain = Real), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RealNonNeg), one, i), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), RealNonNeg), one, j)))
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\{\forall_{b \in \mathbb{R}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \geq b\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(c_{1} \in \mathbb{R}^{\ge 0}\right) ,  \left(c_{2} \in \mathbb{R}^{\ge 0}\right) ,  \ldots ,  \left(c_{j} \in \mathbb{R}^{\ge 0}\right)\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: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9
7Lambdaparameter: 30
body: 11
8ExprRangelambda_map: 12
start_index: 35
end_index: 33
9ExprRangelambda_map: 13
start_index: 35
end_index: 36
10ExprTuple30
11Conditionalvalue: 14
condition: 15
12Lambdaparameter: 42
body: 16
13Lambdaparameter: 42
body: 17
14Operationoperator: 18
operands: 19
15Operationoperator: 22
operands: 20
16Operationoperator: 22
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19ExprTuple30, 24
20ExprTuple30, 25
21ExprTuple37, 26
22Literal
23ExprTuple38, 26
24Operationoperator: 27
operands: 28
25Literal
26Literal
27Literal
28ExprTuple29, 30, 31
29ExprRangelambda_map: 32
start_index: 35
end_index: 33
30Variable
31ExprRangelambda_map: 34
start_index: 35
end_index: 36
32Lambdaparameter: 42
body: 37
33Variable
34Lambdaparameter: 42
body: 38
35Literal
36Variable
37IndexedVarvariable: 39
index: 42
38IndexedVarvariable: 40
index: 42
39Variable
40Variable
41ExprTuple42
42Variable