logo

Expression of type Forall

from the theory of proveit.logic.sets.disjointness

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 B, X, m
from proveit.core_expr_types import A_1_to_m
from proveit.logic import And, Disjoint, Forall, Iff, Set
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [A_1_to_m, B], instance_expr = Iff(Disjoint(A_1_to_m, B), And(Disjoint(A_1_to_m), Forall(instance_param_or_params = [X], instance_expr = Disjoint(X, B), domain = Set(A_1_to_m)))).with_wrapping_at(2)), domain = 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())
\forall_{m \in \mathbb{N}}~\left[\forall_{A_{1}, A_{2}, \ldots, A_{m}, B}~\left(\begin{array}{c} \begin{array}{l} \textrm{disjoint}\left(A_{1}, A_{2}, \ldots, A_{m}, B\right) \Leftrightarrow  \\ \left(\textrm{disjoint}\left(A_{1}, A_{2}, \ldots, A_{m}\right) \land \left[\forall_{X \in \left\{A_{1}, A_{2}, \ldots, A_{m}\right\}}~\textrm{disjoint}\left(X, B\right)\right]\right) \end{array} \end{array}\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: 21
operand: 2
1ExprTuple2
2Lambdaparameter: 40
body: 4
3ExprTuple40
4Conditionalvalue: 5
condition: 6
5Operationoperator: 21
operand: 9
6Operationoperator: 30
operands: 8
7ExprTuple9
8ExprTuple40, 10
9Lambdaparameters: 16
body: 11
10Literal
11Operationoperator: 12
operands: 13
12Literal
13ExprTuple14, 15
14Operationoperator: 28
operands: 16
15Operationoperator: 17
operands: 18
16ExprTuple37, 32
17Literal
18ExprTuple19, 20
19Operationoperator: 28
operands: 36
20Operationoperator: 21
operand: 23
21Literal
22ExprTuple23
23Lambdaparameter: 33
body: 25
24ExprTuple33
25Conditionalvalue: 26
condition: 27
26Operationoperator: 28
operands: 29
27Operationoperator: 30
operands: 31
28Literal
29ExprTuple33, 32
30Literal
31ExprTuple33, 34
32Variable
33Variable
34Operationoperator: 35
operands: 36
35Literal
36ExprTuple37
37ExprRangelambda_map: 38
start_index: 39
end_index: 40
38Lambdaparameter: 44
body: 41
39Literal
40Variable
41IndexedVarvariable: 42
index: 44
42Variable
43ExprTuple44
44Variable