logo

Expression of type Lambda

from the theory of proveit.linear_algebra.linear_maps

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, Function, Lambda, P, Px, V, W, x, y
from proveit.linear_algebra import LinMap, VecAdd
from proveit.logic import Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
expr = Lambda(P, Conditional(Forall(instance_param_or_params = [x, y], instance_expr = Equals(Function(P, [VecAdd(x, y)]), VecAdd(Px, Function(P, [y]))), domain = V), InSet(P, LinMap(V, W))))
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())
P \mapsto \left\{\forall_{x, y \in V}~\left(P\left(x + y\right) = \left(P\left(x\right) + P\left(y\right)\right)\right) \textrm{ if } P \in \mathcal{L}\left(V, W\right)\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 36
body: 2
1ExprTuple36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 27
operands: 7
5Literal
6ExprTuple8
7ExprTuple36, 9
8Lambdaparameters: 34
body: 10
9Operationoperator: 11
operands: 12
10Conditionalvalue: 13
condition: 14
11Literal
12ExprTuple32, 15
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Variable
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23
20Operationoperator: 36
operand: 29
21Operationoperator: 33
operands: 25
22Operationoperator: 27
operands: 26
23Operationoperator: 27
operands: 28
24ExprTuple29
25ExprTuple30, 31
26ExprTuple38, 32
27Literal
28ExprTuple39, 32
29Operationoperator: 33
operands: 34
30Operationoperator: 36
operand: 38
31Operationoperator: 36
operand: 39
32Variable
33Literal
34ExprTuple38, 39
35ExprTuple38
36Variable
37ExprTuple39
38Variable
39Variable