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, Natural, NaturalPos, greater, 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), NaturalPos), domain = Natural, condition = greater(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{N}~|~b > 0}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{i} + b+ c_{1} +  c_{2} +  \ldots +  c_{j}\right) \in \mathbb{N}^+\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
2ExprTuple40, 43
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 18
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 27
body: 12
10Operationoperator: 45
operands: 13
11Operationoperator: 45
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple40, 49
14ExprTuple43, 49
15Operationoperator: 45
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20, 21
18Literal
19ExprTuple22, 23, 24, 25
20Operationoperator: 26
operands: 27
21Literal
22ExprRangelambda_map: 28
start_index: 42
end_index: 40
23Operationoperator: 45
operands: 29
24ExprRangelambda_map: 30
start_index: 42
end_index: 43
25Operationoperator: 31
operands: 32
26Literal
27ExprTuple33, 38, 34
28Lambdaparameter: 53
body: 35
29ExprTuple38, 49
30Lambdaparameter: 53
body: 36
31Literal
32ExprTuple37, 38
33ExprRangelambda_map: 39
start_index: 42
end_index: 40
34ExprRangelambda_map: 41
start_index: 42
end_index: 43
35Operationoperator: 45
operands: 44
36Operationoperator: 45
operands: 46
37Literal
38Variable
39Lambdaparameter: 53
body: 47
40Variable
41Lambdaparameter: 53
body: 48
42Literal
43Variable
44ExprTuple47, 49
45Literal
46ExprTuple48, 49
47IndexedVarvariable: 50
index: 53
48IndexedVarvariable: 51
index: 53
49Literal
50Variable
51Variable
52ExprTuple53
53Variable