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, Forall, InSet
from proveit.numbers import Add, Integer, Natural, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [i, j, k, l], instance_expr = neg_shift_equiv_both, conditions = [InSet(subtract(Add(j, one), i), Natural), Equals(Add(i, a), Add(k, b)), Equals(Add(j, a), Add(l, b))]), And(InSet(a, Integer), InSet(b, Integer)))
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_{i, j, k, l~|~\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)}~\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)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z}\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: 3
operand: 6
2Operationoperator: 17
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 9
body: 10
7Operationoperator: 26
operands: 11
8Operationoperator: 26
operands: 12
9ExprTuple68, 66, 57, 58
10Conditionalvalue: 13
condition: 14
11ExprTuple69, 15
12ExprTuple71, 15
13Operationoperator: 29
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple21, 22, 23
19ExprTuple24
20ExprTuple25
21Operationoperator: 26
operands: 27
22Operationoperator: 29
operands: 28
23Operationoperator: 29
operands: 30
24ExprRangelambda_map: 31
start_index: 56
end_index: 32
25ExprRangelambda_map: 33
start_index: 34
end_index: 35
26Literal
27ExprTuple36, 37
28ExprTuple38, 39
29Literal
30ExprTuple40, 41
31Lambdaparameter: 74
body: 42
32Operationoperator: 72
operand: 66
33Lambdaparameter: 74
body: 44
34Operationoperator: 72
operand: 57
35Operationoperator: 72
operand: 58
36Operationoperator: 64
operands: 47
37Literal
38Operationoperator: 64
operands: 48
39Operationoperator: 64
operands: 49
40Operationoperator: 64
operands: 50
41Operationoperator: 64
operands: 51
42Operationoperator: 53
operand: 59
43ExprTuple66
44Operationoperator: 53
operand: 60
45ExprTuple57
46ExprTuple58
47ExprTuple55, 56
48ExprTuple68, 69
49ExprTuple57, 71
50ExprTuple66, 69
51ExprTuple58, 71
52ExprTuple59
53Variable
54ExprTuple60
55Operationoperator: 64
operands: 61
56Operationoperator: 72
operand: 68
57Variable
58Variable
59Operationoperator: 64
operands: 63
60Operationoperator: 64
operands: 65
61ExprTuple66, 67
62ExprTuple68
63ExprTuple70, 69
64Literal
65ExprTuple70, 71
66Variable
67Literal
68Variable
69Variable
70Operationoperator: 72
operand: 74
71Variable
72Literal
73ExprTuple74
74Variable