logo

Expression of type Forall

from the theory of proveit.linear_algebra.inner_products

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 H, K, alpha, x
from proveit.linear_algebra import InnerProdSpaces, Norm, ScalarMult
from proveit.logic import Equals, Forall
from proveit.numbers import Abs, Mult
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [H], instance_expr = Forall(instance_param_or_params = [alpha, x], instance_expr = Equals(Norm(ScalarMult(alpha, x)), Mult(Abs(alpha), Norm(x))), domains = [K, H]), domain = InnerProdSpaces(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_{H \underset{{\scriptscriptstyle c}}{\in} \textrm{InnerProdSpaces}\left(K\right)}~\left[\forall_{\alpha \in K, x \in H}~\left(\left \|\alpha \cdot x\right \| = \left(\left|\alpha\right| \cdot \left \|x\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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 36
body: 4
3ExprTuple36
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 11
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11
9Literal
10ExprTuple36, 12
11Lambdaparameters: 38
body: 13
12Operationoperator: 14
operand: 35
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple35
16Operationoperator: 18
operands: 19
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24, 25
22Operationoperator: 41
operand: 32
23Operationoperator: 27
operands: 28
24Operationoperator: 30
operands: 29
25Operationoperator: 30
operands: 31
26ExprTuple32
27Literal
28ExprTuple33, 34
29ExprTuple43, 35
30Literal
31ExprTuple44, 36
32Operationoperator: 37
operands: 38
33Operationoperator: 39
operand: 43
34Operationoperator: 41
operand: 44
35Variable
36Variable
37Literal
38ExprTuple43, 44
39Literal
40ExprTuple43
41Literal
42ExprTuple44
43Variable
44Variable