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, 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
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [y_1_to_n]
sub_expr2 = [S_1_to_n]
expr = Conditional(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), Exists(instance_param_or_params = sub_expr1, instance_expr = Q__y_1_to_n, domains = sub_expr2))
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\{\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} \textrm{ if } \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)\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: 3
operands: 4
2Operationoperator: 5
operand: 9
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9
7Operationoperator: 38
operands: 10
8Operationoperator: 11
operand: 15
9Lambdaparameters: 35
body: 13
10ExprTuple26, 14
11Literal
12ExprTuple15
13Conditionalvalue: 32
condition: 16
14Operationoperator: 17
operand: 21
15Lambdaparameters: 35
body: 19
16Operationoperator: 28
operands: 20
17Literal
18ExprTuple21
19Conditionalvalue: 22
condition: 25
20ExprTuple31
21Lambdaparameters: 35
body: 23
22Operationoperator: 38
operands: 24
23Conditionalvalue: 27
condition: 25
24ExprTuple26, 27
25Operationoperator: 28
operands: 29
26Variable
27Operationoperator: 30
operands: 35
28Literal
29ExprTuple31, 32
30Variable
31ExprRangelambda_map: 33
start_index: 41
end_index: 42
32Operationoperator: 34
operands: 35
33Lambdaparameter: 48
body: 36
34Variable
35ExprTuple37
36Operationoperator: 38
operands: 39
37ExprRangelambda_map: 40
start_index: 41
end_index: 42
38Literal
39ExprTuple44, 43
40Lambdaparameter: 48
body: 44
41Literal
42Variable
43IndexedVarvariable: 45
index: 48
44IndexedVarvariable: 46
index: 48
45Variable
46Variable
47ExprTuple48
48Variable