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, n, x
from proveit.core_expr_types import Pk_a1_to_an, a_1_to_n
from proveit.logic import And, 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], instance_expr = And(Pk_a1_to_an), condition = Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n)))), 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~|~\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)}~\left(P\left(a_{1}\right) \land  P\left(a_{2}\right) \land  \ldots \land  P\left(a_{n}\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: 40
body: 3
2ExprTuple40
3Conditionalvalue: 4
condition: 5
4Operationoperator: 19
operand: 8
5Operationoperator: 31
operands: 7
6ExprTuple8
7ExprTuple40, 9
8Lambdaparameters: 36
body: 10
9Literal
10Operationoperator: 19
operand: 12
11ExprTuple12
12Lambdaparameter: 29
body: 14
13ExprTuple29
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operands: 18
16Operationoperator: 19
operand: 22
17Literal
18ExprTuple21
19Literal
20ExprTuple22
21ExprRangelambda_map: 23
start_index: 39
end_index: 40
22Lambdaparameter: 33
body: 24
23Lambdaparameter: 44
body: 25
24Conditionalvalue: 26
condition: 27
25Operationoperator: 29
operand: 41
26Operationoperator: 29
operand: 33
27Operationoperator: 31
operands: 32
28ExprTuple41
29Variable
30ExprTuple33
31Literal
32ExprTuple33, 34
33Variable
34Operationoperator: 35
operands: 36
35Literal
36ExprTuple37
37ExprRangelambda_map: 38
start_index: 39
end_index: 40
38Lambdaparameter: 44
body: 41
39Literal
40Variable
41IndexedVarvariable: 42
index: 44
42Variable
43ExprTuple44
44Variable