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 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 = 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
9ExprTuple64, 62, 52, 53
10Conditionalvalue: 13
condition: 14
11ExprTuple65, 15
12ExprTuple67, 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: 64
end_index: 62
25ExprRangelambda_map: 32
start_index: 52
end_index: 53
26Literal
27ExprTuple33, 34
28ExprTuple35, 36
29Literal
30ExprTuple37, 38
31Lambdaparameter: 66
body: 39
32Lambdaparameter: 66
body: 41
33Operationoperator: 60
operands: 42
34Literal
35Operationoperator: 60
operands: 43
36Operationoperator: 60
operands: 44
37Operationoperator: 60
operands: 45
38Operationoperator: 60
operands: 46
39Operationoperator: 48
operand: 54
40ExprTuple66
41Operationoperator: 48
operand: 55
42ExprTuple50, 51
43ExprTuple64, 65
44ExprTuple52, 67
45ExprTuple62, 65
46ExprTuple53, 67
47ExprTuple54
48Variable
49ExprTuple55
50Operationoperator: 60
operands: 56
51Operationoperator: 57
operand: 64
52Variable
53Variable
54Operationoperator: 60
operands: 59
55Operationoperator: 60
operands: 61
56ExprTuple62, 63
57Literal
58ExprTuple64
59ExprTuple66, 65
60Literal
61ExprTuple66, 67
62Variable
63Literal
64Variable
65Variable
66Variable
67Variable