logo

Expression of type ExprTuple

from the theory of proveit.logic.sets.intersection

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, n, x
from proveit.core_expr_types import Q__y_1_to_n, R__y_1_to_n, S_1_to_n, y_1_to_n
from proveit.logic import Equals, Exists, Forall, InSet
from proveit.logic.sets import general_intersectall_Ryn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y_1_to_n]
sub_expr2 = [S_1_to_n]
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [S_1_to_n, Q, R, x], instance_expr = Equals(InSet(x, general_intersectall_Ryn), Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(x, R__y_1_to_n), domains = sub_expr2, condition = Q__y_1_to_n)).with_wrapping_at(1), condition = Exists(instance_param_or_params = sub_expr1, instance_expr = Q__y_1_to_n, domains = sub_expr2)), 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_{S_{1}, S_{2}, \ldots, S_{n}, Q, R, x~|~\exists_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)}~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(x \in \left[\bigcap_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~R\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right]\right) \\  = \left[\forall_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left(x \in R\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right)\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: 55
body: 3
2ExprTuple55
3Conditionalvalue: 4
condition: 5
4Operationoperator: 24
operand: 8
5Operationoperator: 51
operands: 7
6ExprTuple8
7ExprTuple55, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple12, 47, 43, 39
11Conditionalvalue: 13
condition: 14
12ExprRangelambda_map: 15
start_index: 54
end_index: 55
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operand: 22
15Lambdaparameter: 61
body: 56
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22
20Operationoperator: 51
operands: 23
21Operationoperator: 24
operand: 28
22Lambdaparameters: 48
body: 26
23ExprTuple39, 27
24Literal
25ExprTuple28
26Conditionalvalue: 45
condition: 29
27Operationoperator: 30
operand: 34
28Lambdaparameters: 48
body: 32
29Operationoperator: 41
operands: 33
30Literal
31ExprTuple34
32Conditionalvalue: 35
condition: 38
33ExprTuple44
34Lambdaparameters: 48
body: 36
35Operationoperator: 51
operands: 37
36Conditionalvalue: 40
condition: 38
37ExprTuple39, 40
38Operationoperator: 41
operands: 42
39Variable
40Operationoperator: 43
operands: 48
41Literal
42ExprTuple44, 45
43Variable
44ExprRangelambda_map: 46
start_index: 54
end_index: 55
45Operationoperator: 47
operands: 48
46Lambdaparameter: 61
body: 49
47Variable
48ExprTuple50
49Operationoperator: 51
operands: 52
50ExprRangelambda_map: 53
start_index: 54
end_index: 55
51Literal
52ExprTuple57, 56
53Lambdaparameter: 61
body: 57
54Literal
55Variable
56IndexedVarvariable: 58
index: 61
57IndexedVarvariable: 59
index: 61
58Variable
59Variable
60ExprTuple61
61Variable