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, n
from proveit.core_expr_types import Len, f_1_to_n, i_1_to_n, j_1_to_n
from proveit.core_expr_types.tuples import f_ik_to_jk__1_to_n, range_len_conditions, range_len_sum
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [f_1_to_n, i_1_to_n, j_1_to_n], instance_expr = Equals(Len(operands = [f_ik_to_jk__1_to_n]), range_len_sum).with_wrapping_at(1), condition = range_len_conditions).with_wrapping(), InSet(n, NaturalPos))
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\{\begin{array}{l}\forall_{f_{1}, f_{2}, \ldots, f_{n}, i_{1}, i_{2}, \ldots, i_{n}, j_{1}, j_{2}, \ldots, j_{n}~|~\left(\left(j_{1} - i_{1} + 1\right) \in \mathbb{N}\right), \left(\left(j_{2} - i_{2} + 1\right) \in \mathbb{N}\right), \ldots, \left(\left(j_{n} - i_{n} + 1\right) \in \mathbb{N}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} |\left(f_{1}\left(i_{1}\right), f_{1}\left(i_{1} + 1\right), \ldots, f_{1}\left(j_{1}\right), f_{2}\left(i_{2}\right), f_{2}\left(i_{2} + 1\right), \ldots, f_{2}\left(j_{2}\right), \ldots\ldots, f_{n}\left(i_{n}\right), f_{n}\left(i_{n} + 1\right), \ldots, f_{n}\left(j_{n}\right)\right)| \\  = \left(\left(j_{1} - i_{1} + 1\right) +  \left(j_{2} - i_{2} + 1\right) +  \ldots +  \left(j_{n} - i_{n} + 1\right)\right) \end{array} \end{array}\right)\end{array} \textrm{ if } n \in \mathbb{N}^+\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: 36
operands: 5
3Literal
4ExprTuple6
5ExprTuple35, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple10, 11, 12
9Conditionalvalue: 13
condition: 14
10ExprRangelambda_map: 15
start_index: 49
end_index: 35
11ExprRangelambda_map: 16
start_index: 49
end_index: 35
12ExprRangelambda_map: 17
start_index: 49
end_index: 35
13Operationoperator: 18
operands: 19
14Operationoperator: 20
operands: 21
15Lambdaparameter: 60
body: 22
16Lambdaparameter: 60
body: 56
17Lambdaparameter: 60
body: 47
18Literal
19ExprTuple23, 24
20Literal
21ExprTuple25
22IndexedVarvariable: 54
index: 60
23Operationoperator: 26
operands: 27
24Operationoperator: 44
operands: 28
25ExprRangelambda_map: 29
start_index: 49
end_index: 35
26Literal
27ExprTuple30
28ExprTuple31
29Lambdaparameter: 60
body: 32
30ExprRangelambda_map: 33
start_index: 49
end_index: 35
31ExprRangelambda_map: 34
start_index: 49
end_index: 35
32Operationoperator: 36
operands: 37
33Lambdaparameter: 57
body: 38
34Lambdaparameter: 60
body: 39
35Variable
36Literal
37ExprTuple39, 40
38ExprRangelambda_map: 41
start_index: 42
end_index: 43
39Operationoperator: 44
operands: 45
40Literal
41Lambdaparameter: 60
body: 46
42IndexedVarvariable: 58
index: 57
43IndexedVarvariable: 51
index: 57
44Literal
45ExprTuple47, 48, 49
46Operationoperator: 50
operand: 60
47IndexedVarvariable: 51
index: 60
48Operationoperator: 52
operand: 56
49Literal
50IndexedVarvariable: 54
index: 57
51Variable
52Literal
53ExprTuple56
54Variable
55ExprTuple57
56IndexedVarvariable: 58
index: 60
57Variable
58Variable
59ExprTuple60
60Variable