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