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 Conditional, ExprTuple, Lambda, S, a, b, k, l
from proveit.logic import Card, Forall, Implies
from proveit.numbers import Less, Sum, greater, zero
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], Conditional(Implies(Forall(instance_param_or_params = [k], instance_expr = Less(ak, bk), domain = S), Less(Sum(index_or_indices = sub_expr1, summand = al, domain = S), Sum(index_or_indices = sub_expr1, summand = bl, domain = S))), greater(Card(S), 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, b, S\right) \mapsto \left\{\left[\forall_{k \in S}~\left(a\left(k\right) < b\left(k\right)\right)\right] \Rightarrow \left(\left[\sum_{l \in S}~a\left(l\right)\right] < \left[\sum_{l \in S}~b\left(l\right)\right]\right) \textrm{ if } |S| > 0\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, 41, 47
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 29
operands: 8
6Literal
7ExprTuple9, 10
8ExprTuple11, 12
9Operationoperator: 13
operand: 18
10Operationoperator: 29
operands: 15
11Literal
12Operationoperator: 16
operand: 47
13Literal
14ExprTuple18
15ExprTuple19, 20
16Literal
17ExprTuple47
18Lambdaparameter: 45
body: 21
19Operationoperator: 23
operand: 27
20Operationoperator: 23
operand: 28
21Conditionalvalue: 25
condition: 26
22ExprTuple27
23Literal
24ExprTuple28
25Operationoperator: 29
operands: 30
26Operationoperator: 43
operands: 31
27Lambdaparameter: 46
body: 32
28Lambdaparameter: 46
body: 33
29Literal
30ExprTuple34, 35
31ExprTuple45, 47
32Conditionalvalue: 36
condition: 38
33Conditionalvalue: 37
condition: 38
34Operationoperator: 40
operand: 45
35Operationoperator: 41
operand: 45
36Operationoperator: 40
operand: 46
37Operationoperator: 41
operand: 46
38Operationoperator: 43
operands: 44
39ExprTuple45
40Variable
41Variable
42ExprTuple46
43Literal
44ExprTuple46, 47
45Variable
46Variable
47Variable