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, n, x
from proveit.core_expr_types import Qk_implies_Pk_a1_to_an, a_1_to_n
from proveit.logic import Forall, InSet, Set
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(n, Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Forall(instance_param_or_params = [P, Q], instance_expr = Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n), condition = Qx), condition = Qk_implies_Pk_a1_to_an)), InSet(n, Natural))))
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(n \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{n}}~\left[\forall_{P, Q~|~\left(Q\left(a_{1}\right) \Rightarrow P\left(a_{1}\right)\right), \left(Q\left(a_{2}\right) \Rightarrow P\left(a_{2}\right)\right), \ldots, \left(Q\left(a_{n}\right) \Rightarrow P\left(a_{n}\right)\right)}~\left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}~|~Q\left(x\right)}~P\left(x\right)\right]\right] \textrm{ if } n \in \mathbb{N}\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
1Lambdaparameter: 48
body: 3
2ExprTuple48
3Conditionalvalue: 4
condition: 5
4Operationoperator: 17
operand: 8
5Operationoperator: 35
operands: 7
6ExprTuple8
7ExprTuple48, 9
8Lambdaparameters: 44
body: 10
9Literal
10Operationoperator: 17
operand: 12
11ExprTuple12
12Lambdaparameters: 13
body: 14
13ExprTuple39, 38
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operand: 20
16Operationoperator: 27
operands: 19
17Literal
18ExprTuple20
19ExprTuple21
20Lambdaparameter: 42
body: 22
21ExprRangelambda_map: 23
start_index: 47
end_index: 48
22Conditionalvalue: 24
condition: 25
23Lambdaparameter: 52
body: 26
24Operationoperator: 39
operand: 42
25Operationoperator: 27
operands: 28
26Operationoperator: 29
operands: 30
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33, 34
31Operationoperator: 35
operands: 36
32Operationoperator: 38
operand: 42
33Operationoperator: 38
operand: 49
34Operationoperator: 39
operand: 49
35Literal
36ExprTuple42, 41
37ExprTuple42
38Variable
39Variable
40ExprTuple49
41Operationoperator: 43
operands: 44
42Variable
43Literal
44ExprTuple45
45ExprRangelambda_map: 46
start_index: 47
end_index: 48
46Lambdaparameter: 52
body: 49
47Literal
48Variable
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable