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, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k, d_1_to_j
from proveit.logic import And, Equals, Forall, InSet
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k, d_1_to_j], instance_expr = Equals([a_1_to_i, b_1_to_j, c_1_to_k], [a_1_to_i, d_1_to_j, c_1_to_k]).with_wrapping_at(2), condition = Equals([b_1_to_j], [d_1_to_j])), And(InSet(i, Natural), InSet(j, Natural), InSet(k, Natural)))
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_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}, d_{1}, d_{2}, \ldots, d_{j}~|~\left(b_{1}, b_{2}, \ldots, b_{j}\right) = \left(d_{1}, d_{2}, \ldots, d_{j}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1}, a_{2}, \ldots, a_{i},b_{1}, b_{2}, \ldots, b_{j},c_{1}, c_{2}, \ldots, c_{k}\right) =  \\ \left(a_{1}, a_{2}, \ldots, a_{i},d_{1}, d_{2}, \ldots, d_{j},c_{1}, c_{2}, \ldots, c_{k}\right) \end{array} \end{array}\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  k \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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9, 10
7Lambdaparameters: 11
body: 12
8Operationoperator: 15
operands: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11ExprTuple27, 29, 28, 30
12Conditionalvalue: 17
condition: 18
13ExprTuple32, 19
14ExprTuple38, 19
15Literal
16ExprTuple34, 19
17Operationoperator: 21
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26
23ExprTuple27, 29, 28
24ExprTuple27, 30, 28
25ExprTuple29
26ExprTuple30
27ExprRangelambda_map: 31
start_index: 37
end_index: 32
28ExprRangelambda_map: 33
start_index: 37
end_index: 34
29ExprRangelambda_map: 35
start_index: 37
end_index: 38
30ExprRangelambda_map: 36
start_index: 37
end_index: 38
31Lambdaparameter: 48
body: 39
32Variable
33Lambdaparameter: 48
body: 40
34Variable
35Lambdaparameter: 48
body: 41
36Lambdaparameter: 48
body: 42
37Literal
38Variable
39IndexedVarvariable: 43
index: 48
40IndexedVarvariable: 44
index: 48
41IndexedVarvariable: 45
index: 48
42IndexedVarvariable: 46
index: 48
43Variable
44Variable
45Variable
46Variable
47ExprTuple48
48Variable