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, g, i, j, k
from proveit.core_expr_types import f_i_to_j, fk, g_i_to_j, gk
from proveit.logic import Equals, Forall, Implies
from proveit.numbers import Integer, Interval
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([f, g], Forall(instance_param_or_params = [i, j], instance_expr = Implies(Forall(instance_param_or_params = [k], instance_expr = Equals(fk, gk), domain = Interval(i, j)), Equals([f_i_to_j], [g_i_to_j])), domain = Integer)))
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, g\right) \mapsto \left[\forall_{i, j \in \mathbb{Z}}~\left(\left[\forall_{k \in \{i~\ldotp \ldotp~j\}}~\left(f\left(k\right) = g\left(k\right)\right)\right] \Rightarrow \left(\left(f\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(g\left(i\right), g\left(i + 1\right), \ldots, g\left(j\right)\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
2ExprTuple43, 44
3Operationoperator: 17
operand: 5
4ExprTuple5
5Lambdaparameters: 47
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14
11Literal
12ExprTuple15, 16
13Operationoperator: 17
operand: 22
14Operationoperator: 33
operands: 19
15Operationoperator: 35
operands: 20
16Operationoperator: 35
operands: 21
17Literal
18ExprTuple22
19ExprTuple23, 24
20ExprTuple50, 25
21ExprTuple51, 25
22Lambdaparameter: 49
body: 26
23ExprTuple27
24ExprTuple28
25Literal
26Conditionalvalue: 29
condition: 30
27ExprRangelambda_map: 31
start_index: 50
end_index: 51
28ExprRangelambda_map: 32
start_index: 50
end_index: 51
29Operationoperator: 33
operands: 34
30Operationoperator: 35
operands: 36
31Lambdaparameter: 48
body: 37
32Lambdaparameter: 48
body: 38
33Literal
34ExprTuple39, 40
35Literal
36ExprTuple49, 41
37Operationoperator: 43
operand: 48
38Operationoperator: 44
operand: 48
39Operationoperator: 43
operand: 49
40Operationoperator: 44
operand: 49
41Operationoperator: 46
operands: 47
42ExprTuple48
43Variable
44Variable
45ExprTuple49
46Literal
47ExprTuple50, 51
48Variable
49Variable
50Variable
51Variable