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, f, fx, g, gx, x
from proveit.logic import Forall, Implies
from proveit.numbers import LessEq, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda([S, f, g], Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = LessEq(fx, gx), domain = S), LessEq(Sum(index_or_indices = sub_expr1, summand = fx, domain = S), Sum(index_or_indices = sub_expr1, summand = gx, 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(S, f, g\right) \mapsto \left(\left[\forall_{x \in S}~\left(f\left(x\right) \leq g\left(x\right)\right)\right] \Rightarrow \left(\left[\sum_{x \in S}~f\left(x\right)\right] \leq \left[\sum_{x \in S}~g\left(x\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
1ExprTuple33, 27, 28
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 7
operand: 10
6Operationoperator: 20
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameter: 32
body: 13
11Operationoperator: 15
operand: 18
12Operationoperator: 15
operand: 19
13Conditionalvalue: 17
condition: 26
14ExprTuple18
15Literal
16ExprTuple19
17Operationoperator: 20
operands: 21
18Lambdaparameter: 32
body: 22
19Lambdaparameter: 32
body: 23
20Literal
21ExprTuple24, 25
22Conditionalvalue: 24
condition: 26
23Conditionalvalue: 25
condition: 26
24Operationoperator: 27
operand: 32
25Operationoperator: 28
operand: 32
26Operationoperator: 30
operands: 31
27Variable
28Variable
29ExprTuple32
30Literal
31ExprTuple32, 33
32Variable
33Variable