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 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, 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 = [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)), 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_{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)\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: 59
body: 1
1Operationoperator: 51
operand: 3
2ExprTuple3
3Lambdaparameters: 31
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 51
operand: 9
6Operationoperator: 49
operands: 8
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameter: 85
body: 13
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12ExprTuple85
13Operationoperator: 17
operands: 18
14ExprTuple78, 19
15Literal
16ExprTuple54, 19
17Literal
18ExprTuple20, 21
19Operationoperator: 22
operand: 59
20Operationoperator: 73
operands: 24
21Operationoperator: 49
operands: 25
22Literal
23ExprTuple59
24ExprTuple85, 26
25ExprTuple27, 28, 29
26Operationoperator: 30
operands: 31
27Operationoperator: 51
operand: 35
28Operationoperator: 51
operand: 36
29Operationoperator: 51
operand: 37
30Literal
31ExprTuple78, 54
32ExprTuple35
33ExprTuple36
34ExprTuple37
35Lambdaparameter: 88
body: 38
36Lambdaparameters: 69
body: 39
37Lambdaparameter: 87
body: 41
38Conditionalvalue: 42
condition: 67
39Conditionalvalue: 43
condition: 44
40ExprTuple87
41Conditionalvalue: 45
condition: 46
42Operationoperator: 73
operands: 47
43Operationoperator: 71
operands: 48
44Operationoperator: 49
operands: 50
45Operationoperator: 51
operand: 58
46Operationoperator: 73
operands: 53
47ExprTuple82, 54
48ExprTuple55, 56
49Literal
50ExprTuple67, 57
51Literal
52ExprTuple58
53ExprTuple87, 59
54Variable
55Operationoperator: 85
operand: 64
56Operationoperator: 68
operands: 61
57Operationoperator: 73
operands: 62
58Lambdaparameter: 88
body: 63
59Variable
60ExprTuple64
61ExprTuple82, 65
62ExprTuple75, 78
63Conditionalvalue: 66
condition: 67
64Operationoperator: 68
operands: 69
65Operationoperator: 85
operand: 75
66Operationoperator: 71
operands: 72
67Operationoperator: 73
operands: 74
68Literal
69ExprTuple88, 75
70ExprTuple75
71Literal
72ExprTuple76, 77
73Literal
74ExprTuple88, 78
75Variable
76Operationoperator: 85
operand: 81
77Operationoperator: 83
operands: 80
78Variable
79ExprTuple81
80ExprTuple87, 82
81Operationoperator: 83
operands: 84
82Operationoperator: 85
operand: 88
83Literal
84ExprTuple87, 88
85Variable
86ExprTuple88
87Variable
88Variable