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 ExprTuple, Lambda, f, i, j, x
from proveit.core_expr_types import Len, f_i_to_j, range_i_to_jp1
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([f, x], Forall(instance_param_or_params = [i, j], instance_expr = Equals(Len(operands = [f_i_to_j, x]), Len(operands = [range_i_to_jp1])), condition = InSet(Len(operands = [f_i_to_j]), Natural))))
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, x\right) \mapsto \left[\forall_{i, j~|~|\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right)| \in \mathbb{N}}~\left(|\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right), x\right)| = |\left(i, \left(i + 1\right), \ldots, \left(j + 1\right)\right)|\right)\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
2ExprTuple35, 23
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple29, 33
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 21
operands: 19
16Operationoperator: 21
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19ExprTuple25, 23
20ExprTuple24
21Literal
22ExprTuple25
23Variable
24ExprRangelambda_map: 26
start_index: 29
end_index: 27
25ExprRangelambda_map: 28
start_index: 29
end_index: 33
26Lambdaparameter: 37
body: 37
27Operationoperator: 30
operands: 31
28Lambdaparameter: 37
body: 32
29Variable
30Literal
31ExprTuple33, 34
32Operationoperator: 35
operand: 37
33Variable
34Literal
35Variable
36ExprTuple37
37Variable