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, c, f, fx, x
from proveit.logic import And, Equals, InSet
from proveit.numbers import Add, Integer, Interval, Sum, subtract
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, [subtract(x, c)]), domain = Interval(Add(a, c), Add(b, c)))), And(InSet(a, Integer), InSet(b, Integer), InSet(c, 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 = a + c}^{b + c} f\left(x - c\right)\right) \textrm{ if } a \in \mathbb{Z} ,  b \in \mathbb{Z} ,  c \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, 11
7Operationoperator: 13
operand: 18
8Operationoperator: 13
operand: 19
9Operationoperator: 31
operands: 15
10Operationoperator: 31
operands: 16
11Operationoperator: 31
operands: 17
12ExprTuple18
13Literal
14ExprTuple19
15ExprTuple49, 20
16ExprTuple50, 20
17ExprTuple51, 20
18Lambdaparameter: 40
body: 21
19Lambdaparameter: 40
body: 22
20Literal
21Conditionalvalue: 23
condition: 24
22Conditionalvalue: 25
condition: 26
23Operationoperator: 29
operand: 40
24Operationoperator: 31
operands: 28
25Operationoperator: 29
operand: 34
26Operationoperator: 31
operands: 32
27ExprTuple40
28ExprTuple40, 33
29Variable
30ExprTuple34
31Literal
32ExprTuple40, 35
33Operationoperator: 38
operands: 36
34Operationoperator: 47
operands: 37
35Operationoperator: 38
operands: 39
36ExprTuple49, 50
37ExprTuple40, 41
38Literal
39ExprTuple42, 43
40Variable
41Operationoperator: 44
operand: 51
42Operationoperator: 47
operands: 46
43Operationoperator: 47
operands: 48
44Literal
45ExprTuple51
46ExprTuple49, 51
47Literal
48ExprTuple50, 51
49Variable
50Variable
51Variable