logo

Expression of type Forall

from the theory of proveit.numbers.division

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 Px, d, x, y, z
from proveit.logic import Equals, Forall, NotEquals
from proveit.numbers import Complex, Interval, Sum, frac, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = Interval(y, z)
expr = Forall(instance_param_or_params = [d], instance_expr = Equals(frac(Sum(index_or_indices = sub_expr1, summand = Px, domain = sub_expr2), d), Sum(index_or_indices = sub_expr1, summand = frac(Px, d), domain = sub_expr2)), domain = Complex, condition = NotEquals(d, zero))
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_{d \in \mathbb{C}~|~d \neq 0}~\left(\frac{\sum_{x = y}^{z} P\left(x\right)}{d} = \left(\sum_{x = y}^{z} \frac{P\left(x\right)}{d}\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 35
body: 5
4ExprTuple35
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 31
operands: 16
13Operationoperator: 25
operand: 22
14Operationoperator: 36
operands: 18
15Operationoperator: 19
operands: 20
16ExprTuple21, 35
17ExprTuple22
18ExprTuple35, 23
19Literal
20ExprTuple35, 24
21Operationoperator: 25
operand: 28
22Lambdaparameter: 41
body: 27
23Literal
24Literal
25Literal
26ExprTuple28
27Conditionalvalue: 29
condition: 33
28Lambdaparameter: 41
body: 30
29Operationoperator: 31
operands: 32
30Conditionalvalue: 34
condition: 33
31Literal
32ExprTuple34, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operand: 41
35Variable
36Literal
37ExprTuple41, 40
38Variable
39ExprTuple41
40Operationoperator: 42
operands: 43
41Variable
42Literal
43ExprTuple44, 45
44Variable
45Variable