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, i, j, k, x
from proveit.logic import And, Equals, Forall, InSet, NotEquals
from proveit.numbers import Add, Complex, Exp, Integer, Interval, LessEq, Sum, frac, one, subtract
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [j, k], instance_expr = Equals(Sum(index_or_indices = [i], summand = Exp(x, i), domain = Interval(j, k)), frac(subtract(Exp(x, j), Exp(x, Add(k, one))), subtract(one, x))), domain = Integer, condition = LessEq(j, k)), And(InSet(x, Complex), NotEquals(x, one)))
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\{\forall_{j, k \in \mathbb{Z}~|~j \leq k}~\left(\left(\sum_{i = j}^{k} x^{i}\right) = \frac{x^{j} - x^{k + 1}}{1 - x}\right) \textrm{ if } x \in \mathbb{C} ,  x \neq 1\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
operand: 6
2Operationoperator: 18
operands: 5
3Literal
4ExprTuple6
5ExprTuple7, 8
6Lambdaparameters: 56
body: 9
7Operationoperator: 46
operands: 10
8Operationoperator: 11
operands: 12
9Conditionalvalue: 13
condition: 14
10ExprTuple60, 15
11Literal
12ExprTuple60, 65
13Operationoperator: 16
operands: 17
14Operationoperator: 18
operands: 19
15Literal
16Literal
17ExprTuple20, 21
18Literal
19ExprTuple22, 23, 24
20Operationoperator: 25
operand: 32
21Operationoperator: 27
operands: 28
22Operationoperator: 46
operands: 29
23Operationoperator: 46
operands: 30
24Operationoperator: 31
operands: 56
25Literal
26ExprTuple32
27Literal
28ExprTuple33, 34
29ExprTuple59, 35
30ExprTuple64, 35
31Literal
32Lambdaparameter: 52
body: 37
33Operationoperator: 62
operands: 38
34Operationoperator: 62
operands: 39
35Literal
36ExprTuple52
37Conditionalvalue: 40
condition: 41
38ExprTuple42, 43
39ExprTuple65, 44
40Operationoperator: 57
operands: 45
41Operationoperator: 46
operands: 47
42Operationoperator: 57
operands: 48
43Operationoperator: 50
operand: 54
44Operationoperator: 50
operand: 60
45ExprTuple60, 52
46Literal
47ExprTuple52, 53
48ExprTuple60, 59
49ExprTuple54
50Literal
51ExprTuple60
52Variable
53Operationoperator: 55
operands: 56
54Operationoperator: 57
operands: 58
55Literal
56ExprTuple59, 64
57Literal
58ExprTuple60, 61
59Variable
60Variable
61Operationoperator: 62
operands: 63
62Literal
63ExprTuple64, 65
64Variable
65Literal