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