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 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, conditions = [InSet(subtract(Add(j, one), i), Natural), Equals(k, subtract(i, a)), Equals(l, subtract(j, a))]), InSet(a, 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}, k = \left(i - a\right), l = \left(j - a\right)}~\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)\right) \textrm{ if } a \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: 22
operands: 5
3Literal
4ExprTuple6
5ExprTuple57, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple55, 53, 31, 33
9Conditionalvalue: 10
condition: 11
10Operationoperator: 25
operands: 12
11Operationoperator: 13
operands: 14
12ExprTuple15, 16
13Literal
14ExprTuple17, 18, 19
15ExprTuple20
16ExprTuple21
17Operationoperator: 22
operands: 23
18Operationoperator: 25
operands: 24
19Operationoperator: 25
operands: 26
20ExprRangelambda_map: 27
start_index: 55
end_index: 53
21ExprRangelambda_map: 28
start_index: 31
end_index: 33
22Literal
23ExprTuple29, 30
24ExprTuple31, 32
25Literal
26ExprTuple33, 34
27Lambdaparameter: 56
body: 35
28Lambdaparameter: 56
body: 36
29Operationoperator: 51
operands: 37
30Literal
31Variable
32Operationoperator: 51
operands: 38
33Variable
34Operationoperator: 51
operands: 39
35Operationoperator: 41
operand: 56
36Operationoperator: 41
operand: 46
37ExprTuple43, 44
38ExprTuple55, 45
39ExprTuple53, 45
40ExprTuple56
41Variable
42ExprTuple46
43Operationoperator: 51
operands: 47
44Operationoperator: 49
operand: 55
45Operationoperator: 49
operand: 57
46Operationoperator: 51
operands: 52
47ExprTuple53, 54
48ExprTuple55
49Literal
50ExprTuple57
51Literal
52ExprTuple56, 57
53Variable
54Literal
55Variable
56Variable
57Variable