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
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(Exp(e, Mult(i, a)), Exp(e, Mult(i, b)))), Mult(two, 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|\mathsf{e}^{\mathsf{i} \cdot a} - \mathsf{e}^{\mathsf{i} \cdot b}\right| = \left(2 \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
2ExprTuple49, 53
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operands: 7
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10, 11
8Literal
9ExprTuple12, 13
10Operationoperator: 39
operand: 19
11Operationoperator: 44
operands: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple19
15ExprTuple35, 20
16ExprTuple49, 21
17Literal
18ExprTuple53, 21
19Operationoperator: 46
operands: 22
20Operationoperator: 23
operand: 27
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27
25Operationoperator: 37
operands: 28
26Operationoperator: 51
operand: 33
27Operationoperator: 30
operands: 31
28ExprTuple41, 32
29ExprTuple33
30Literal
31ExprTuple34, 35
32Operationoperator: 44
operands: 36
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operand: 43
35Literal
36ExprTuple48, 49
37Literal
38ExprTuple41, 42
39Literal
40ExprTuple43
41Literal
42Operationoperator: 44
operands: 45
43Operationoperator: 46
operands: 47
44Literal
45ExprTuple48, 53
46Literal
47ExprTuple49, 50
48Literal
49Variable
50Operationoperator: 51
operand: 53
51Literal
52ExprTuple53
53Variable