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
from proveit.linear_algebra import InnerProd, InnerProdSpaces, Norm
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import sqrt
In [2]:
# build up the expression from sub-expressions
expr = Lambda(H, Conditional(Forall(instance_param_or_params = [x], instance_expr = Equals(Norm(x), sqrt(InnerProd(x, x))), 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 \in H}~\left(\left \|x\right \| = \sqrt{\left \langle x, x\right \rangle}\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: 23
body: 2
1ExprTuple23
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple23, 10
9Lambdaparameter: 34
body: 11
10Operationoperator: 12
operand: 16
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple16
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operands: 20
16Variable
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple34, 23
21Operationoperator: 24
operand: 34
22Operationoperator: 26
operands: 27
23Variable
24Literal
25ExprTuple34
26Literal
27ExprTuple28, 29
28Operationoperator: 30
operands: 31
29Operationoperator: 32
operands: 33
30Literal
31ExprTuple34, 34
32Literal
33ExprTuple35, 36
34Variable
35Literal
36Literal