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 Span, SpanningSets, VecSpaces
from proveit.logic import Equals, Forall, InSet, 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, SpanningSets(V)), Equals(V, Span(sub_expr1))), 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(\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{SpanningSets}\left(V\right)\right) = \left(V = \textrm{Span}\left(\left\{x_{1}, x_{2}, \ldots, x_{n}\right\}\right)\right)\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: 49
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 21
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple49, 13
12Lambdaparameter: 55
body: 15
13Operationoperator: 16
operand: 20
14ExprTuple55
15Conditionalvalue: 18
condition: 19
16Literal
17ExprTuple20
18Operationoperator: 21
operand: 24
19Operationoperator: 46
operands: 23
20Variable
21Literal
22ExprTuple24
23ExprTuple55, 25
24Lambdaparameters: 51
body: 26
25Literal
26Conditionalvalue: 27
condition: 28
27Operationoperator: 36
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32, 33
30Literal
31ExprTuple34
32Operationoperator: 46
operands: 35
33Operationoperator: 36
operands: 37
34ExprRangelambda_map: 38
start_index: 54
end_index: 55
35ExprTuple48, 39
36Literal
37ExprTuple49, 40
38Lambdaparameter: 59
body: 41
39Operationoperator: 42
operand: 49
40Operationoperator: 44
operand: 48
41Operationoperator: 46
operands: 47
42Literal
43ExprTuple49
44Literal
45ExprTuple48
46Literal
47ExprTuple56, 49
48Operationoperator: 50
operands: 51
49Variable
50Literal
51ExprTuple52
52ExprRangelambda_map: 53
start_index: 54
end_index: 55
53Lambdaparameter: 59
body: 56
54Literal
55Variable
56IndexedVarvariable: 57
index: 59
57Variable
58ExprTuple59
59Variable