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 Conditional, 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 = 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(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..
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
1ExprTuple39, 40, 46
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 28
operands: 7
5Literal
6ExprTuple8, 9
7ExprTuple10, 11
8Operationoperator: 12
operand: 17
9Operationoperator: 28
operands: 14
10Literal
11Operationoperator: 15
operand: 46
12Literal
13ExprTuple17
14ExprTuple18, 19
15Literal
16ExprTuple46
17Lambdaparameter: 44
body: 20
18Operationoperator: 22
operand: 26
19Operationoperator: 22
operand: 27
20Conditionalvalue: 24
condition: 25
21ExprTuple26
22Literal
23ExprTuple27
24Operationoperator: 28
operands: 29
25Operationoperator: 42
operands: 30
26Lambdaparameter: 45
body: 31
27Lambdaparameter: 45
body: 32
28Literal
29ExprTuple33, 34
30ExprTuple44, 46
31Conditionalvalue: 35
condition: 37
32Conditionalvalue: 36
condition: 37
33Operationoperator: 39
operand: 44
34Operationoperator: 40
operand: 44
35Operationoperator: 39
operand: 45
36Operationoperator: 40
operand: 45
37Operationoperator: 42
operands: 43
38ExprTuple44
39Variable
40Variable
41ExprTuple45
42Literal
43ExprTuple45, 46
44Variable
45Variable
46Variable