logo

Expression of type Lambda

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, Lambda, a, b, r
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Abs, Exp, Mult, Real, RealNonNeg, e, frac, i, subtract, two
from proveit.trigonometry import Sin
In [2]:
# build up the expression from sub-expressions
expr = Lambda(r, Conditional(Forall(instance_param_or_params = [a, b], instance_expr = 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)))), domain = Real), InSet(r, RealNonNeg)))
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())
r \mapsto \left\{\forall_{a, b \in \mathbb{R}}~\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)\right) \textrm{ if } r \in \mathbb{R}^{\ge 0}\right..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 49
body: 2
1ExprTuple49
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 25
operands: 7
5Literal
6ExprTuple8
7ExprTuple49, 9
8Lambdaparameters: 10
body: 11
9Literal
10ExprTuple59, 66
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20, 21
18Operationoperator: 46
operand: 27
19Operationoperator: 61
operands: 23
20Operationoperator: 25
operands: 24
21Operationoperator: 25
operands: 26
22ExprTuple27
23ExprTuple43, 49, 28
24ExprTuple59, 29
25Literal
26ExprTuple66, 29
27Operationoperator: 55
operands: 30
28Operationoperator: 31
operand: 35
29Literal
30ExprTuple33, 34
31Literal
32ExprTuple35
33Operationoperator: 61
operands: 36
34Operationoperator: 63
operand: 41
35Operationoperator: 38
operands: 39
36ExprTuple49, 40
37ExprTuple41
38Literal
39ExprTuple42, 43
40Operationoperator: 53
operands: 44
41Operationoperator: 61
operands: 45
42Operationoperator: 46
operand: 51
43Literal
44ExprTuple57, 48
45ExprTuple49, 50
46Literal
47ExprTuple51
48Operationoperator: 61
operands: 52
49Variable
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operands: 56
52ExprTuple65, 59
53Literal
54ExprTuple57, 58
55Literal
56ExprTuple59, 60
57Literal
58Operationoperator: 61
operands: 62
59Variable
60Operationoperator: 63
operand: 66
61Literal
62ExprTuple65, 66
63Literal
64ExprTuple66
65Literal
66Variable