logo

Expression of type ExprTuple

from the theory of proveit.core_expr_types.conditionals

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, ConditionalSet, ExprRange, ExprTuple, IndexedVar, Lambda, 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, FALSE
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda([a_1_to_m, b, c_1_to_n], Equals(ConditionalSet(ExprRange(sub_expr1, Conditional(IndexedVar(a, sub_expr1), FALSE), one, m), b, ExprRange(sub_expr1, Conditional(IndexedVar(c, sub_expr1), FALSE), one, n)), b)))
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(a_{1}, a_{2}, \ldots, a_{m}, b, c_{1}, c_{2}, \ldots, c_{n}\right) \mapsto \left(\left\{\begin{array}{ccc}a_{1} \textrm{ if } \bot \\ a_{2} \textrm{ if } \bot \\  \vdots \\ a_{m} \textrm{ if } \bot \\ b \\ c_{1} \textrm{ if } \bot \\ c_{2} \textrm{ if } \bot \\  \vdots \\ c_{n} \textrm{ if } \bot\end{array}\right.. = b\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
2ExprTuple4, 14, 5
3Operationoperator: 6
operands: 7
4ExprRangelambda_map: 8
start_index: 19
end_index: 17
5ExprRangelambda_map: 9
start_index: 19
end_index: 20
6Literal
7ExprTuple10, 14
8Lambdaparameter: 29
body: 23
9Lambdaparameter: 29
body: 24
10Operationoperator: 11
operands: 12
11Literal
12ExprTuple13, 14, 15
13ExprRangelambda_map: 16
start_index: 19
end_index: 17
14Variable
15ExprRangelambda_map: 18
start_index: 19
end_index: 20
16Lambdaparameter: 29
body: 21
17Variable
18Lambdaparameter: 29
body: 22
19Literal
20Variable
21Conditionalvalue: 23
condition: 25
22Conditionalvalue: 24
condition: 25
23IndexedVarvariable: 26
index: 29
24IndexedVarvariable: 27
index: 29
25Literal
26Variable
27Variable
28ExprTuple29
29Variable