logo

Expression of type ExprTuple

from the theory of proveit.logic.sets.enumeration

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, ExprTuple, Lambda, P, Px, Q, Qx, x
from proveit.core_expr_types import Qk_implies_Pk_a1_to_an, a_1_to_n
from proveit.logic import And, Forall, Set
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([P, Q], Conditional(Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n), condition = Qx), And(Qk_implies_Pk_a1_to_an))))
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(\left(P, Q\right) \mapsto \left\{\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}~|~Q\left(x\right)}~P\left(x\right) \textrm{ if } \left(Q\left(a_{1}\right) \Rightarrow P\left(a_{1}\right)\right) \land  \left(Q\left(a_{2}\right) \Rightarrow P\left(a_{2}\right)\right) \land  \ldots \land  \left(Q\left(a_{n}\right) \Rightarrow P\left(a_{n}\right)\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 2
body: 3
2ExprTuple28, 27
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 16
operands: 8
6Literal
7ExprTuple9
8ExprTuple10
9Lambdaparameter: 31
body: 11
10ExprRangelambda_map: 12
start_index: 36
end_index: 37
11Conditionalvalue: 13
condition: 14
12Lambdaparameter: 41
body: 15
13Operationoperator: 28
operand: 31
14Operationoperator: 16
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23
20Operationoperator: 24
operands: 25
21Operationoperator: 27
operand: 31
22Operationoperator: 27
operand: 38
23Operationoperator: 28
operand: 38
24Literal
25ExprTuple31, 30
26ExprTuple31
27Variable
28Variable
29ExprTuple38
30Operationoperator: 32
operands: 33
31Variable
32Literal
33ExprTuple34
34ExprRangelambda_map: 35
start_index: 36
end_index: 37
35Lambdaparameter: 41
body: 38
36Literal
37Variable
38IndexedVarvariable: 39
index: 41
39Variable
40ExprTuple41
41Variable