logo

Expression of type Conditional

from the theory of proveit.numbers.summation

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, Function, a, b, f, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Integer, Interval, Neg, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Conditional(Equals(Sum(index_or_indices = sub_expr1, summand = fx, domain = Interval(a, b)), Sum(index_or_indices = sub_expr1, summand = Function(f, [Neg(x)]), domain = Interval(Neg(b), Neg(a)))), And(InSet(a, Integer), InSet(b, Integer)))
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\{\left(\sum_{x = a}^{b} f\left(x\right)\right) = \left(\sum_{x = -b}^{-a} f\left(-x\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z}\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: 12
operand: 16
8Operationoperator: 12
operand: 17
9Operationoperator: 28
operands: 14
10Operationoperator: 28
operands: 15
11ExprTuple16
12Literal
13ExprTuple17
14ExprTuple44, 18
15ExprTuple43, 18
16Lambdaparameter: 37
body: 19
17Lambdaparameter: 37
body: 20
18Literal
19Conditionalvalue: 21
condition: 22
20Conditionalvalue: 23
condition: 24
21Operationoperator: 26
operand: 37
22Operationoperator: 28
operands: 25
23Operationoperator: 26
operand: 31
24Operationoperator: 28
operands: 29
25ExprTuple37, 30
26Variable
27ExprTuple31
28Literal
29ExprTuple37, 32
30Operationoperator: 35
operands: 33
31Operationoperator: 41
operand: 37
32Operationoperator: 35
operands: 36
33ExprTuple44, 43
34ExprTuple37
35Literal
36ExprTuple38, 39
37Variable
38Operationoperator: 41
operand: 43
39Operationoperator: 41
operand: 44
40ExprTuple43
41Literal
42ExprTuple44
43Variable
44Variable