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
from proveit.logic import And, Equals, Forall, Iff, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Lambda(P, 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))
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())
P \mapsto \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)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 68
body: 2
1ExprTuple68
2Operationoperator: 3
operands: 4
3Literal
4ExprTuple5, 6
5Operationoperator: 56
operands: 7
6Operationoperator: 32
operands: 8
7ExprTuple68, 9
8ExprTuple10, 11, 12
9Operationoperator: 13
operands: 14
10Operationoperator: 34
operand: 18
11Operationoperator: 34
operand: 19
12Operationoperator: 34
operand: 20
13Literal
14ExprTuple61, 37
15ExprTuple18
16ExprTuple19
17ExprTuple20
18Lambdaparameter: 71
body: 21
19Lambdaparameters: 52
body: 22
20Lambdaparameter: 70
body: 24
21Conditionalvalue: 25
condition: 50
22Conditionalvalue: 26
condition: 27
23ExprTuple70
24Conditionalvalue: 28
condition: 29
25Operationoperator: 56
operands: 30
26Operationoperator: 54
operands: 31
27Operationoperator: 32
operands: 33
28Operationoperator: 34
operand: 41
29Operationoperator: 56
operands: 36
30ExprTuple65, 37
31ExprTuple38, 39
32Literal
33ExprTuple50, 40
34Literal
35ExprTuple41
36ExprTuple70, 42
37Variable
38Operationoperator: 68
operand: 47
39Operationoperator: 51
operands: 44
40Operationoperator: 56
operands: 45
41Lambdaparameter: 71
body: 46
42Variable
43ExprTuple47
44ExprTuple65, 48
45ExprTuple58, 61
46Conditionalvalue: 49
condition: 50
47Operationoperator: 51
operands: 52
48Operationoperator: 68
operand: 58
49Operationoperator: 54
operands: 55
50Operationoperator: 56
operands: 57
51Literal
52ExprTuple71, 58
53ExprTuple58
54Literal
55ExprTuple59, 60
56Literal
57ExprTuple71, 61
58Variable
59Operationoperator: 68
operand: 64
60Operationoperator: 66
operands: 63
61Variable
62ExprTuple64
63ExprTuple70, 65
64Operationoperator: 66
operands: 67
65Operationoperator: 68
operand: 71
66Literal
67ExprTuple70, 71
68Variable
69ExprTuple71
70Variable
71Variable