logo

Expression of type Lambda

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 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 = 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(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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 1
body: 2
1ExprTuple32, 33, 39
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 10
6Operationoperator: 21
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameter: 37
body: 13
11Operationoperator: 15
operand: 19
12Operationoperator: 15
operand: 20
13Conditionalvalue: 17
condition: 18
14ExprTuple19
15Literal
16ExprTuple20
17Operationoperator: 21
operands: 22
18Operationoperator: 35
operands: 23
19Lambdaparameter: 38
body: 24
20Lambdaparameter: 38
body: 25
21Literal
22ExprTuple26, 27
23ExprTuple37, 39
24Conditionalvalue: 28
condition: 30
25Conditionalvalue: 29
condition: 30
26Operationoperator: 32
operand: 37
27Operationoperator: 33
operand: 37
28Operationoperator: 32
operand: 38
29Operationoperator: 33
operand: 38
30Operationoperator: 35
operands: 36
31ExprTuple37
32Variable
33Variable
34ExprTuple38
35Literal
36ExprTuple38, 39
37Variable
38Variable
39Variable