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 Conditional, H, K, Lambda, a, x, y
from proveit.linear_algebra import InnerProd, InnerProdSpaces, ScalarMult
from proveit.logic import Equals, Forall, InClass
In [2]:
# build up the expression from sub-expressions
expr = Lambda(H, Conditional(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), InClass(H, 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())
H \mapsto \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] \textrm{ if } H \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\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: 39
body: 2
1ExprTuple39
2Conditionalvalue: 3
condition: 4
3Operationoperator: 16
operand: 8
4Operationoperator: 6
operands: 7
5ExprTuple8
6Literal
7ExprTuple39, 9
8Lambdaparameter: 44
body: 11
9Operationoperator: 12
operand: 20
10ExprTuple44
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple20
14Operationoperator: 16
operand: 19
15Operationoperator: 35
operands: 18
16Literal
17ExprTuple19
18ExprTuple44, 20
19Lambdaparameters: 43
body: 21
20Variable
21Conditionalvalue: 22
condition: 23
22Operationoperator: 24
operands: 25
23Operationoperator: 26
operands: 27
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30, 31
28Operationoperator: 42
operands: 32
29Operationoperator: 40
operands: 33
30Operationoperator: 35
operands: 34
31Operationoperator: 35
operands: 36
32ExprTuple37, 46
33ExprTuple44, 38
34ExprTuple45, 39
35Literal
36ExprTuple46, 39
37Operationoperator: 40
operands: 41
38Operationoperator: 42
operands: 43
39Variable
40Literal
41ExprTuple44, 45
42Literal
43ExprTuple45, 46
44Variable
45Variable
46Variable