logo

Expression of type ExprTuple

from the theory of proveit.numbers.summation

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, k
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, Interval, eight, nine, one, subtract, two
In [2]:
# build up the expression from sub-expressions
sub_expr1 = subtract(k, two)
sub_expr2 = Conditional(sub_expr1, InSet(k, Interval(nine, nine)))
sub_expr3 = Conditional(sub_expr1, InSet(k, Interval(Add(eight, one), nine)))
expr = ExprTuple(Forall(instance_param_or_params = [k], instance_expr = Equals(sub_expr3, sub_expr2)), Equals(Lambda(k, sub_expr3), Lambda(k, sub_expr2)).with_wrapping_at(2))
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(\forall_{k}~\left(\left\{k - 2 \textrm{ if } k \in \{8 + 1~\ldotp \ldotp~9\}\right.. = \left\{k - 2 \textrm{ if } k \in \{9~\ldotp \ldotp~9\}\right..\right), \begin{array}{c} \begin{array}{l} \left[k \mapsto \left\{k - 2 \textrm{ if } k \in \{8 + 1~\ldotp \ldotp~9\}\right..\right] =  \\ \left[k \mapsto \left\{k - 2 \textrm{ if } k \in \{9~\ldotp \ldotp~9\}\right..\right] \end{array} \end{array}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 6
2Operationoperator: 11
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameter: 24
body: 9
7Lambdaparameter: 24
body: 13
8Lambdaparameter: 24
body: 14
9Operationoperator: 11
operands: 12
10ExprTuple24
11Literal
12ExprTuple13, 14
13Conditionalvalue: 16
condition: 15
14Conditionalvalue: 16
condition: 17
15Operationoperator: 20
operands: 18
16Operationoperator: 34
operands: 19
17Operationoperator: 20
operands: 21
18ExprTuple24, 22
19ExprTuple24, 23
20Literal
21ExprTuple24, 25
22Operationoperator: 29
operands: 26
23Operationoperator: 27
operand: 32
24Variable
25Operationoperator: 29
operands: 30
26ExprTuple31, 33
27Literal
28ExprTuple32
29Literal
30ExprTuple33, 33
31Operationoperator: 34
operands: 35
32Literal
33Literal
34Literal
35ExprTuple36, 37
36Literal
37Literal