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 A, B, Conditional, Function, K, Lambda, V, W, x
from proveit.linear_algebra import LinMap, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(K, Forall(instance_param_or_params = [V, W], instance_expr = Forall(instance_param_or_params = [A, B], instance_expr = Equals(VecAdd(A, B), Lambda(x, Conditional(VecAdd(Function(A, sub_expr1), Function(B, sub_expr1)), InSet(x, V)))), domain = LinMap(V, W)), domain = VecSpaces(K)))
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())
K \mapsto \left[\forall_{V, W \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{A, B \in \mathcal{L}\left(V, W\right)}~\left(\left(A + B\right) = \left[x \mapsto \left\{A\left(x\right) + B\left(x\right) \textrm{ if } x \in 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
0Lambdaparameter: 30
body: 1
1Operationoperator: 7
operand: 3
2ExprTuple3
3Lambdaparameters: 43
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 22
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 31
body: 13
11Operationoperator: 15
operands: 14
12Operationoperator: 15
operands: 16
13Conditionalvalue: 17
condition: 18
14ExprTuple46, 19
15Literal
16ExprTuple47, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operand: 30
20Literal
21ExprTuple26, 27
22Literal
23ExprTuple28, 29
24Literal
25ExprTuple30
26Operationoperator: 38
operands: 31
27Lambdaparameter: 51
body: 32
28Operationoperator: 40
operands: 33
29Operationoperator: 40
operands: 34
30Variable
31ExprTuple48, 49
32Conditionalvalue: 35
condition: 36
33ExprTuple48, 37
34ExprTuple49, 37
35Operationoperator: 38
operands: 39
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38Literal
39ExprTuple44, 45
40Literal
41ExprTuple51, 46
42Literal
43ExprTuple46, 47
44Operationoperator: 48
operand: 51
45Operationoperator: 49
operand: 51
46Variable
47Variable
48Variable
49Variable
50ExprTuple51
51Variable