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, 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(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(\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), \left[\forall_{x \in \left\{a_{1}, a_{2}, \ldots, a_{n}\right\}}~P\left(x\right)\right] = \bot\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operands: 4
2Operationoperator: 13
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 17
6ExprRangelambda_map: 8
start_index: 31
end_index: 32
7Operationoperator: 9
operand: 12
8Lambdaparameter: 36
body: 11
9Literal
10ExprTuple12
11Operationoperator: 13
operands: 14
12Lambdaparameter: 25
body: 15
13Literal
14ExprTuple16, 17
15Conditionalvalue: 18
condition: 19
16Operationoperator: 21
operand: 33
17Literal
18Operationoperator: 21
operand: 25
19Operationoperator: 23
operands: 24
20ExprTuple33
21Variable
22ExprTuple25
23Literal
24ExprTuple25, 26
25Variable
26Operationoperator: 27
operands: 28
27Literal
28ExprTuple29
29ExprRangelambda_map: 30
start_index: 31
end_index: 32
30Lambdaparameter: 36
body: 33
31Literal
32Variable
33IndexedVarvariable: 34
index: 36
34Variable
35ExprTuple36
36Variable