logo

Expression of type Forall

from the theory of proveit.linear_algebra.scalar_multiplication

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
from proveit.core_expr_types import a_1_to_n, x_1_to_n
from proveit.linear_algebra import VecSpaces, lin_comb_axn
from proveit.logic import Forall, InSet
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_1_to_n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(lin_comb_axn, V), domain = V), domain = K), 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_{1}, a_{2}, \ldots, a_{n} \in K}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right) \in V\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: 23
operand: 2
1ExprTuple2
2Lambdaparameter: 42
body: 3
3Operationoperator: 23
operand: 5
4ExprTuple5
5Lambdaparameter: 54
body: 7
6ExprTuple54
7Conditionalvalue: 8
condition: 9
8Operationoperator: 23
operand: 13
9Operationoperator: 11
operands: 12
10ExprTuple13
11Literal
12ExprTuple54, 14
13Lambdaparameters: 15
body: 16
14Operationoperator: 17
operand: 42
15ExprTuple19
16Conditionalvalue: 20
condition: 21
17Literal
18ExprTuple42
19ExprRangelambda_map: 22
start_index: 49
end_index: 50
20Operationoperator: 23
operand: 26
21Operationoperator: 37
operands: 25
22Lambdaparameter: 62
body: 57
23Literal
24ExprTuple26
25ExprTuple27
26Lambdaparameters: 28
body: 29
27ExprRangelambda_map: 30
start_index: 49
end_index: 50
28ExprTuple31
29Conditionalvalue: 32
condition: 33
30Lambdaparameter: 62
body: 34
31ExprRangelambda_map: 35
start_index: 49
end_index: 50
32Operationoperator: 51
operands: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 51
operands: 39
35Lambdaparameter: 62
body: 58
36ExprTuple40, 54
37Literal
38ExprTuple41
39ExprTuple57, 42
40Operationoperator: 43
operands: 44
41ExprRangelambda_map: 45
start_index: 49
end_index: 50
42Variable
43Literal
44ExprTuple46
45Lambdaparameter: 62
body: 47
46ExprRangelambda_map: 48
start_index: 49
end_index: 50
47Operationoperator: 51
operands: 52
48Lambdaparameter: 62
body: 53
49Literal
50Variable
51Literal
52ExprTuple58, 54
53Operationoperator: 55
operands: 56
54Variable
55Literal
56ExprTuple57, 58
57IndexedVarvariable: 59
index: 62
58IndexedVarvariable: 60
index: 62
59Variable
60Variable
61ExprTuple62
62Variable