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, 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, InSet, Or, Set
from proveit.numbers import Natural, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
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(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)))), 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(\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] \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: 47
body: 3
2ExprTuple47
3Conditionalvalue: 4
condition: 5
4Operationoperator: 24
operand: 8
5Operationoperator: 38
operands: 7
6ExprTuple8
7ExprTuple47, 9
8Lambdaparameters: 43
body: 10
9Literal
10Operationoperator: 24
operand: 12
11ExprTuple12
12Lambdaparameter: 36
body: 14
13ExprTuple36
14Operationoperator: 28
operands: 15
15ExprTuple16, 17
16Operationoperator: 18
operands: 19
17Operationoperator: 28
operands: 20
18Literal
19ExprTuple21
20ExprTuple22, 32
21ExprRangelambda_map: 23
start_index: 46
end_index: 47
22Operationoperator: 24
operand: 27
23Lambdaparameter: 51
body: 26
24Literal
25ExprTuple27
26Operationoperator: 28
operands: 29
27Lambdaparameter: 40
body: 30
28Literal
29ExprTuple31, 32
30Conditionalvalue: 33
condition: 34
31Operationoperator: 36
operand: 48
32Literal
33Operationoperator: 36
operand: 40
34Operationoperator: 38
operands: 39
35ExprTuple48
36Variable
37ExprTuple40
38Literal
39ExprTuple40, 41
40Variable
41Operationoperator: 42
operands: 43
42Literal
43ExprTuple44
44ExprRangelambda_map: 45
start_index: 46
end_index: 47
45Lambdaparameter: 51
body: 48
46Literal
47Variable
48IndexedVarvariable: 49
index: 51
49Variable
50ExprTuple51
51Variable