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
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
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 = [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))
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_{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)
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: 11
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple32, 43, 40, 5
4Operationoperator: 6
operands: 7
5ExprRangelambda_map: 8
start_index: 54
end_index: 55
6Literal
7ExprTuple9, 10
8Lambdaparameter: 63
body: 57
9Operationoperator: 11
operand: 15
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15
13Literal
14ExprTuple16, 17
15Lambdaparameters: 41
body: 18
16Operationoperator: 20
operand: 23
17Operationoperator: 20
operand: 24
18Conditionalvalue: 22
condition: 28
19ExprTuple23
20Literal
21ExprTuple24
22Operationoperator: 43
operands: 41
23Lambdaparameters: 41
body: 25
24Lambdaparameters: 44
body: 26
25Conditionalvalue: 27
condition: 28
26Conditionalvalue: 29
condition: 30
27Operationoperator: 32
operands: 41
28Operationoperator: 33
operands: 31
29Operationoperator: 32
operands: 44
30Operationoperator: 33
operands: 34
31ExprTuple35, 36
32Variable
33Literal
34ExprTuple37, 38
35ExprRangelambda_map: 39
start_index: 54
end_index: 55
36Operationoperator: 40
operands: 41
37ExprRangelambda_map: 42
start_index: 54
end_index: 55
38Operationoperator: 43
operands: 44
39Lambdaparameter: 63
body: 45
40Variable
41ExprTuple46
42Lambdaparameter: 63
body: 47
43Variable
44ExprTuple48
45Operationoperator: 51
operands: 49
46ExprRangelambda_map: 50
start_index: 54
end_index: 55
47Operationoperator: 51
operands: 52
48ExprRangelambda_map: 53
start_index: 54
end_index: 55
49ExprTuple56, 57
50Lambdaparameter: 63
body: 56
51Literal
52ExprTuple58, 57
53Lambdaparameter: 63
body: 58
54Literal
55Variable
56IndexedVarvariable: 59
index: 63
57IndexedVarvariable: 60
index: 63
58IndexedVarvariable: 61
index: 63
59Variable
60Variable
61Variable
62ExprTuple63
63Variable