logo

Expression of type Forall

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 V, a, b
from proveit.linear_algebra import InnerProd, Norm, VecAdd
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 = [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))
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_{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)
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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 34
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 20
operands: 7
6Operationoperator: 8
operands: 9
7ExprTuple10, 11
8Literal
9ExprTuple12, 13, 14
10Operationoperator: 45
operand: 22
11Operationoperator: 39
operands: 16
12Operationoperator: 18
operands: 17
13Operationoperator: 18
operands: 19
14Operationoperator: 20
operands: 21
15ExprTuple22
16ExprTuple23, 24
17ExprTuple47, 25
18Literal
19ExprTuple48, 25
20Literal
21ExprTuple26, 27
22Operationoperator: 28
operands: 34
23Operationoperator: 29
operands: 30
24Operationoperator: 31
operands: 32
25Variable
26Operationoperator: 33
operands: 34
27Literal
28Literal
29Literal
30ExprTuple35, 36
31Literal
32ExprTuple37, 43
33Literal
34ExprTuple47, 48
35Operationoperator: 39
operands: 38
36Operationoperator: 39
operands: 40
37Literal
38ExprTuple41, 43
39Literal
40ExprTuple42, 43
41Operationoperator: 45
operand: 47
42Operationoperator: 45
operand: 48
43Literal
44ExprTuple47
45Literal
46ExprTuple48
47Variable
48Variable