logo

Expression of type ExprTuple

from the theory of proveit.core_expr_types.tuples

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, ExprRange, ExprTuple, Function, Lambda, Variable, f, i, j, m, n
from proveit.logic import Equals
from proveit.numbers import Add, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([f, i, j, m, n], Conditional(Equals([ExprRange(sub_expr1, ExprRange(sub_expr2, Function(f, [sub_expr1, sub_expr2]), i, j), m, n)], []), Equals(Add(n, one), m))))
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(\left(f, i, j, m, n\right) \mapsto \left\{\left(f\left(m, i\right), f\left(m, i + 1\right), \ldots, f\left(m, j\right), f\left(m + 1, i\right), f\left(m + 1, i + 1\right), \ldots, f\left(m + 1, j\right), \ldots\ldots, f\left(n, i\right), f\left(n, i + 1\right), \ldots, f\left(n, j\right)\right) = () \textrm{ if } \left(n + 1\right) = m\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
1Lambdaparameters: 2
body: 3
2ExprTuple26, 22, 23, 16, 17
3Conditionalvalue: 4
condition: 5
4Operationoperator: 7
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 10
7Literal
8ExprTuple11, 16
9ExprTuple12
10ExprTuple
11Operationoperator: 13
operands: 14
12ExprRangelambda_map: 15
start_index: 16
end_index: 17
13Literal
14ExprTuple17, 18
15Lambdaparameter: 28
body: 20
16Variable
17Variable
18Literal
19ExprTuple28
20ExprRangelambda_map: 21
start_index: 22
end_index: 23
21Lambdaparameter: 29
body: 25
22Variable
23Variable
24ExprTuple29
25Operationoperator: 26
operands: 27
26Variable
27ExprTuple28, 29
28Variable
29Variable