logo

Expression of type Forall

from the theory of proveit.logic.sets.comprehension

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, f, n
from proveit.core_expr_types import Q__x_1_to_n, R__x_1_to_n, S_1_to_n, f__x_1_to_n, x_1_to_n
from proveit.logic import Forall, Implies, SetOfAll, SubsetEq
from proveit.logic.sets import general_comprehension_fyn
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x_1_to_n]
sub_expr2 = [S_1_to_n]
expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [f, Q, R, S_1_to_n], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = Q__x_1_to_n, domains = sub_expr2, condition = R__x_1_to_n), SubsetEq(SetOfAll(instance_param_or_params = sub_expr1, instance_element = f__x_1_to_n, domains = sub_expr2, condition = R__x_1_to_n), general_comprehension_fyn).with_wrapping_at(2)).with_wrapping_at(2)), 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_{f, Q, R, S_{1}, S_{2}, \ldots, S_{n}}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{\left(x_{1} \in S_{1}\right), \left(x_{2} \in S_{2}\right), \ldots, \left(x_{n} \in S_{n}\right)~|~R\left(x_{1}, x_{2}, \ldots, x_{n}\right)}~Q\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right] \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left\{f\left(x_{1}, x_{2}, \ldots, x_{n}\right)~|~R\left(x_{1}, x_{2}, \ldots, x_{n}\right)\right\}_{\left(x_{1} \in S_{1}\right), \left(x_{2} \in S_{2}\right), \ldots, \left(x_{n} \in S_{n}\right)} \subseteq  \\ \left\{f\left(y_{1}, y_{2}, \ldots, y_{n}\right)~|~Q\left(y_{1}, y_{2}, \ldots, y_{n}\right)\right\}_{\left(y_{1} \in S_{1}\right), \left(y_{2} \in S_{2}\right), \ldots, \left(y_{n} \in S_{n}\right)} \end{array} \end{array}\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: 19
operand: 2
1ExprTuple2
2Lambdaparameter: 63
body: 4
3ExprTuple63
4Conditionalvalue: 5
condition: 6
5Operationoperator: 19
operand: 9
6Operationoperator: 59
operands: 8
7ExprTuple9
8ExprTuple63, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple40, 51, 48, 13
12Operationoperator: 14
operands: 15
13ExprRangelambda_map: 16
start_index: 62
end_index: 63
14Literal
15ExprTuple17, 18
16Lambdaparameter: 71
body: 65
17Operationoperator: 19
operand: 23
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23
21Literal
22ExprTuple24, 25
23Lambdaparameters: 49
body: 26
24Operationoperator: 28
operand: 31
25Operationoperator: 28
operand: 32
26Conditionalvalue: 30
condition: 36
27ExprTuple31
28Literal
29ExprTuple32
30Operationoperator: 51
operands: 49
31Lambdaparameters: 49
body: 33
32Lambdaparameters: 52
body: 34
33Conditionalvalue: 35
condition: 36
34Conditionalvalue: 37
condition: 38
35Operationoperator: 40
operands: 49
36Operationoperator: 41
operands: 39
37Operationoperator: 40
operands: 52
38Operationoperator: 41
operands: 42
39ExprTuple43, 44
40Variable
41Literal
42ExprTuple45, 46
43ExprRangelambda_map: 47
start_index: 62
end_index: 63
44Operationoperator: 48
operands: 49
45ExprRangelambda_map: 50
start_index: 62
end_index: 63
46Operationoperator: 51
operands: 52
47Lambdaparameter: 71
body: 53
48Variable
49ExprTuple54
50Lambdaparameter: 71
body: 55
51Variable
52ExprTuple56
53Operationoperator: 59
operands: 57
54ExprRangelambda_map: 58
start_index: 62
end_index: 63
55Operationoperator: 59
operands: 60
56ExprRangelambda_map: 61
start_index: 62
end_index: 63
57ExprTuple64, 65
58Lambdaparameter: 71
body: 64
59Literal
60ExprTuple66, 65
61Lambdaparameter: 71
body: 66
62Literal
63Variable
64IndexedVarvariable: 67
index: 71
65IndexedVarvariable: 68
index: 71
66IndexedVarvariable: 69
index: 71
67Variable
68Variable
69Variable
70ExprTuple71
71Variable