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, InSet
from proveit.numbers import Add, RealNonNeg, RealPos, greater, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(InSet(Add(a_1_to_i, b, c_1_to_j), RealPos), And(ExprRange(sub_expr1, InSet(IndexedVar(a, sub_expr1), RealNonNeg), one, i), InSet(b, RealNonNeg), ExprRange(sub_expr1, InSet(IndexedVar(c, sub_expr1), RealNonNeg), one, j), greater(b, zero)))
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} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{R}^+ \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) ,  b \in \mathbb{R}^{\ge 0}, \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) ,  b > 0\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: 31
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9, 10, 11
6Operationoperator: 12
operands: 13
7Literal
8ExprRangelambda_map: 14
start_index: 28
end_index: 26
9Operationoperator: 31
operands: 15
10ExprRangelambda_map: 16
start_index: 28
end_index: 29
11Operationoperator: 17
operands: 18
12Literal
13ExprTuple19, 24, 20
14Lambdaparameter: 39
body: 21
15ExprTuple24, 35
16Lambdaparameter: 39
body: 22
17Literal
18ExprTuple23, 24
19ExprRangelambda_map: 25
start_index: 28
end_index: 26
20ExprRangelambda_map: 27
start_index: 28
end_index: 29
21Operationoperator: 31
operands: 30
22Operationoperator: 31
operands: 32
23Literal
24Variable
25Lambdaparameter: 39
body: 33
26Variable
27Lambdaparameter: 39
body: 34
28Literal
29Variable
30ExprTuple33, 35
31Literal
32ExprTuple34, 35
33IndexedVarvariable: 36
index: 39
34IndexedVarvariable: 37
index: 39
35Literal
36Variable
37Variable
38ExprTuple39
39Variable