logo

Expression of type Conditional

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 Conditional, a, i, j, k, l
from proveit.core_expr_types.tuples import shift_equiv
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Conditional(shift_equiv, And(InSet(subtract(Add(j, one), i), Natural), Equals(k, subtract(i, a)), Equals(l, subtract(j, a))))
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\left(i\right), f\left(i + 1\right), \ldots, f\left(j\right)\right) = \left(f\left(k + a\right), f\left(\left(k + 1\right) + a\right), \ldots, f\left(l + a\right)\right) \textrm{ if } \left(\left(j + 1\right) - i\right) \in \mathbb{N} ,  k = \left(i - a\right) ,  l = \left(j - a\right)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 16
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple8, 9, 10
6ExprTuple11
7ExprTuple12
8Operationoperator: 13
operands: 14
9Operationoperator: 16
operands: 15
10Operationoperator: 16
operands: 17
11ExprRangelambda_map: 18
start_index: 46
end_index: 44
12ExprRangelambda_map: 19
start_index: 22
end_index: 24
13Literal
14ExprTuple20, 21
15ExprTuple22, 23
16Literal
17ExprTuple24, 25
18Lambdaparameter: 47
body: 26
19Lambdaparameter: 47
body: 27
20Operationoperator: 42
operands: 28
21Literal
22Variable
23Operationoperator: 42
operands: 29
24Variable
25Operationoperator: 42
operands: 30
26Operationoperator: 32
operand: 47
27Operationoperator: 32
operand: 37
28ExprTuple34, 35
29ExprTuple46, 36
30ExprTuple44, 36
31ExprTuple47
32Variable
33ExprTuple37
34Operationoperator: 42
operands: 38
35Operationoperator: 40
operand: 46
36Operationoperator: 40
operand: 48
37Operationoperator: 42
operands: 43
38ExprTuple44, 45
39ExprTuple46
40Literal
41ExprTuple48
42Literal
43ExprTuple47, 48
44Variable
45Literal
46Variable
47Variable
48Variable