logo

Expression of type Conditional

from the theory of proveit.core_expr_types.expr_arrays

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, ExprArray, i, j
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import And, Forall, InSet, NotEquals
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], instance_expr = NotEquals(ExprArray(a_1_to_i), ExprArray(b_1_to_j))), And(InSet(i, Natural), InSet(j, Natural), NotEquals(i, j)))
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}}~\left(\left(\begin{array}{c} 
 \multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & a_{1} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & a_{2} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & \vdots & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & a_{i} & \rightarrow \end{array}} \\
\end{array}
\right) \neq \left(\begin{array}{c} 
 \multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b_{1} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b_{2} & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & \vdots & \rightarrow \end{array}} \\
\multicolumn{1}{c}{\begin{array}{lcr} \leftarrow & b_{j} & \rightarrow \end{array}} \\
\end{array}
\right)\right) \textrm{ if } i \in \mathbb{N} ,  j \in \mathbb{N} ,  i \neq j\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
11ExprTuple22, 23
12Operationoperator: 17
operands: 18
13ExprTuple25, 19
14Literal
15ExprTuple28, 19
16ExprTuple25, 28
17Literal
18ExprTuple20, 21
19Literal
20ExprTuple22
21ExprTuple23
22ExprRangelambda_map: 24
start_index: 27
end_index: 25
23ExprRangelambda_map: 26
start_index: 27
end_index: 28
24Lambdaparameter: 34
body: 29
25Variable
26Lambdaparameter: 34
body: 30
27Literal
28Variable
29IndexedVarvariable: 31
index: 34
30IndexedVarvariable: 32
index: 34
31Variable
32Variable
33ExprTuple34
34Variable