logo

Expression of type ExprTuple

from the theory of proveit.numbers.multiplication

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, n, x
from proveit.core_expr_types import a_1_to_n
from proveit.logic import And, Equals, Forall, InSet, Set
from proveit.numbers import Add, Complex, Mult, Natural
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([n, x], Conditional(Forall(instance_param_or_params = [a_1_to_n], instance_expr = Equals(Add(a_1_to_n), Mult(x, n)), domain = Set(x)), And(InSet(n, Natural), InSet(x, Complex)))))
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(n, x\right) \mapsto \left\{\forall_{a_{1}, a_{2}, \ldots, a_{n} \in \left\{x\right\}}~\left(\left(a_{1} +  a_{2} +  \ldots +  a_{n}\right) = \left(x \cdot n\right)\right) \textrm{ if } n \in \mathbb{N} ,  x \in \mathbb{C}\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
1Lambdaparameters: 2
body: 3
2ExprTuple35, 45
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 27
body: 12
10Operationoperator: 36
operands: 13
11Operationoperator: 36
operands: 14
12Conditionalvalue: 15
condition: 16
13ExprTuple35, 17
14ExprTuple45, 18
15Operationoperator: 19
operands: 20
16Operationoperator: 21
operands: 22
17Literal
18Literal
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operands: 29
25ExprRangelambda_map: 30
start_index: 34
end_index: 35
26Literal
27ExprTuple31
28Literal
29ExprTuple45, 35
30Lambdaparameter: 44
body: 32
31ExprRangelambda_map: 33
start_index: 34
end_index: 35
32Operationoperator: 36
operands: 37
33Lambdaparameter: 44
body: 38
34Literal
35Variable
36Literal
37ExprTuple38, 39
38IndexedVarvariable: 40
index: 44
39Operationoperator: 42
operand: 45
40Variable
41ExprTuple44
42Literal
43ExprTuple45
44Variable
45Variable