logo

Expression of type Conditional

from the theory of proveit.logic.sets.enumeration

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, x
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import And, Equals, Forall, InSet, Set
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, x, b_1_to_j, c_1_to_k], instance_expr = Equals(Set(a_1_to_i, x, b_1_to_j, x, c_1_to_k), Set(a_1_to_i, b_1_to_j, x, c_1_to_k)).with_wrapping_at(2)), 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}, x, b_{1}, b_{2}, \ldots, b_{j}, c_{1}, c_{2}, \ldots, c_{k}}~\left(\begin{array}{c} \begin{array}{l} \left\{a_{1}, a_{2}, \ldots, a_{i}, x,b_{1}, b_{2}, \ldots, b_{j}, x,c_{1}, c_{2}, \ldots, c_{k}\right\} =  \\ \left\{a_{1}, a_{2}, \ldots, a_{i},b_{1}, b_{2}, \ldots, b_{j}, x,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
11ExprTuple25, 27, 26, 28
12Operationoperator: 17
operands: 18
13ExprTuple30, 19
14ExprTuple32, 19
15Literal
16ExprTuple35, 19
17Literal
18ExprTuple20, 21
19Literal
20Operationoperator: 23
operands: 22
21Operationoperator: 23
operands: 24
22ExprTuple25, 27, 26, 27, 28
23Literal
24ExprTuple25, 26, 27, 28
25ExprRangelambda_map: 29
start_index: 34
end_index: 30
26ExprRangelambda_map: 31
start_index: 34
end_index: 32
27Variable
28ExprRangelambda_map: 33
start_index: 34
end_index: 35
29Lambdaparameter: 43
body: 36
30Variable
31Lambdaparameter: 43
body: 37
32Variable
33Lambdaparameter: 43
body: 38
34Literal
35Variable
36IndexedVarvariable: 39
index: 43
37IndexedVarvariable: 40
index: 43
38IndexedVarvariable: 41
index: 43
39Variable
40Variable
41Variable
42ExprTuple43
43Variable