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
from proveit.core_expr_types import Len
from proveit.core_expr_types.tuples import f_ik_to_jk__1_to_n, range_len_conditions, range_len_sum
from proveit.logic import And, Equals
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(Len(operands = [f_ik_to_jk__1_to_n]), range_len_sum).with_wrapping_at(1), And(range_len_conditions))
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}{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} \textrm{ if } \left(\left(j_{1} - i_{1} + 1\right) \in \mathbb{N}\right) \land  \left(\left(j_{2} - i_{2} + 1\right) \in \mathbb{N}\right) \land  \ldots \land  \left(\left(j_{n} - i_{n} + 1\right) \in \mathbb{N}\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: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9
7Operationoperator: 10
operands: 11
8Operationoperator: 28
operands: 12
9ExprRangelambda_map: 13
start_index: 33
end_index: 19
10Literal
11ExprTuple14
12ExprTuple15
13Lambdaparameter: 44
body: 16
14ExprRangelambda_map: 17
start_index: 33
end_index: 19
15ExprRangelambda_map: 18
start_index: 33
end_index: 19
16Operationoperator: 20
operands: 21
17Lambdaparameter: 41
body: 22
18Lambdaparameter: 44
body: 23
19Variable
20Literal
21ExprTuple23, 24
22ExprRangelambda_map: 25
start_index: 26
end_index: 27
23Operationoperator: 28
operands: 29
24Literal
25Lambdaparameter: 44
body: 30
26IndexedVarvariable: 42
index: 41
27IndexedVarvariable: 35
index: 41
28Literal
29ExprTuple31, 32, 33
30Operationoperator: 34
operand: 44
31IndexedVarvariable: 35
index: 44
32Operationoperator: 36
operand: 40
33Literal
34IndexedVarvariable: 38
index: 41
35Variable
36Literal
37ExprTuple40
38Variable
39ExprTuple41
40IndexedVarvariable: 42
index: 44
41Variable
42Variable
43ExprTuple44
44Variable