logo

Expression of type Conditional

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, 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 = 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())
\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 23
operands: 5
3Literal
4ExprTuple6
5ExprTuple47, 7
6Lambdaparameters: 8
body: 9
7Literal
8ExprTuple57, 64
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17
14Literal
15ExprTuple18, 19
16Operationoperator: 44
operand: 25
17Operationoperator: 59
operands: 21
18Operationoperator: 23
operands: 22
19Operationoperator: 23
operands: 24
20ExprTuple25
21ExprTuple41, 47, 26
22ExprTuple57, 27
23Literal
24ExprTuple64, 27
25Operationoperator: 53
operands: 28
26Operationoperator: 29
operand: 33
27Literal
28ExprTuple31, 32
29Literal
30ExprTuple33
31Operationoperator: 59
operands: 34
32Operationoperator: 61
operand: 39
33Operationoperator: 36
operands: 37
34ExprTuple47, 38
35ExprTuple39
36Literal
37ExprTuple40, 41
38Operationoperator: 51
operands: 42
39Operationoperator: 59
operands: 43
40Operationoperator: 44
operand: 49
41Literal
42ExprTuple55, 46
43ExprTuple47, 48
44Literal
45ExprTuple49
46Operationoperator: 59
operands: 50
47Variable
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operands: 54
50ExprTuple63, 57
51Literal
52ExprTuple55, 56
53Literal
54ExprTuple57, 58
55Literal
56Operationoperator: 59
operands: 60
57Variable
58Operationoperator: 61
operand: 64
59Literal
60ExprTuple63, 64
61Literal
62ExprTuple64
63Literal
64Variable