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, i, j, n
from proveit.core_expr_types import Len, f_1_to_n, i_to_j_len
from proveit.core_expr_types.tuples import f_i_to_j__1_to_n
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Mult, Natural, NaturalPos
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [f_1_to_n, i, j], instance_expr = Equals(Len(operands = [f_i_to_j__1_to_n]), Mult(n, i_to_j_len)).with_wrapping_at(1), condition = InSet(i_to_j_len, Natural)), 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\{\forall_{f_{1}, f_{2}, \ldots, f_{n}, i, j~|~\left(j - i + 1\right) \in \mathbb{N}}~\left(\begin{array}{c} \begin{array}{l} |\left(f_{1}\left(i\right), f_{1}\left(i + 1\right), \ldots, f_{1}\left(j\right), f_{2}\left(i\right), f_{2}\left(i + 1\right), \ldots, f_{2}\left(j\right), \ldots\ldots, f_{n}\left(i\right), f_{n}\left(i + 1\right), \ldots, f_{n}\left(j\right)\right)| \\  = \left(n \cdot \left(j - i + 1\right)\right) \end{array} \end{array}\right) \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: 16
operands: 5
3Literal
4ExprTuple6
5ExprTuple29, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple10, 40, 36
9Conditionalvalue: 11
condition: 12
10ExprRangelambda_map: 13
start_index: 34
end_index: 29
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Lambdaparameter: 45
body: 18
14Literal
15ExprTuple19, 20
16Literal
17ExprTuple27, 21
18IndexedVarvariable: 43
index: 45
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operands: 25
21Literal
22Literal
23ExprTuple26
24Literal
25ExprTuple29, 27
26ExprRangelambda_map: 28
start_index: 34
end_index: 29
27Operationoperator: 30
operands: 31
28Lambdaparameter: 46
body: 32
29Variable
30Literal
31ExprTuple36, 33, 34
32ExprRangelambda_map: 35
start_index: 40
end_index: 36
33Operationoperator: 37
operand: 40
34Literal
35Lambdaparameter: 45
body: 39
36Variable
37Literal
38ExprTuple40
39Operationoperator: 41
operand: 45
40Variable
41IndexedVarvariable: 43
index: 46
42ExprTuple45
43Variable
44ExprTuple46
45Variable
46Variable