logo

Expression of type ExprTuple

from the theory of proveit.numbers.absolute_value

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, r, theta
from proveit.logic import And, Equals, InSet
from proveit.numbers import Abs, Exp, Mult, Real, e, i
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([r, theta], Conditional(Equals(Abs(Mult(r, Exp(e, Mult(i, theta)))), Abs(r)), And(InSet(r, Real), InSet(theta, Real)))))
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(r, \theta\right) \mapsto \left\{\left|r \cdot \mathsf{e}^{\mathsf{i} \cdot \theta}\right| = \left|r\right| \textrm{ if } r \in \mathbb{R} ,  \theta \in \mathbb{R}\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
2ExprTuple23, 32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 15
operand: 20
11Operationoperator: 15
operand: 23
12Operationoperator: 18
operands: 17
13Operationoperator: 18
operands: 19
14ExprTuple20
15Literal
16ExprTuple23
17ExprTuple23, 21
18Literal
19ExprTuple32, 21
20Operationoperator: 29
operands: 22
21Literal
22ExprTuple23, 24
23Variable
24Operationoperator: 25
operands: 26
25Literal
26ExprTuple27, 28
27Literal
28Operationoperator: 29
operands: 30
29Literal
30ExprTuple31, 32
31Literal
32Variable