logo

Expression of type ExprTuple

from the theory of proveit.numbers.summation

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 ExprTuple, Lambda, S, a, b, k, l
from proveit.logic import Forall, Implies
from proveit.numbers import LessEq, Sum
from proveit.numbers.summation import ak, al, bk, bl
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [l]
expr = ExprTuple(Lambda([a, b, S], Implies(Forall(instance_param_or_params = [k], instance_expr = LessEq(ak, bk), domain = S), LessEq(Sum(index_or_indices = sub_expr1, summand = al, domain = S), Sum(index_or_indices = sub_expr1, summand = bl, domain = S)))))
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, b, S\right) \mapsto \left(\left[\forall_{k \in S}~\left(a\left(k\right) \leq b\left(k\right)\right)\right] \Rightarrow \left(\left[\sum_{l \in S}~a\left(l\right)\right] \leq \left[\sum_{l \in S}~b\left(l\right)\right]\right)\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
2ExprTuple33, 34, 40
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 8
operand: 11
7Operationoperator: 22
operands: 10
8Literal
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameter: 38
body: 14
12Operationoperator: 16
operand: 20
13Operationoperator: 16
operand: 21
14Conditionalvalue: 18
condition: 19
15ExprTuple20
16Literal
17ExprTuple21
18Operationoperator: 22
operands: 23
19Operationoperator: 36
operands: 24
20Lambdaparameter: 39
body: 25
21Lambdaparameter: 39
body: 26
22Literal
23ExprTuple27, 28
24ExprTuple38, 40
25Conditionalvalue: 29
condition: 31
26Conditionalvalue: 30
condition: 31
27Operationoperator: 33
operand: 38
28Operationoperator: 34
operand: 38
29Operationoperator: 33
operand: 39
30Operationoperator: 34
operand: 39
31Operationoperator: 36
operands: 37
32ExprTuple38
33Variable
34Variable
35ExprTuple39
36Literal
37ExprTuple39, 40
38Variable
39Variable
40Variable