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
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, Natural, Neg, two
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]), Add(j, Neg(i), two)), 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(j - i + 2\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
2ExprTuple34, 24
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Lambdaparameters: 7
body: 8
7ExprTuple32, 31
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 22
operands: 19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Literal
19ExprTuple27, 24
20Literal
21ExprTuple31, 25, 26
22Literal
23ExprTuple27
24Variable
25Operationoperator: 28
operand: 32
26Literal
27ExprRangelambda_map: 30
start_index: 32
end_index: 31
28Literal
29ExprTuple32
30Lambdaparameter: 36
body: 33
31Variable
32Variable
33Operationoperator: 34
operand: 36
34Variable
35ExprTuple36
36Variable