logo

Expression of type Lambda

from the theory of proveit.linear_algebra.inner_products

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 H, K, Lambda, a, x, y
from proveit.linear_algebra import InnerProd, InnerProdSpaces, ScalarMult
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
expr = Lambda(K, Forall(instance_param_or_params = [H], instance_expr = Forall(instance_param_or_params = [a], instance_expr = Forall(instance_param_or_params = [x, y], instance_expr = Equals(InnerProd(ScalarMult(a, x), y), ScalarMult(a, InnerProd(x, y))), domain = H), domain = K), domain = InnerProdSpaces(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_{H \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)}~\left[\forall_{a \in K}~\left[\forall_{x, y \in H}~\left(\left \langle a \cdot x, y\right \rangle = \left(a \cdot \left \langle x, y\right \rangle\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: 23
body: 1
1Operationoperator: 19
operand: 3
2ExprTuple3
3Lambdaparameter: 42
body: 5
4ExprTuple42
5Conditionalvalue: 6
condition: 7
6Operationoperator: 19
operand: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple42, 12
11Lambdaparameter: 47
body: 14
12Operationoperator: 15
operand: 23
13ExprTuple47
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple23
17Operationoperator: 19
operand: 22
18Operationoperator: 38
operands: 21
19Literal
20ExprTuple22
21ExprTuple47, 23
22Lambdaparameters: 46
body: 24
23Variable
24Conditionalvalue: 25
condition: 26
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Operationoperator: 45
operands: 35
32Operationoperator: 43
operands: 36
33Operationoperator: 38
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple40, 49
36ExprTuple47, 41
37ExprTuple48, 42
38Literal
39ExprTuple49, 42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42Variable
43Literal
44ExprTuple47, 48
45Literal
46ExprTuple48, 49
47Variable
48Variable
49Variable