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 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 = [K], instance_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_{K}~\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()
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: 10
operand: 2
1ExprTuple2
2Lambdaparameter: 21
body: 3
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameter: 40
body: 7
6ExprTuple40
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 14
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14
12Literal
13ExprTuple40, 15
14Lambdaparameters: 49
body: 16
15Operationoperator: 17
operand: 21
16Conditionalvalue: 19
condition: 20
17Literal
18ExprTuple21
19Operationoperator: 35
operands: 22
20Operationoperator: 23
operands: 24
21Variable
22ExprTuple25, 26
23Literal
24ExprTuple27, 28, 29
25Operationoperator: 60
operand: 37
26Operationoperator: 54
operands: 31
27Operationoperator: 33
operands: 32
28Operationoperator: 33
operands: 34
29Operationoperator: 35
operands: 36
30ExprTuple37
31ExprTuple38, 39
32ExprTuple62, 40
33Literal
34ExprTuple63, 40
35Literal
36ExprTuple41, 42
37Operationoperator: 43
operands: 49
38Operationoperator: 44
operands: 45
39Operationoperator: 46
operands: 47
40Variable
41Operationoperator: 48
operands: 49
42Literal
43Literal
44Literal
45ExprTuple50, 51
46Literal
47ExprTuple52, 58
48Literal
49ExprTuple62, 63
50Operationoperator: 54
operands: 53
51Operationoperator: 54
operands: 55
52Literal
53ExprTuple56, 58
54Literal
55ExprTuple57, 58
56Operationoperator: 60
operand: 62
57Operationoperator: 60
operand: 63
58Literal
59ExprTuple62
60Literal
61ExprTuple63
62Variable
63Variable