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, x, b_1_to_j, 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}, x,b_{1}, b_{2}, \ldots, b_{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: 23
body: 11
8Operationoperator: 14
operands: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11Operationoperator: 16
operands: 17
12ExprTuple29, 18
13ExprTuple31, 18
14Literal
15ExprTuple34, 18
16Literal
17ExprTuple19, 20
18Literal
19Operationoperator: 22
operands: 21
20Operationoperator: 22
operands: 23
21ExprTuple24, 25, 26, 25, 27
22Literal
23ExprTuple24, 25, 26, 27
24ExprRangelambda_map: 28
start_index: 33
end_index: 29
25Variable
26ExprRangelambda_map: 30
start_index: 33
end_index: 31
27ExprRangelambda_map: 32
start_index: 33
end_index: 34
28Lambdaparameter: 42
body: 35
29Variable
30Lambdaparameter: 42
body: 36
31Variable
32Lambdaparameter: 42
body: 37
33Literal
34Variable
35IndexedVarvariable: 38
index: 42
36IndexedVarvariable: 39
index: 42
37IndexedVarvariable: 40
index: 42
38Variable
39Variable
40Variable
41ExprTuple42
42Variable