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, b, 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, Natural, Real, RealNonNeg, greater_eq
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, c_1_to_j], instance_expr = Forall(instance_param_or_params = [b], instance_expr = greater_eq(Add(a_1_to_i, b, c_1_to_j), b), domain = Real), domain = RealNonNeg), And(InSet(i, Natural), InSet(j, Natural)))
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_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{R}^{\ge 0}}~\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)\right] \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}\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: 15
operand: 5
2Operationoperator: 17
operands: 4
3ExprTuple5
4ExprTuple6, 7
5Lambdaparameters: 8
body: 9
6Operationoperator: 34
operands: 10
7Operationoperator: 34
operands: 11
8ExprTuple41, 43
9Conditionalvalue: 12
condition: 13
10ExprTuple45, 14
11ExprTuple48, 14
12Operationoperator: 15
operand: 19
13Operationoperator: 17
operands: 18
14Literal
15Literal
16ExprTuple19
17Literal
18ExprTuple20, 21
19Lambdaparameter: 42
body: 23
20ExprRangelambda_map: 24
start_index: 47
end_index: 45
21ExprRangelambda_map: 25
start_index: 47
end_index: 48
22ExprTuple42
23Conditionalvalue: 26
condition: 27
24Lambdaparameter: 54
body: 28
25Lambdaparameter: 54
body: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 34
operands: 32
28Operationoperator: 34
operands: 33
29Operationoperator: 34
operands: 35
30Literal
31ExprTuple42, 36
32ExprTuple42, 37
33ExprTuple49, 38
34Literal
35ExprTuple50, 38
36Operationoperator: 39
operands: 40
37Literal
38Literal
39Literal
40ExprTuple41, 42, 43
41ExprRangelambda_map: 44
start_index: 47
end_index: 45
42Variable
43ExprRangelambda_map: 46
start_index: 47
end_index: 48
44Lambdaparameter: 54
body: 49
45Variable
46Lambdaparameter: 54
body: 50
47Literal
48Variable
49IndexedVarvariable: 51
index: 54
50IndexedVarvariable: 52
index: 54
51Variable
52Variable
53ExprTuple54
54Variable