logo

Expression of type ExprTuple

from the theory of proveit.linear_algebra.addition

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 Conditional, ExprTuple, K, Lambda, V, n
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [x_1_to_n], instance_expr = InSet(VecAdd(x_1_to_n), V), domain = V), domain = VecSpaces(K))), InSet(n, 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())
\left(n \mapsto \left\{\forall_{K}~\left[\forall_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(x_{1} +  x_{2} +  \ldots +  x_{n}\right) \in V\right)\right]\right] \textrm{ if } n \in \mathbb{N}^+\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 41
body: 3
2ExprTuple41
3Conditionalvalue: 4
condition: 5
4Operationoperator: 17
operand: 8
5Operationoperator: 42
operands: 7
6ExprTuple8
7ExprTuple41, 9
8Lambdaparameter: 28
body: 10
9Literal
10Operationoperator: 17
operand: 12
11ExprTuple12
12Lambdaparameter: 45
body: 14
13ExprTuple45
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operand: 21
16Operationoperator: 19
operands: 20
17Literal
18ExprTuple21
19Literal
20ExprTuple45, 22
21Lambdaparameters: 35
body: 23
22Operationoperator: 24
operand: 28
23Conditionalvalue: 26
condition: 27
24Literal
25ExprTuple28
26Operationoperator: 42
operands: 29
27Operationoperator: 30
operands: 31
28Variable
29ExprTuple32, 45
30Literal
31ExprTuple33
32Operationoperator: 34
operands: 35
33ExprRangelambda_map: 36
start_index: 40
end_index: 41
34Literal
35ExprTuple37
36Lambdaparameter: 48
body: 38
37ExprRangelambda_map: 39
start_index: 40
end_index: 41
38Operationoperator: 42
operands: 43
39Lambdaparameter: 48
body: 44
40Literal
41Variable
42Literal
43ExprTuple44, 45
44IndexedVarvariable: 46
index: 48
45Variable
46Variable
47ExprTuple48
48Variable