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, n
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
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [n], instance_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))), domain = NaturalPos)
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_{n \in \mathbb{N}^+}~\left[\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]\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: 31
operand: 2
1ExprTuple2
2Lambdaparameter: 58
body: 4
3ExprTuple58
4Conditionalvalue: 5
condition: 6
5Operationoperator: 31
operand: 9
6Operationoperator: 59
operands: 8
7ExprTuple9
8ExprTuple58, 10
9Lambdaparameter: 50
body: 11
10Literal
11Operationoperator: 31
operand: 13
12ExprTuple13
13Lambdaparameter: 62
body: 15
14ExprTuple62
15Conditionalvalue: 16
condition: 17
16Operationoperator: 31
operand: 21
17Operationoperator: 19
operands: 20
18ExprTuple21
19Literal
20ExprTuple62, 22
21Lambdaparameters: 23
body: 24
22Operationoperator: 25
operand: 50
23ExprTuple27
24Conditionalvalue: 28
condition: 29
25Literal
26ExprTuple50
27ExprRangelambda_map: 30
start_index: 57
end_index: 58
28Operationoperator: 31
operand: 34
29Operationoperator: 45
operands: 33
30Lambdaparameter: 70
body: 65
31Literal
32ExprTuple34
33ExprTuple35
34Lambdaparameters: 36
body: 37
35ExprRangelambda_map: 38
start_index: 57
end_index: 58
36ExprTuple39
37Conditionalvalue: 40
condition: 41
38Lambdaparameter: 70
body: 42
39ExprRangelambda_map: 43
start_index: 57
end_index: 58
40Operationoperator: 59
operands: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 59
operands: 47
43Lambdaparameter: 70
body: 66
44ExprTuple48, 62
45Literal
46ExprTuple49
47ExprTuple65, 50
48Operationoperator: 51
operands: 52
49ExprRangelambda_map: 53
start_index: 57
end_index: 58
50Variable
51Literal
52ExprTuple54
53Lambdaparameter: 70
body: 55
54ExprRangelambda_map: 56
start_index: 57
end_index: 58
55Operationoperator: 59
operands: 60
56Lambdaparameter: 70
body: 61
57Literal
58Variable
59Literal
60ExprTuple66, 62
61Operationoperator: 63
operands: 64
62Variable
63Literal
64ExprTuple65, 66
65IndexedVarvariable: 67
index: 70
66IndexedVarvariable: 68
index: 70
67Variable
68Variable
69ExprTuple70
70Variable