logo

Expression of type ExprTuple

from the theory of proveit.logic.sets.comprehension

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, Lambda, Q, R, f, n
from proveit.core_expr_types import Q__x_1_to_n, R__x_1_to_n, S_1_to_n, f__x_1_to_n, x_1_to_n
from proveit.logic import Forall, Implies, InSet, SetOfAll, SubsetEq
from proveit.logic.sets import general_comprehension_fyn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
sub_expr2 = [S_1_to_n]
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [f, Q, R, S_1_to_n], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Q__x_1_to_n, domains = sub_expr2, condition = R__x_1_to_n), SubsetEq(SetOfAll(instance_param_or_params = sub_expr1, instance_element = f__x_1_to_n, domains = sub_expr2, condition = R__x_1_to_n), general_comprehension_fyn).with_wrapping_at(2)).with_wrapping_at(2)), 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_{f, Q, R, S_{1}, S_{2}, \ldots, S_{n}}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{\left(x_{1} \in S_{1}\right), \left(x_{2} \in S_{2}\right), \ldots, \left(x_{n} \in S_{n}\right)~|~R\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left\{f\left(x_{1}, x_{2}, \ldots, x_{n}\right)~|~R\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right\}_{\left(x_{1} \in S_{1}\right), \left(x_{2} \in S_{2}\right), \ldots, \left(x_{n} \in S_{n}\right)} \subseteq  \\ \left\{f\left(y_{1}, y_{2}, \ldots, y_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right\}_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)} \end{array} \end{array}\right) \end{array} \end{array}\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: 62
body: 3
2ExprTuple62
3Conditionalvalue: 4
condition: 5
4Operationoperator: 18
operand: 8
5Operationoperator: 58
operands: 7
6ExprTuple8
7ExprTuple62, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple39, 50, 47, 12
11Operationoperator: 13
operands: 14
12ExprRangelambda_map: 15
start_index: 61
end_index: 62
13Literal
14ExprTuple16, 17
15Lambdaparameter: 70
body: 64
16Operationoperator: 18
operand: 22
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22
20Literal
21ExprTuple23, 24
22Lambdaparameters: 48
body: 25
23Operationoperator: 27
operand: 30
24Operationoperator: 27
operand: 31
25Conditionalvalue: 29
condition: 35
26ExprTuple30
27Literal
28ExprTuple31
29Operationoperator: 50
operands: 48
30Lambdaparameters: 48
body: 32
31Lambdaparameters: 51
body: 33
32Conditionalvalue: 34
condition: 35
33Conditionalvalue: 36
condition: 37
34Operationoperator: 39
operands: 48
35Operationoperator: 40
operands: 38
36Operationoperator: 39
operands: 51
37Operationoperator: 40
operands: 41
38ExprTuple42, 43
39Variable
40Literal
41ExprTuple44, 45
42ExprRangelambda_map: 46
start_index: 61
end_index: 62
43Operationoperator: 47
operands: 48
44ExprRangelambda_map: 49
start_index: 61
end_index: 62
45Operationoperator: 50
operands: 51
46Lambdaparameter: 70
body: 52
47Variable
48ExprTuple53
49Lambdaparameter: 70
body: 54
50Variable
51ExprTuple55
52Operationoperator: 58
operands: 56
53ExprRangelambda_map: 57
start_index: 61
end_index: 62
54Operationoperator: 58
operands: 59
55ExprRangelambda_map: 60
start_index: 61
end_index: 62
56ExprTuple63, 64
57Lambdaparameter: 70
body: 63
58Literal
59ExprTuple65, 64
60Lambdaparameter: 70
body: 65
61Literal
62Variable
63IndexedVarvariable: 66
index: 70
64IndexedVarvariable: 67
index: 70
65IndexedVarvariable: 68
index: 70
66Variable
67Variable
68Variable
69ExprTuple70
70Variable