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