# 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.
# import Expression classes needed to build the expression
from proveit import K, Lambda, V, n
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import Bases, Dim, VecSpaces
from proveit.logic import Equals, Forall, InSet, Set
from proveit.numbers import NaturalPos

In [2]:
# build up the expression from sub-expressions
expr = Lambda(K, 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(Dim(V), n), condition = InSet(Set(x_1_to_n), Bases(V))), 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())

K \mapsto \left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{n \in \mathbb{N}^+}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n}~|~\left\{x_{1}, x_{2}, \ldots, x_{n}\right\} \in \textrm{Bases}\left(V\right)}~\left(\textrm{Dim}\left(V\right) = n\right)\right]\right]\right]

In [5]:
stored_expr.style_options()

no style options
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Lambdaparameter: 18
body: 1
1Operationoperator: 19
operand: 3
2ExprTuple3
3Lambdaparameter: 40
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 19
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple40, 11
10Lambdaparameter: 43
body: 13
11Operationoperator: 14
operand: 18
12ExprTuple43
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple18
16Operationoperator: 19
operand: 22
17Operationoperator: 29
operands: 21
18Variable
19Literal
20ExprTuple22
21ExprTuple43, 23
22Lambdaparameters: 36
body: 24
23Literal
24Conditionalvalue: 25
condition: 26
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 43
29Literal
30ExprTuple32, 33
31Operationoperator: 34
operand: 40
32Operationoperator: 35
operands: 36
33Operationoperator: 37
operand: 40
34Literal
35Literal
36ExprTuple39
37Literal
38ExprTuple40
39ExprRangelambda_map: 41
start_index: 42
end_index: 43
40Variable
41Lambdaparameter: 47
body: 44
42Literal
43Variable
44IndexedVarvariable: 45
index: 47
45Variable
46ExprTuple47
47Variable