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, b, i, j, k, l
from proveit.core_expr_types.tuples import neg_shift_equiv_both
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(neg_shift_equiv_both, And(InSet(subtract(Add(j, one), i), Natural), Equals(Add(i, a), Add(k, b)), Equals(Add(j, a), Add(l, b))))
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 + a\right), f\left(\left(i - 1\right) + a\right), \ldots, f\left(j + a\right)\right) = \left(f\left(k + b\right), f\left(\left(k - 1\right) + b\right), \ldots, f\left(l + b\right)\right) \textrm{ if } \left(\left(j + 1\right) - i\right) \in \mathbb{N} ,  \left(i + a\right) = \left(k + b\right) ,  \left(j + a\right) = \left(l + b\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: 43
end_index: 19
12ExprRangelambda_map: 20
start_index: 21
end_index: 22
13Literal
14ExprTuple23, 24
15ExprTuple25, 26
16Literal
17ExprTuple27, 28
18Lambdaparameter: 61
body: 29
19Operationoperator: 59
operand: 53
20Lambdaparameter: 61
body: 31
21Operationoperator: 59
operand: 44
22Operationoperator: 59
operand: 45
23Operationoperator: 51
operands: 34
24Literal
25Operationoperator: 51
operands: 35
26Operationoperator: 51
operands: 36
27Operationoperator: 51
operands: 37
28Operationoperator: 51
operands: 38
29Operationoperator: 40
operand: 46
30ExprTuple53
31Operationoperator: 40
operand: 47
32ExprTuple44
33ExprTuple45
34ExprTuple42, 43
35ExprTuple55, 56
36ExprTuple44, 58
37ExprTuple53, 56
38ExprTuple45, 58
39ExprTuple46
40Variable
41ExprTuple47
42Operationoperator: 51
operands: 48
43Operationoperator: 59
operand: 55
44Variable
45Variable
46Operationoperator: 51
operands: 50
47Operationoperator: 51
operands: 52
48ExprTuple53, 54
49ExprTuple55
50ExprTuple57, 56
51Literal
52ExprTuple57, 58
53Variable
54Literal
55Variable
56Variable
57Operationoperator: 59
operand: 61
58Variable
59Literal
60ExprTuple61
61Variable