logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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, Less, Natural, RationalNeg, RationalNonPos, zero
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([i, j], Conditional(Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_j], instance_expr = InSet(Add(a_1_to_i, b, c_1_to_j), RationalNeg), domain = RationalNonPos, condition = Less(b, zero)), 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(\left(i, j\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{i}, b, c_{1}, c_{2}, \ldots, c_{j} \in \mathbb{Q}^{\leq 0}~|~b < 0}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{Q}^-\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N}\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple41, 44
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 19
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 28
body: 12
10Operationoperator: 46
operands: 13
11Operationoperator: 46
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple41, 17
14ExprTuple44, 17
15Operationoperator: 46
operands: 18
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23, 24, 25, 26
21Operationoperator: 27
operands: 28
22Literal
23ExprRangelambda_map: 29
start_index: 43
end_index: 41
24Operationoperator: 46
operands: 30
25ExprRangelambda_map: 31
start_index: 43
end_index: 44
26Operationoperator: 32
operands: 33
27Literal
28ExprTuple34, 38, 35
29Lambdaparameter: 54
body: 36
30ExprTuple38, 50
31Lambdaparameter: 54
body: 37
32Literal
33ExprTuple38, 39
34ExprRangelambda_map: 40
start_index: 43
end_index: 41
35ExprRangelambda_map: 42
start_index: 43
end_index: 44
36Operationoperator: 46
operands: 45
37Operationoperator: 46
operands: 47
38Variable
39Literal
40Lambdaparameter: 54
body: 48
41Variable
42Lambdaparameter: 54
body: 49
43Literal
44Variable
45ExprTuple48, 50
46Literal
47ExprTuple49, 50
48IndexedVarvariable: 51
index: 54
49IndexedVarvariable: 52
index: 54
50Literal
51Variable
52Variable
53ExprTuple54
54Variable