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 LinDepSets, VecZero, lin_comb_axn, some_nonzero_a
from proveit.logic import Equals, Exists, Forall, InSet, Set
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 = [x_1_to_n], instance_expr = Equals(InSet(Set(x_1_to_n), LinDepSets(V)), Exists(instance_param_or_params = [a_1_to_n], instance_expr = Equals(lin_comb_axn, VecZero(V)), domain = K, condition = some_nonzero_a).with_wrapping()).with_wrapping_at(2), domain = V).with_wrapping(), 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[\begin{array}{l}\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{LinDepSets}\left(V\right)\right) =  \\ \left[\begin{array}{l}\exists_{a_{1}, a_{2}, \ldots, a_{n} \in K~|~\left(a_{1} \neq 0\right) \lor  \left(a_{2} \neq 0\right) \lor  \ldots \lor  \left(a_{n} \neq 0\right)}~\\
\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) = \vec{0}\left(V\right)\right)\end{array}\right] \end{array} \end{array}\right)\end{array}\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: 64
body: 4
3ExprTuple64
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 60
operands: 9
7Literal
8ExprTuple10
9ExprTuple64, 11
10Lambdaparameters: 29
body: 12
11Literal
12Conditionalvalue: 13
condition: 14
13Operationoperator: 40
operands: 15
14Operationoperator: 42
operands: 16
15ExprTuple17, 18
16ExprTuple19
17Operationoperator: 60
operands: 20
18Operationoperator: 21
operand: 26
19ExprRangelambda_map: 23
start_index: 63
end_index: 64
20ExprTuple24, 25
21Literal
22ExprTuple26
23Lambdaparameter: 78
body: 27
24Operationoperator: 28
operands: 29
25Operationoperator: 30
operand: 56
26Lambdaparameters: 31
body: 32
27Operationoperator: 60
operands: 33
28Literal
29ExprTuple34
30Literal
31ExprTuple35
32Conditionalvalue: 36
condition: 37
33ExprTuple72, 56
34ExprRangelambda_map: 38
start_index: 63
end_index: 64
35ExprRangelambda_map: 39
start_index: 63
end_index: 64
36Operationoperator: 40
operands: 41
37Operationoperator: 42
operands: 43
38Lambdaparameter: 78
body: 72
39Lambdaparameter: 78
body: 73
40Literal
41ExprTuple44, 45
42Literal
43ExprTuple46, 47
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operand: 56
46ExprRangelambda_map: 52
start_index: 63
end_index: 64
47Operationoperator: 53
operands: 54
48Literal
49ExprTuple55
50Literal
51ExprTuple56
52Lambdaparameter: 78
body: 57
53Literal
54ExprTuple58
55ExprRangelambda_map: 59
start_index: 63
end_index: 64
56Variable
57Operationoperator: 60
operands: 61
58ExprRangelambda_map: 62
start_index: 63
end_index: 64
59Lambdaparameter: 78
body: 65
60Literal
61ExprTuple73, 66
62Lambdaparameter: 78
body: 67
63Literal
64Variable
65Operationoperator: 68
operands: 69
66Variable
67Operationoperator: 70
operands: 71
68Literal
69ExprTuple73, 72
70Literal
71ExprTuple73, 74
72IndexedVarvariable: 75
index: 78
73IndexedVarvariable: 76
index: 78
74Literal
75Variable
76Variable
77ExprTuple78
78Variable