logo

Expression of type Forall

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 a, b, r
from proveit.logic import Equals, Forall
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 = Forall(instance_param_or_params = [r], instance_expr = 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), domain = 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())
\forall_{r \in \mathbb{R}^{\ge 0}}~\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)\right]
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 51
body: 4
3ExprTuple51
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 27
operands: 9
7Literal
8ExprTuple10
9ExprTuple51, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple61, 68
13Conditionalvalue: 14
condition: 15
14Operationoperator: 16
operands: 17
15Operationoperator: 18
operands: 19
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23
20Operationoperator: 48
operand: 29
21Operationoperator: 63
operands: 25
22Operationoperator: 27
operands: 26
23Operationoperator: 27
operands: 28
24ExprTuple29
25ExprTuple45, 51, 30
26ExprTuple61, 31
27Literal
28ExprTuple68, 31
29Operationoperator: 57
operands: 32
30Operationoperator: 33
operand: 37
31Literal
32ExprTuple35, 36
33Literal
34ExprTuple37
35Operationoperator: 63
operands: 38
36Operationoperator: 65
operand: 43
37Operationoperator: 40
operands: 41
38ExprTuple51, 42
39ExprTuple43
40Literal
41ExprTuple44, 45
42Operationoperator: 55
operands: 46
43Operationoperator: 63
operands: 47
44Operationoperator: 48
operand: 53
45Literal
46ExprTuple59, 50
47ExprTuple51, 52
48Literal
49ExprTuple53
50Operationoperator: 63
operands: 54
51Variable
52Operationoperator: 55
operands: 56
53Operationoperator: 57
operands: 58
54ExprTuple67, 61
55Literal
56ExprTuple59, 60
57Literal
58ExprTuple61, 62
59Literal
60Operationoperator: 63
operands: 64
61Variable
62Operationoperator: 65
operand: 68
63Literal
64ExprTuple67, 68
65Literal
66ExprTuple68
67Literal
68Variable