# 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.
# import Expression classes needed to build the expression
from proveit import K, 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 = 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())

\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]

In [5]:
stored_expr.style_options()

namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 37
body: 4
3ExprTuple37
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple37, 12
11Lambdaparameters: 46
body: 13
12Operationoperator: 14
operand: 18
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple18
16Operationoperator: 32
operands: 19
17Operationoperator: 20
operands: 21
18Variable
19ExprTuple22, 23
20Literal
21ExprTuple24, 25, 26
22Operationoperator: 57
operand: 34
23Operationoperator: 51
operands: 28
24Operationoperator: 30
operands: 29
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operands: 33
27ExprTuple34
28ExprTuple35, 36
29ExprTuple59, 37
30Literal
31ExprTuple60, 37
32Literal
33ExprTuple38, 39
34Operationoperator: 40
operands: 46
35Operationoperator: 41
operands: 42
36Operationoperator: 43
operands: 44
37Variable
38Operationoperator: 45
operands: 46
39Literal
40Literal
41Literal
42ExprTuple47, 48
43Literal
44ExprTuple49, 55
45Literal
46ExprTuple59, 60
47Operationoperator: 51
operands: 50
48Operationoperator: 51
operands: 52
49Literal
50ExprTuple53, 55
51Literal
52ExprTuple54, 55
53Operationoperator: 57
operand: 59
54Operationoperator: 57
operand: 60
55Literal
56ExprTuple59
57Literal
58ExprTuple60
59Variable
60Variable