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 ExprRange, ExprTuple, Function, IndexedVar, Lambda, P, Px, Variable, a, n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import Equals, FALSE, Forall, Or, Set
from proveit.numbers import one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Lambda(P, Equals(Or(ExprRange(sub_expr1, Equals(Function(P, [IndexedVar(a, sub_expr1)]), FALSE), one, n)), Equals(Forall(instance_param_or_params = [x], instance_expr = Px, domain = Set(a_1_to_n)), FALSE))))
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(P \mapsto \left(\left(\left(P\left(a_{1}\right) = \bot\right) \lor  \left(P\left(a_{2}\right) = \bot\right) \lor  \ldots \lor  \left(P\left(a_{n}\right) = \bot\right)\right) = \left(\left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)\right] = \bot\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
1Lambdaparameter: 25
body: 3
2ExprTuple25
3Operationoperator: 17
operands: 4
4ExprTuple5, 6
5Operationoperator: 7
operands: 8
6Operationoperator: 17
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 21
10ExprRangelambda_map: 12
start_index: 35
end_index: 36
11Operationoperator: 13
operand: 16
12Lambdaparameter: 40
body: 15
13Literal
14ExprTuple16
15Operationoperator: 17
operands: 18
16Lambdaparameter: 29
body: 19
17Literal
18ExprTuple20, 21
19Conditionalvalue: 22
condition: 23
20Operationoperator: 25
operand: 37
21Literal
22Operationoperator: 25
operand: 29
23Operationoperator: 27
operands: 28
24ExprTuple37
25Variable
26ExprTuple29
27Literal
28ExprTuple29, 30
29Variable
30Operationoperator: 31
operands: 32
31Literal
32ExprTuple33
33ExprRangelambda_map: 34
start_index: 35
end_index: 36
34Lambdaparameter: 40
body: 37
35Literal
36Variable
37IndexedVarvariable: 38
index: 40
38Variable
39ExprTuple40
40Variable