logo

Expression of type Forall

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 ExprArray, i, j
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import Forall, NotEquals
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i, j], instance_expr = 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))), domain = Natural, condition = 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())
\forall_{i, j \in \mathbb{N}~|~i \neq j}~\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)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 6
operand: 2
1ExprTuple2
2Lambdaparameters: 19
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple11, 12, 13
10Lambdaparameters: 14
body: 15
11Operationoperator: 17
operands: 16
12Operationoperator: 17
operands: 18
13Operationoperator: 20
operands: 19
14ExprTuple25, 26
15Operationoperator: 20
operands: 21
16ExprTuple28, 22
17Literal
18ExprTuple31, 22
19ExprTuple28, 31
20Literal
21ExprTuple23, 24
22Literal
23ExprTuple25
24ExprTuple26
25ExprRangelambda_map: 27
start_index: 30
end_index: 28
26ExprRangelambda_map: 29
start_index: 30
end_index: 31
27Lambdaparameter: 37
body: 32
28Variable
29Lambdaparameter: 37
body: 33
30Literal
31Variable
32IndexedVarvariable: 34
index: 37
33IndexedVarvariable: 35
index: 37
34Variable
35Variable
36ExprTuple37
37Variable