logo

Expression of type Forall

from the theory of proveit.linear_algebra.vector_sets

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 Span, VecSpaces, lin_comb_axn
from proveit.logic import Equals, Forall, Set, SetOfAll
from proveit.numbers import NaturalPos
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 = [n], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = Equals(Span(Set(x_1_to_n)), SetOfAll(instance_param_or_params = [a_1_to_n], instance_element = lin_comb_axn, domain = K)).with_wrapping_at(2), domain = V).with_wrapping(), domain = NaturalPos), 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_{n \in \mathbb{N}^+}~\left[\begin{array}{l}\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\\
\left(\begin{array}{c} \begin{array}{l} \textrm{Span}\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}\right) =  \\ \left\{\left(a_{1} \cdot x_{1}\right) +  \left(a_{2} \cdot x_{2}\right) +  \ldots +  \left(a_{n} \cdot x_{n}\right)\right\}_{a_{1}, a_{2}, \ldots, a_{n} \in K} \end{array} \end{array}\right)\end{array}\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: 21
operand: 2
1ExprTuple2
2Lambdaparameter: 73
body: 3
3Operationoperator: 21
operand: 5
4ExprTuple5
5Lambdaparameter: 52
body: 7
6ExprTuple52
7Conditionalvalue: 8
condition: 9
8Operationoperator: 21
operand: 13
9Operationoperator: 11
operands: 12
10ExprTuple13
11Literal
12ExprTuple52, 14
13Lambdaparameter: 64
body: 16
14Operationoperator: 17
operand: 73
15ExprTuple64
16Conditionalvalue: 19
condition: 20
17Literal
18ExprTuple73
19Operationoperator: 21
operand: 24
20Operationoperator: 69
operands: 23
21Literal
22ExprTuple24
23ExprTuple64, 25
24Lambdaparameters: 44
body: 26
25Literal
26Conditionalvalue: 27
condition: 28
27Operationoperator: 29
operands: 30
28Operationoperator: 57
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple34
32Operationoperator: 35
operand: 40
33Operationoperator: 37
operand: 41
34ExprRangelambda_map: 39
start_index: 63
end_index: 64
35Literal
36ExprTuple40
37Literal
38ExprTuple41
39Lambdaparameter: 77
body: 42
40Operationoperator: 43
operands: 44
41Lambdaparameters: 45
body: 46
42Operationoperator: 69
operands: 47
43Literal
44ExprTuple48
45ExprTuple49
46Conditionalvalue: 50
condition: 51
47ExprTuple71, 52
48ExprRangelambda_map: 53
start_index: 63
end_index: 64
49ExprRangelambda_map: 54
start_index: 63
end_index: 64
50Operationoperator: 55
operands: 56
51Operationoperator: 57
operands: 58
52Variable
53Lambdaparameter: 77
body: 71
54Lambdaparameter: 77
body: 72
55Literal
56ExprTuple59
57Literal
58ExprTuple60
59ExprRangelambda_map: 61
start_index: 63
end_index: 64
60ExprRangelambda_map: 62
start_index: 63
end_index: 64
61Lambdaparameter: 77
body: 65
62Lambdaparameter: 77
body: 66
63Literal
64Variable
65Operationoperator: 67
operands: 68
66Operationoperator: 69
operands: 70
67Literal
68ExprTuple72, 71
69Literal
70ExprTuple72, 73
71IndexedVarvariable: 74
index: 77
72IndexedVarvariable: 75
index: 77
73Variable
74Variable
75Variable
76ExprTuple77
77Variable