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, f, i, j, m, n
from proveit.core_expr_types import Len
from proveit.core_expr_types.tuples import general_range_of_ranges
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Add, Natural, one, zero
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [f, i, j], instance_expr = Equals(Len(operands = general_range_of_ranges), zero).with_wrapping_at(1)), And(InSet(m, Natural), InSet(n, Natural), Equals(Add(n, one), m)))
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, i, j}~\left(\begin{array}{c} \begin{array}{l} |\left(f\left(m, i\left(m\right)\right), f\left(m, i\left(m\right) + 1\right), \ldots, f\left(m, j\left(m\right)\right), f\left(m + 1, i\left(m + 1\right)\right), f\left(m + 1, i\left(m + 1\right) + 1\right), \ldots, f\left(m + 1, j\left(m + 1\right)\right), \ldots\ldots, f\left(n, i\left(n\right)\right), f\left(n, i\left(n\right) + 1\right), \ldots, f\left(n, j\left(n\right)\right)\right)| \\  = 0 \end{array} \end{array}\right) \textrm{ if } m \in \mathbb{N} ,  n \in \mathbb{N} ,  \left(n + 1\right) = m\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9, 10
7Lambdaparameters: 11
body: 12
8Operationoperator: 14
operands: 13
9Operationoperator: 14
operands: 15
10Operationoperator: 17
operands: 16
11ExprTuple41, 38, 39
12Operationoperator: 17
operands: 18
13ExprTuple30, 19
14Literal
15ExprTuple31, 19
16ExprTuple20, 30
17Literal
18ExprTuple21, 22
19Literal
20Operationoperator: 23
operands: 24
21Operationoperator: 25
operands: 26
22Literal
23Literal
24ExprTuple31, 27
25Literal
26ExprTuple28
27Literal
28ExprRangelambda_map: 29
start_index: 30
end_index: 31
29Lambdaparameter: 43
body: 32
30Variable
31Variable
32ExprRangelambda_map: 33
start_index: 34
end_index: 35
33Lambdaparameter: 44
body: 37
34Operationoperator: 38
operand: 43
35Operationoperator: 39
operand: 43
36ExprTuple44
37Operationoperator: 41
operands: 42
38Variable
39Variable
40ExprTuple43
41Variable
42ExprTuple43, 44
43Variable
44Variable