logo

Expression of type Lambda

from the theory of proveit.linear_algebra

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 Function, Lambda, S, T, V, W, v
from proveit.linear_algebra import LinMap, LinMapAdd
from proveit.logic import Equals, Forall
from proveit.numbers import Add
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [v]
expr = Lambda([V, W], Forall(instance_param_or_params = [S, T], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(LinMapAdd(S, T), sub_expr1), Add(Function(S, sub_expr1), Function(T, sub_expr1))), domain = V), domain = 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())
\left(V, W\right) \mapsto \left[\forall_{S, T \in \mathcal{L}\left(V, W\right)}~\left[\forall_{v \in V}~\left(\left(S + T\right)\left(v\right) = \left(S\left(v\right) + T\left(v\right)\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: 25
body: 1
1Operationoperator: 7
operand: 3
2ExprTuple3
3Lambdaparameters: 34
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple12, 13
11Lambdaparameter: 40
body: 14
12Operationoperator: 22
operands: 15
13Operationoperator: 22
operands: 16
14Conditionalvalue: 17
condition: 18
15ExprTuple37, 19
16ExprTuple38, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operands: 25
20Literal
21ExprTuple26, 27
22Literal
23ExprTuple40, 28
24Literal
25ExprTuple28, 29
26Operationoperator: 30
operand: 40
27Operationoperator: 31
operands: 32
28Variable
29Variable
30Operationoperator: 33
operands: 34
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple37, 38
35Operationoperator: 37
operand: 40
36Operationoperator: 38
operand: 40
37Variable
38Variable
39ExprTuple40
40Variable