logo

Expression of type Equals

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, 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 = Equals(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))).with_wrapping_at(2)
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())
\begin{array}{c} \begin{array}{l} \left(b \in \left\{a_{1}, a_{2}, \ldots, a_{m}, b,c_{1}, c_{2}, \ldots, c_{n}\right\}\right) =  \\ \left(\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) \end{array} \end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()(2)('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 27
operands: 1
1ExprTuple2, 3
2Operationoperator: 4
operands: 5
3Operationoperator: 6
operands: 7
4Literal
5ExprTuple30, 8
6Literal
7ExprTuple9, 10, 11
8Operationoperator: 12
operands: 13
9ExprRangelambda_map: 14
start_index: 24
end_index: 22
10Operationoperator: 27
operands: 15
11ExprRangelambda_map: 16
start_index: 24
end_index: 25
12Literal
13ExprTuple17, 30, 18
14Lambdaparameter: 35
body: 19
15ExprTuple30, 30
16Lambdaparameter: 35
body: 20
17ExprRangelambda_map: 21
start_index: 24
end_index: 22
18ExprRangelambda_map: 23
start_index: 24
end_index: 25
19Operationoperator: 27
operands: 26
20Operationoperator: 27
operands: 28
21Lambdaparameter: 35
body: 29
22Variable
23Lambdaparameter: 35
body: 31
24Literal
25Variable
26ExprTuple30, 29
27Literal
28ExprTuple30, 31
29IndexedVarvariable: 32
index: 35
30Variable
31IndexedVarvariable: 33
index: 35
32Variable
33Variable
34ExprTuple35
35Variable