# 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, K, Lambda, V, a, b
from proveit.linear_algebra import InnerProd, Norm, VecAdd, VecSpaces
from proveit.logic import Equals, Forall, InClass
from proveit.numbers import Add, Exp, sqrt, two, zero

In [2]:
# build up the expression from sub-expressions
expr = Lambda(V, Conditional(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)), InClass(V, 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())

V \mapsto \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) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\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: 35
body: 2
1ExprTuple35
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple35, 10
9Lambdaparameters: 44
body: 11
10Operationoperator: 12
operand: 16
11Conditionalvalue: 14
condition: 15
12Literal
13ExprTuple16
14Operationoperator: 30
operands: 17
15Operationoperator: 18
operands: 19
16Variable
17ExprTuple20, 21
18Literal
19ExprTuple22, 23, 24
20Operationoperator: 55
operand: 32
21Operationoperator: 49
operands: 26
22Operationoperator: 28
operands: 27
23Operationoperator: 28
operands: 29
24Operationoperator: 30
operands: 31
25ExprTuple32
26ExprTuple33, 34
27ExprTuple57, 35
28Literal
29ExprTuple58, 35
30Literal
31ExprTuple36, 37
32Operationoperator: 38
operands: 44
33Operationoperator: 39
operands: 40
34Operationoperator: 41
operands: 42
35Variable
36Operationoperator: 43
operands: 44
37Literal
38Literal
39Literal
40ExprTuple45, 46
41Literal
42ExprTuple47, 53
43Literal
44ExprTuple57, 58
45Operationoperator: 49
operands: 48
46Operationoperator: 49
operands: 50
47Literal
48ExprTuple51, 53
49Literal
50ExprTuple52, 53
51Operationoperator: 55
operand: 57
52Operationoperator: 55
operand: 58
53Literal
54ExprTuple57
55Literal
56ExprTuple58
57Variable
58Variable