logo

Expression of type ExprTuple

from the theory of proveit.logic.equality

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, ExprRange, ExprTuple, IndexedVar, Lambda, Variable, n, x
from proveit.core_expr_types import x_1_to_np1
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [x_1_to_np1], instance_expr = Equals(IndexedVar(x, one), IndexedVar(x, Add(n, one))), condition = ExprRange(sub_expr1, Equals(IndexedVar(x, sub_expr1), IndexedVar(x, Add(sub_expr1, one))), one, n)), InSet(n, NaturalPos))))
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(n \mapsto \left\{\forall_{x_{1}, x_{2}, \ldots, x_{n + 1}~|~\left(x_{1} = x_{1 + 1}\right), \left(x_{2} = x_{2 + 1}\right), \ldots, \left(x_{n} = x_{n + 1}\right)}~\left(x_{1} = x_{n + 1}\right) \textrm{ if } n \in \mathbb{N}^+\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
1Lambdaparameter: 32
body: 3
2ExprTuple32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple32, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple14
13Conditionalvalue: 15
condition: 16
14ExprRangelambda_map: 17
start_index: 42
end_index: 27
15Operationoperator: 30
operands: 18
16Operationoperator: 19
operands: 20
17Lambdaparameter: 41
body: 33
18ExprTuple21, 22
19Literal
20ExprTuple23
21IndexedVarvariable: 36
index: 42
22IndexedVarvariable: 36
index: 27
23ExprRangelambda_map: 26
start_index: 42
end_index: 32
24ExprTuple42
25ExprTuple27
26Lambdaparameter: 41
body: 28
27Operationoperator: 39
operands: 29
28Operationoperator: 30
operands: 31
29ExprTuple32, 42
30Literal
31ExprTuple33, 34
32Variable
33IndexedVarvariable: 36
index: 41
34IndexedVarvariable: 36
index: 38
35ExprTuple41
36Variable
37ExprTuple38
38Operationoperator: 39
operands: 40
39Literal
40ExprTuple41, 42
41Variable
42Literal