logo

Expression of type Forall

from the theory of proveit.logic.sets.intersection

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 Q, R, n, x
from proveit.core_expr_types import Q__y_1_to_n, R__y_1_to_n, S_1_to_n, y_1_to_n
from proveit.logic import Equals, Exists, Forall, InSet
from proveit.logic.sets import general_intersectall_Ryn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y_1_to_n]
sub_expr2 = [S_1_to_n]
expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [S_1_to_n, Q, R, x], instance_expr = Equals(InSet(x, general_intersectall_Ryn), Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(x, R__y_1_to_n), domains = sub_expr2, condition = Q__y_1_to_n)).with_wrapping_at(1), condition = Exists(instance_param_or_params = sub_expr1, instance_expr = Q__y_1_to_n, domains = sub_expr2)), domain = NaturalPos)
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_{n \in \mathbb{N}^+}~\left[\forall_{S_{1}, S_{2}, \ldots, S_{n}, Q, R, x~|~\exists_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)}~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left(\begin{array}{c} \begin{array}{l} \left(x \in \left[\bigcap_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~R\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right]\right) \\  = \left[\forall_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)}~\left(x \in R\left(y_{1}, y_{2}, \ldots, y_{n}\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: 25
operand: 2
1ExprTuple2
2Lambdaparameter: 56
body: 4
3ExprTuple56
4Conditionalvalue: 5
condition: 6
5Operationoperator: 25
operand: 9
6Operationoperator: 52
operands: 8
7ExprTuple9
8ExprTuple56, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple13, 48, 44, 40
12Conditionalvalue: 14
condition: 15
13ExprRangelambda_map: 16
start_index: 55
end_index: 56
14Operationoperator: 17
operands: 18
15Operationoperator: 19
operand: 23
16Lambdaparameter: 62
body: 57
17Literal
18ExprTuple21, 22
19Literal
20ExprTuple23
21Operationoperator: 52
operands: 24
22Operationoperator: 25
operand: 29
23Lambdaparameters: 49
body: 27
24ExprTuple40, 28
25Literal
26ExprTuple29
27Conditionalvalue: 46
condition: 30
28Operationoperator: 31
operand: 35
29Lambdaparameters: 49
body: 33
30Operationoperator: 42
operands: 34
31Literal
32ExprTuple35
33Conditionalvalue: 36
condition: 39
34ExprTuple45
35Lambdaparameters: 49
body: 37
36Operationoperator: 52
operands: 38
37Conditionalvalue: 41
condition: 39
38ExprTuple40, 41
39Operationoperator: 42
operands: 43
40Variable
41Operationoperator: 44
operands: 49
42Literal
43ExprTuple45, 46
44Variable
45ExprRangelambda_map: 47
start_index: 55
end_index: 56
46Operationoperator: 48
operands: 49
47Lambdaparameter: 62
body: 50
48Variable
49ExprTuple51
50Operationoperator: 52
operands: 53
51ExprRangelambda_map: 54
start_index: 55
end_index: 56
52Literal
53ExprTuple58, 57
54Lambdaparameter: 62
body: 58
55Literal
56Variable
57IndexedVarvariable: 59
index: 62
58IndexedVarvariable: 60
index: 62
59Variable
60Variable
61ExprTuple62
62Variable