logo

Expression of type ExprTuple

from the theory of proveit.trigonometry

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, a, b, r
from proveit.logic import And, Equals, InSet
from proveit.numbers import Abs, Exp, Mult, Real, e, frac, i, subtract, two
from proveit.trigonometry import Sin
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([a, b], Conditional(Equals(Abs(subtract(Mult(r, Exp(e, Mult(i, a))), Mult(r, Exp(e, Mult(i, b))))), Mult(two, r, Sin(frac(Abs(subtract(a, b)), two)))), And(InSet(a, Real), InSet(b, 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(a, b\right) \mapsto \left\{\left|\left(r \cdot \mathsf{e}^{\mathsf{i} \cdot a}\right) - \left(r \cdot \mathsf{e}^{\mathsf{i} \cdot b}\right)\right| = \left(2 \cdot r \cdot \sin{\frac{\left|a - b\right|}{2}}\right) \textrm{ if } a \in \mathbb{R} ,  b \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
2ExprTuple51, 58
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 38
operand: 19
11Operationoperator: 53
operands: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19
15ExprTuple35, 41, 20
16ExprTuple51, 21
17Literal
18ExprTuple58, 21
19Operationoperator: 47
operands: 22
20Operationoperator: 23
operand: 27
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27
25Operationoperator: 53
operands: 28
26Operationoperator: 55
operand: 33
27Operationoperator: 30
operands: 31
28ExprTuple41, 32
29ExprTuple33
30Literal
31ExprTuple34, 35
32Operationoperator: 45
operands: 36
33Operationoperator: 53
operands: 37
34Operationoperator: 38
operand: 43
35Literal
36ExprTuple49, 40
37ExprTuple41, 42
38Literal
39ExprTuple43
40Operationoperator: 53
operands: 44
41Variable
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 48
44ExprTuple57, 51
45Literal
46ExprTuple49, 50
47Literal
48ExprTuple51, 52
49Literal
50Operationoperator: 53
operands: 54
51Variable
52Operationoperator: 55
operand: 58
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple58
57Literal
58Variable