logo

Expression of type Conditional

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 Conditional, 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 = Conditional(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)), 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_{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) \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: 21
operand: 5
2Operationoperator: 48
operands: 4
3ExprTuple5
4ExprTuple52, 6
5Lambdaparameters: 7
body: 8
6Literal
7ExprTuple9, 44, 40, 36
8Conditionalvalue: 10
condition: 11
9ExprRangelambda_map: 12
start_index: 51
end_index: 52
10Operationoperator: 13
operands: 14
11Operationoperator: 15
operand: 19
12Lambdaparameter: 58
body: 53
13Literal
14ExprTuple17, 18
15Literal
16ExprTuple19
17Operationoperator: 48
operands: 20
18Operationoperator: 21
operand: 25
19Lambdaparameters: 45
body: 23
20ExprTuple36, 24
21Literal
22ExprTuple25
23Conditionalvalue: 42
condition: 26
24Operationoperator: 27
operand: 31
25Lambdaparameters: 45
body: 29
26Operationoperator: 38
operands: 30
27Literal
28ExprTuple31
29Conditionalvalue: 32
condition: 35
30ExprTuple41
31Lambdaparameters: 45
body: 33
32Operationoperator: 48
operands: 34
33Conditionalvalue: 37
condition: 35
34ExprTuple36, 37
35Operationoperator: 38
operands: 39
36Variable
37Operationoperator: 40
operands: 45
38Literal
39ExprTuple41, 42
40Variable
41ExprRangelambda_map: 43
start_index: 51
end_index: 52
42Operationoperator: 44
operands: 45
43Lambdaparameter: 58
body: 46
44Variable
45ExprTuple47
46Operationoperator: 48
operands: 49
47ExprRangelambda_map: 50
start_index: 51
end_index: 52
48Literal
49ExprTuple54, 53
50Lambdaparameter: 58
body: 54
51Literal
52Variable
53IndexedVarvariable: 55
index: 58
54IndexedVarvariable: 56
index: 58
55Variable
56Variable
57ExprTuple58
58Variable