# 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 Conditional, K, 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 = 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())

\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()

namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple33, 8
7Lambdaparameters: 42
body: 9
8Operationoperator: 10
operand: 14
9Conditionalvalue: 12
condition: 13
10Literal
11ExprTuple14
12Operationoperator: 28
operands: 15
13Operationoperator: 16
operands: 17
14Variable
15ExprTuple18, 19
16Literal
17ExprTuple20, 21, 22
18Operationoperator: 53
operand: 30
19Operationoperator: 47
operands: 24
20Operationoperator: 26
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operands: 29
23ExprTuple30
24ExprTuple31, 32
25ExprTuple55, 33
26Literal
27ExprTuple56, 33
28Literal
29ExprTuple34, 35
30Operationoperator: 36
operands: 42
31Operationoperator: 37
operands: 38
32Operationoperator: 39
operands: 40
33Variable
34Operationoperator: 41
operands: 42
35Literal
36Literal
37Literal
38ExprTuple43, 44
39Literal
40ExprTuple45, 51
41Literal
42ExprTuple55, 56
43Operationoperator: 47
operands: 46
44Operationoperator: 47
operands: 48
45Literal
46ExprTuple49, 51
47Literal
48ExprTuple50, 51
49Operationoperator: 53
operand: 55
50Operationoperator: 53
operand: 56
51Literal
52ExprTuple55
53Literal
54ExprTuple56
55Variable
56Variable