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 x_1_to_n
from proveit.linear_algebra import Bases, LinDepSets, SpanningSets, VecSpaces
from proveit.logic import And, Equals, Forall, InSet, NotInSet, Set
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Set(x_1_to_n)
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(InSet(sub_expr1, Bases(V)), And(InSet(sub_expr1, SpanningSets(V)), NotInSet(sub_expr1, LinDepSets(V))).with_wrapping_at(2)).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} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{Bases}\left(V\right)\right) =  \\ \left(\begin{array}{c} \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{SpanningSets}\left(V\right)\right) \land  \\ \left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \notin \textrm{LinDepSets}\left(V\right)\right) \end{array}\right) \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: 20
body: 3
3Operationoperator: 21
operand: 5
4ExprTuple5
5Lambdaparameter: 58
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 21
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple58, 13
12Lambdaparameter: 61
body: 15
13Operationoperator: 16
operand: 20
14ExprTuple61
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple20
18Operationoperator: 21
operand: 24
19Operationoperator: 47
operands: 23
20Variable
21Literal
22ExprTuple24
23ExprTuple61, 25
24Lambdaparameters: 54
body: 26
25Literal
26Conditionalvalue: 27
condition: 28
27Operationoperator: 29
operands: 30
28Operationoperator: 36
operands: 31
29Literal
30ExprTuple32, 33
31ExprTuple34
32Operationoperator: 47
operands: 35
33Operationoperator: 36
operands: 37
34ExprRangelambda_map: 38
start_index: 60
end_index: 61
35ExprTuple50, 39
36Literal
37ExprTuple40, 41
38Lambdaparameter: 65
body: 42
39Operationoperator: 43
operand: 58
40Operationoperator: 47
operands: 44
41Operationoperator: 45
operands: 46
42Operationoperator: 47
operands: 48
43Literal
44ExprTuple50, 49
45Literal
46ExprTuple50, 51
47Literal
48ExprTuple62, 58
49Operationoperator: 52
operand: 58
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operand: 58
52Literal
53Literal
54ExprTuple57
55Literal
56ExprTuple58
57ExprRangelambda_map: 59
start_index: 60
end_index: 61
58Variable
59Lambdaparameter: 65
body: 62
60Literal
61Variable
62IndexedVarvariable: 63
index: 65
63Variable
64ExprTuple65
65Variable