logo

Expression of type Conditional

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 Conditional, Px, d, x, y, z
from proveit.logic import And, Equals, InSet, 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 = Conditional(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)), And(InSet(d, Complex), 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())
\left\{\frac{\sum_{x = y}^{z} P\left(x\right)}{d} = \left(\sum_{x = y}^{z} \frac{P\left(x\right)}{d}\right) \textrm{ if } d \in \mathbb{C} ,  d \neq 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
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 8
5Literal
6ExprTuple9, 10
7Operationoperator: 26
operands: 11
8Operationoperator: 20
operand: 17
9Operationoperator: 31
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple16, 30
12ExprTuple17
13ExprTuple30, 18
14Literal
15ExprTuple30, 19
16Operationoperator: 20
operand: 23
17Lambdaparameter: 36
body: 22
18Literal
19Literal
20Literal
21ExprTuple23
22Conditionalvalue: 24
condition: 28
23Lambdaparameter: 36
body: 25
24Operationoperator: 26
operands: 27
25Conditionalvalue: 29
condition: 28
26Literal
27ExprTuple29, 30
28Operationoperator: 31
operands: 32
29Operationoperator: 33
operand: 36
30Variable
31Literal
32ExprTuple36, 35
33Variable
34ExprTuple36
35Operationoperator: 37
operands: 38
36Variable
37Literal
38ExprTuple39, 40
39Variable
40Variable