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, x, y, z
from proveit.linear_algebra import InnerProd, InnerProdSpaces, VecAdd
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 = [x, y, z], instance_expr = Equals(InnerProd(x, VecAdd(y, z)), VecAdd(InnerProd(x, y), InnerProd(x, z))), domain = H), 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_{x, y, z \in H}~\left(\left \langle x, y + z\right \rangle = \left(\left \langle x, y\right \rangle + \left \langle x, z\right \rangle\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: 36
body: 2
1ExprTuple36
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple36, 10
9Lambdaparameters: 11
body: 12
10Operationoperator: 13
operand: 17
11ExprTuple43, 42, 44
12Conditionalvalue: 15
condition: 16
13Literal
14ExprTuple17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17Variable
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24, 25, 26
22Operationoperator: 40
operands: 27
23Operationoperator: 37
operands: 28
24Operationoperator: 31
operands: 29
25Operationoperator: 31
operands: 30
26Operationoperator: 31
operands: 32
27ExprTuple43, 33
28ExprTuple34, 35
29ExprTuple43, 36
30ExprTuple42, 36
31Literal
32ExprTuple44, 36
33Operationoperator: 37
operands: 38
34Operationoperator: 40
operands: 39
35Operationoperator: 40
operands: 41
36Variable
37Literal
38ExprTuple42, 44
39ExprTuple43, 42
40Literal
41ExprTuple43, 44
42Variable
43Variable
44Variable