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 neg_shift_equiv
from proveit.logic import And, Equals, InSet
from proveit.numbers import Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Conditional(neg_shift_equiv, And(InSet(subtract(subtract(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: 41
end_index: 19
12ExprRangelambda_map: 20
start_index: 21
end_index: 22
13Literal
14ExprTuple23, 24
15ExprTuple38, 25
16Literal
17ExprTuple39, 26
18Lambdaparameter: 58
body: 27
19Operationoperator: 55
operand: 49
20Lambdaparameter: 58
body: 29
21Operationoperator: 55
operand: 38
22Operationoperator: 55
operand: 39
23Operationoperator: 47
operands: 32
24Literal
25Operationoperator: 47
operands: 33
26Operationoperator: 47
operands: 34
27Operationoperator: 36
operand: 52
28ExprTuple49
29Operationoperator: 36
operand: 43
30ExprTuple38
31ExprTuple39
32ExprTuple40, 41
33ExprTuple51, 42
34ExprTuple49, 42
35ExprTuple52
36Variable
37ExprTuple43
38Variable
39Variable
40Operationoperator: 47
operands: 44
41Operationoperator: 55
operand: 51
42Operationoperator: 55
operand: 53
43Operationoperator: 47
operands: 48
44ExprTuple49, 50
45ExprTuple51
46ExprTuple53
47Literal
48ExprTuple52, 53
49Variable
50Operationoperator: 55
operand: 57
51Variable
52Operationoperator: 55
operand: 58
53Variable
54ExprTuple57
55Literal
56ExprTuple58
57Literal
58Variable