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, Equals, 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 = Equals(And(Pk_a1_to_an), 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}~\left(\left(P\left(a_{1}\right) \land  P\left(a_{2}\right) \land  \ldots \land  P\left(a_{n}\right)\right) = \left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)\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: 42
body: 3
2ExprTuple42
3Conditionalvalue: 4
condition: 5
4Operationoperator: 21
operand: 8
5Operationoperator: 33
operands: 7
6ExprTuple8
7ExprTuple42, 9
8Lambdaparameters: 38
body: 10
9Literal
10Operationoperator: 21
operand: 12
11ExprTuple12
12Lambdaparameter: 31
body: 14
13ExprTuple31
14Operationoperator: 15
operands: 16
15Literal
16ExprTuple17, 18
17Operationoperator: 19
operands: 20
18Operationoperator: 21
operand: 24
19Literal
20ExprTuple23
21Literal
22ExprTuple24
23ExprRangelambda_map: 25
start_index: 41
end_index: 42
24Lambdaparameter: 35
body: 26
25Lambdaparameter: 46
body: 27
26Conditionalvalue: 28
condition: 29
27Operationoperator: 31
operand: 43
28Operationoperator: 31
operand: 35
29Operationoperator: 33
operands: 34
30ExprTuple43
31Variable
32ExprTuple35
33Literal
34ExprTuple35, 36
35Variable
36Operationoperator: 37
operands: 38
37Literal
38ExprTuple39
39ExprRangelambda_map: 40
start_index: 41
end_index: 42
40Lambdaparameter: 46
body: 43
41Literal
42Variable
43IndexedVarvariable: 44
index: 46
44Variable
45ExprTuple46
46Variable