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, ExprTuple, Lambda, f, i, j, m, n
from proveit.core_expr_types import Len
from proveit.core_expr_types.tuples import general_range_of_ranges
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Natural, one, zero
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([m, n], Conditional(Forall(instance_param_or_params = [f, i, j], instance_expr = Equals(Len(operands = general_range_of_ranges), zero).with_wrapping_at(1)), And(InSet(m, Natural), InSet(n, Natural), 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(m, n\right) \mapsto \left\{\forall_{f, i, j}~\left(\begin{array}{c} \begin{array}{l} |\left(f\left(m, i\left(m\right)\right), f\left(m, i\left(m\right) + 1\right), \ldots, f\left(m, j\left(m\right)\right), f\left(m + 1, i\left(m + 1\right)\right), f\left(m + 1, i\left(m + 1\right) + 1\right), \ldots, f\left(m + 1, j\left(m + 1\right)\right), \ldots\ldots, f\left(n, i\left(n\right)\right), f\left(n, i\left(n\right) + 1\right), \ldots, f\left(n, j\left(n\right)\right)\right)| \\  = 0 \end{array} \end{array}\right) \textrm{ if } m \in \mathbb{N} ,  n \in \mathbb{N} ,  \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
2ExprTuple33, 34
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameters: 14
body: 15
11Operationoperator: 17
operands: 16
12Operationoperator: 17
operands: 18
13Operationoperator: 20
operands: 19
14ExprTuple44, 41, 42
15Operationoperator: 20
operands: 21
16ExprTuple33, 22
17Literal
18ExprTuple34, 22
19ExprTuple23, 33
20Literal
21ExprTuple24, 25
22Literal
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25Literal
26Literal
27ExprTuple34, 30
28Literal
29ExprTuple31
30Literal
31ExprRangelambda_map: 32
start_index: 33
end_index: 34
32Lambdaparameter: 46
body: 35
33Variable
34Variable
35ExprRangelambda_map: 36
start_index: 37
end_index: 38
36Lambdaparameter: 47
body: 40
37Operationoperator: 41
operand: 46
38Operationoperator: 42
operand: 46
39ExprTuple47
40Operationoperator: 44
operands: 45
41Variable
42Variable
43ExprTuple46
44Variable
45ExprTuple46, 47
46Variable
47Variable