logo

Expression of type ExprTuple

from the theory of proveit.numbers.negation

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, IndexedVar, Lambda, Variable, n, x
from proveit.core_expr_types import x_1_to_n
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Add, Complex, NaturalPos, Neg, 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 = [x_1_to_n], instance_expr = Equals(Neg(Add(x_1_to_n)), Add(ExprRange(sub_expr1, Neg(IndexedVar(x, sub_expr1)), one, n))), domain = Complex), InSet(n, NaturalPos))))
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_{x_{1}, x_{2}, \ldots, x_{n} \in \mathbb{C}}~\left(\left(-\left(x_{1} +  x_{2} +  \ldots +  x_{n}\right)\right) = \left(- x_{1} -  x_{2} -  \ldots -  x_{n}\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: 37
body: 3
2ExprTuple37
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 30
operands: 8
6Literal
7ExprTuple9
8ExprTuple37, 10
9Lambdaparameters: 28
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20
18Operationoperator: 38
operand: 24
19Operationoperator: 27
operands: 22
20ExprRangelambda_map: 23
start_index: 36
end_index: 37
21ExprTuple24
22ExprTuple25
23Lambdaparameter: 43
body: 26
24Operationoperator: 27
operands: 28
25ExprRangelambda_map: 29
start_index: 36
end_index: 37
26Operationoperator: 30
operands: 31
27Literal
28ExprTuple32
29Lambdaparameter: 43
body: 33
30Literal
31ExprTuple40, 34
32ExprRangelambda_map: 35
start_index: 36
end_index: 37
33Operationoperator: 38
operand: 40
34Literal
35Lambdaparameter: 43
body: 40
36Literal
37Variable
38Literal
39ExprTuple40
40IndexedVarvariable: 41
index: 43
41Variable
42ExprTuple43
43Variable