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 K, Lambda, V, a, b
from proveit.linear_algebra import InnerProd, Norm, VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Exp, sqrt, two, zero
In [2]:
# build up the expression from sub-expressions
expr = Lambda(K, Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [a, b], instance_expr = Equals(Norm(VecAdd(a, b)), sqrt(Add(Exp(Norm(a), two), Exp(Norm(b), two)))), domain = V, condition = Equals(InnerProd(a, b), zero)), domain = VecSpaces(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_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{a, b \in V~|~\left \langle a, b\right \rangle = 0}~\left(\left \|a + b\right \| = \sqrt{\left(\left \|a\right \|^{2} + \left \|b\right \|^{2}\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: 19
body: 1
1Operationoperator: 8
operand: 3
2ExprTuple3
3Lambdaparameter: 38
body: 5
4ExprTuple38
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operand: 12
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12
10Literal
11ExprTuple38, 13
12Lambdaparameters: 47
body: 14
13Operationoperator: 15
operand: 19
14Conditionalvalue: 17
condition: 18
15Literal
16ExprTuple19
17Operationoperator: 33
operands: 20
18Operationoperator: 21
operands: 22
19Variable
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27
23Operationoperator: 58
operand: 35
24Operationoperator: 52
operands: 29
25Operationoperator: 31
operands: 30
26Operationoperator: 31
operands: 32
27Operationoperator: 33
operands: 34
28ExprTuple35
29ExprTuple36, 37
30ExprTuple60, 38
31Literal
32ExprTuple61, 38
33Literal
34ExprTuple39, 40
35Operationoperator: 41
operands: 47
36Operationoperator: 42
operands: 43
37Operationoperator: 44
operands: 45
38Variable
39Operationoperator: 46
operands: 47
40Literal
41Literal
42Literal
43ExprTuple48, 49
44Literal
45ExprTuple50, 56
46Literal
47ExprTuple60, 61
48Operationoperator: 52
operands: 51
49Operationoperator: 52
operands: 53
50Literal
51ExprTuple54, 56
52Literal
53ExprTuple55, 56
54Operationoperator: 58
operand: 60
55Operationoperator: 58
operand: 61
56Literal
57ExprTuple60
58Literal
59ExprTuple61
60Variable
61Variable