logo

Expression of type Conditional

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 Conditional, 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, InSet, 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 = Conditional(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)), InSet(n, 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())
\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) \textrm{ if } n \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 15
operand: 5
2Operationoperator: 55
operands: 4
3ExprTuple5
4ExprTuple59, 6
5Lambdaparameters: 7
body: 8
6Literal
7ExprTuple36, 47, 44, 9
8Operationoperator: 10
operands: 11
9ExprRangelambda_map: 12
start_index: 58
end_index: 59
10Literal
11ExprTuple13, 14
12Lambdaparameter: 67
body: 61
13Operationoperator: 15
operand: 19
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19
17Literal
18ExprTuple20, 21
19Lambdaparameters: 45
body: 22
20Operationoperator: 24
operand: 27
21Operationoperator: 24
operand: 28
22Conditionalvalue: 26
condition: 32
23ExprTuple27
24Literal
25ExprTuple28
26Operationoperator: 47
operands: 45
27Lambdaparameters: 45
body: 29
28Lambdaparameters: 48
body: 30
29Conditionalvalue: 31
condition: 32
30Conditionalvalue: 33
condition: 34
31Operationoperator: 36
operands: 45
32Operationoperator: 37
operands: 35
33Operationoperator: 36
operands: 48
34Operationoperator: 37
operands: 38
35ExprTuple39, 40
36Variable
37Literal
38ExprTuple41, 42
39ExprRangelambda_map: 43
start_index: 58
end_index: 59
40Operationoperator: 44
operands: 45
41ExprRangelambda_map: 46
start_index: 58
end_index: 59
42Operationoperator: 47
operands: 48
43Lambdaparameter: 67
body: 49
44Variable
45ExprTuple50
46Lambdaparameter: 67
body: 51
47Variable
48ExprTuple52
49Operationoperator: 55
operands: 53
50ExprRangelambda_map: 54
start_index: 58
end_index: 59
51Operationoperator: 55
operands: 56
52ExprRangelambda_map: 57
start_index: 58
end_index: 59
53ExprTuple60, 61
54Lambdaparameter: 67
body: 60
55Literal
56ExprTuple62, 61
57Lambdaparameter: 67
body: 62
58Literal
59Variable
60IndexedVarvariable: 63
index: 67
61IndexedVarvariable: 64
index: 67
62IndexedVarvariable: 65
index: 67
63Variable
64Variable
65Variable
66ExprTuple67
67Variable