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, a, x, y
from proveit.linear_algebra import InnerProd, InnerProdSpaces, ScalarMult
from proveit.logic import Equals, Forall
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [H], instance_expr = Forall(instance_param_or_params = [a], instance_expr = Forall(instance_param_or_params = [x, y], instance_expr = Equals(InnerProd(ScalarMult(a, x), y), ScalarMult(a, InnerProd(x, y))), domain = H), domain = K), 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_{a \in K}~\left[\forall_{x, y \in H}~\left(\left \langle a \cdot x, y\right \rangle = \left(a \cdot \left \langle x, y\right \rangle\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: 18
operand: 2
1ExprTuple2
2Lambdaparameter: 41
body: 4
3ExprTuple41
4Conditionalvalue: 5
condition: 6
5Operationoperator: 18
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple41, 11
10Lambdaparameter: 46
body: 13
11Operationoperator: 14
operand: 22
12ExprTuple46
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple22
16Operationoperator: 18
operand: 21
17Operationoperator: 37
operands: 20
18Literal
19ExprTuple21
20ExprTuple46, 22
21Lambdaparameters: 45
body: 23
22Variable
23Conditionalvalue: 24
condition: 25
24Operationoperator: 26
operands: 27
25Operationoperator: 28
operands: 29
26Literal
27ExprTuple30, 31
28Literal
29ExprTuple32, 33
30Operationoperator: 44
operands: 34
31Operationoperator: 42
operands: 35
32Operationoperator: 37
operands: 36
33Operationoperator: 37
operands: 38
34ExprTuple39, 48
35ExprTuple46, 40
36ExprTuple47, 41
37Literal
38ExprTuple48, 41
39Operationoperator: 42
operands: 43
40Operationoperator: 44
operands: 45
41Variable
42Literal
43ExprTuple46, 47
44Literal
45ExprTuple47, 48
46Variable
47Variable
48Variable