logo

Expression of type ExprTuple

from the theory of proveit.logic.sets.enumeration

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 ExprRange, ExprTuple, IndexedVar, Variable, a, b, c, m, n
from proveit.core_expr_types import a_1_to_m, c_1_to_n
from proveit.logic import Equals, InSet, Or, Set
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(InSet(b, Set(a_1_to_m, b, c_1_to_n)), Or(ExprRange(sub_expr1, Equals(b, IndexedVar(a, sub_expr1)), one, m), Equals(b, b), ExprRange(sub_expr1, Equals(b, IndexedVar(c, sub_expr1)), one, n)))
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(b \in \left\{a_{1}, a_{2}, \ldots, a_{m}, b,c_{1}, c_{2}, \ldots, c_{n}\right\}, \left(b = a_{1}\right) \lor  \left(b = a_{2}\right) \lor  \ldots \lor  \left(b = a_{m}\right) \lor \left(b = b\right)\lor \left(b = c_{1}\right) \lor  \left(b = c_{2}\right) \lor  \ldots \lor  \left(b = c_{n}\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple29, 7
5Literal
6ExprTuple8, 9, 10
7Operationoperator: 11
operands: 12
8ExprRangelambda_map: 13
start_index: 23
end_index: 21
9Operationoperator: 26
operands: 14
10ExprRangelambda_map: 15
start_index: 23
end_index: 24
11Literal
12ExprTuple16, 29, 17
13Lambdaparameter: 34
body: 18
14ExprTuple29, 29
15Lambdaparameter: 34
body: 19
16ExprRangelambda_map: 20
start_index: 23
end_index: 21
17ExprRangelambda_map: 22
start_index: 23
end_index: 24
18Operationoperator: 26
operands: 25
19Operationoperator: 26
operands: 27
20Lambdaparameter: 34
body: 28
21Variable
22Lambdaparameter: 34
body: 30
23Literal
24Variable
25ExprTuple29, 28
26Literal
27ExprTuple29, 30
28IndexedVarvariable: 31
index: 34
29Variable
30IndexedVarvariable: 32
index: 34
31Variable
32Variable
33ExprTuple34
34Variable