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, K, Lambda, P, Px, Py, V, W, c, x, y
from proveit.linear_algebra import LinMap, ScalarMult, VecAdd, VecSpaces
from proveit.logic import And, Equals, Forall, Iff, InClass, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = VecSpaces(K)
expr = Lambda([V, W], Conditional(Forall(instance_param_or_params = [P], instance_expr = Iff(InSet(P, LinMap(V, W)), And(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(Px, W), domain = V), Forall(instance_param_or_params = [x, y], instance_expr = Equals(Function(P, [VecAdd(x, y)]), VecAdd(Px, Py)), domain = V), Forall(instance_param_or_params = [c], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(P, [ScalarMult(c, x)]), ScalarMult(c, Px)), domain = V), domain = K)).with_wrapping_at(2,4)).with_wrapping_at(2)), And(InClass(V, sub_expr2), InClass(W, 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(V, W\right) \mapsto \left\{\forall_{P}~\left(\begin{array}{c} \begin{array}{l} \left(P \in \mathcal{L}\left(V, W\right)\right) \Leftrightarrow  \\ \left(\begin{array}{c} \left[\forall_{x \in V}~\left(P\left(x\right) \in W\right)\right] \land  \\ \left[\forall_{x, y \in V}~\left(P\left(x + y\right) = \left(P\left(x\right) + P\left(y\right)\right)\right)\right] \land  \\ \left[\forall_{c \in K}~\left[\forall_{x \in V}~\left(P\left(c \cdot x\right) = \left(c \cdot P\left(x\right)\right)\right)\right]\right] \end{array}\right) \end{array} \end{array}\right) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right) ,  W \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\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: 28
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 48
operand: 6
3Operationoperator: 46
operands: 5
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 82
body: 10
7Operationoperator: 12
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple82
10Operationoperator: 14
operands: 15
11ExprTuple75, 16
12Literal
13ExprTuple51, 16
14Literal
15ExprTuple17, 18
16Operationoperator: 19
operand: 56
17Operationoperator: 70
operands: 21
18Operationoperator: 46
operands: 22
19Literal
20ExprTuple56
21ExprTuple82, 23
22ExprTuple24, 25, 26
23Operationoperator: 27
operands: 28
24Operationoperator: 48
operand: 32
25Operationoperator: 48
operand: 33
26Operationoperator: 48
operand: 34
27Literal
28ExprTuple75, 51
29ExprTuple32
30ExprTuple33
31ExprTuple34
32Lambdaparameter: 85
body: 35
33Lambdaparameters: 66
body: 36
34Lambdaparameter: 84
body: 38
35Conditionalvalue: 39
condition: 64
36Conditionalvalue: 40
condition: 41
37ExprTuple84
38Conditionalvalue: 42
condition: 43
39Operationoperator: 70
operands: 44
40Operationoperator: 68
operands: 45
41Operationoperator: 46
operands: 47
42Operationoperator: 48
operand: 55
43Operationoperator: 70
operands: 50
44ExprTuple79, 51
45ExprTuple52, 53
46Literal
47ExprTuple64, 54
48Literal
49ExprTuple55
50ExprTuple84, 56
51Variable
52Operationoperator: 82
operand: 61
53Operationoperator: 65
operands: 58
54Operationoperator: 70
operands: 59
55Lambdaparameter: 85
body: 60
56Variable
57ExprTuple61
58ExprTuple79, 62
59ExprTuple72, 75
60Conditionalvalue: 63
condition: 64
61Operationoperator: 65
operands: 66
62Operationoperator: 82
operand: 72
63Operationoperator: 68
operands: 69
64Operationoperator: 70
operands: 71
65Literal
66ExprTuple85, 72
67ExprTuple72
68Literal
69ExprTuple73, 74
70Literal
71ExprTuple85, 75
72Variable
73Operationoperator: 82
operand: 78
74Operationoperator: 80
operands: 77
75Variable
76ExprTuple78
77ExprTuple84, 79
78Operationoperator: 80
operands: 81
79Operationoperator: 82
operand: 85
80Literal
81ExprTuple84, 85
82Variable
83ExprTuple85
84Variable
85Variable