logo

Expression of type Lambda

from the theory of proveit.linear_algebra.addition

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, Lambda, V, a, b
from proveit.linear_algebra import InnerProd, Norm, VecAdd
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Exp, sqrt, two, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda([a, b], Conditional(Equals(Norm(VecAdd(a, b)), sqrt(Add(Exp(Norm(a), two), Exp(Norm(b), two)))), And(InSet(a, V), InSet(b, V), Equals(InnerProd(a, b), zero))))
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())
\left(a, b\right) \mapsto \left\{\left \|a + b\right \| = \sqrt{\left(\left \|a\right \|^{2} + \left \|b\right \|^{2}\right)} \textrm{ if } a \in V ,  b \in V ,  \left \langle a, b\right \rangle = 0\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameters: 31
body: 1
1Conditionalvalue: 2
condition: 3
2Operationoperator: 17
operands: 4
3Operationoperator: 5
operands: 6
4ExprTuple7, 8
5Literal
6ExprTuple9, 10, 11
7Operationoperator: 42
operand: 19
8Operationoperator: 36
operands: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11Operationoperator: 17
operands: 18
12ExprTuple19
13ExprTuple20, 21
14ExprTuple44, 22
15Literal
16ExprTuple45, 22
17Literal
18ExprTuple23, 24
19Operationoperator: 25
operands: 31
20Operationoperator: 26
operands: 27
21Operationoperator: 28
operands: 29
22Variable
23Operationoperator: 30
operands: 31
24Literal
25Literal
26Literal
27ExprTuple32, 33
28Literal
29ExprTuple34, 40
30Literal
31ExprTuple44, 45
32Operationoperator: 36
operands: 35
33Operationoperator: 36
operands: 37
34Literal
35ExprTuple38, 40
36Literal
37ExprTuple39, 40
38Operationoperator: 42
operand: 44
39Operationoperator: 42
operand: 45
40Literal
41ExprTuple44
42Literal
43ExprTuple45
44Variable
45Variable