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
from proveit.logic import Equals, Forall, InSet
In [2]:
# build up the expression from sub-expressions
expr = Lambda(c, Conditional(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)), InSet(c, 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())
c \mapsto \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) \textrm{ if } c \in K\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 31
body: 2
1ExprTuple31
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 29
operands: 7
5Literal
6ExprTuple8
7ExprTuple31, 9
8Lambdaparameter: 34
body: 11
9Variable
10ExprTuple34
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 29
operands: 16
14Literal
15ExprTuple17, 18
16ExprTuple34, 19
17Operationoperator: 27
operands: 20
18Lambdaparameter: 36
body: 21
19Operationoperator: 22
operands: 23
20ExprTuple31, 34
21Conditionalvalue: 24
condition: 25
22Literal
23ExprTuple33, 26
24Operationoperator: 27
operands: 28
25Operationoperator: 29
operands: 30
26Variable
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple36, 33
31Variable
32Operationoperator: 34
operand: 36
33Variable
34Variable
35ExprTuple36
36Variable