logo

Expression of type Forall

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 i, j, k, x
from proveit.logic import Equals, Forall, 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 = Forall(instance_param_or_params = [x], instance_expr = 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)), domain = Complex, condition = 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())
\forall_{x \in \mathbb{C}~|~x \neq 1}~\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)\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: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 63
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 21
operands: 8
6Literal
7ExprTuple9
8ExprTuple10, 11
9Lambdaparameters: 59
body: 12
10Operationoperator: 49
operands: 13
11Operationoperator: 14
operands: 15
12Conditionalvalue: 16
condition: 17
13ExprTuple63, 18
14Literal
15ExprTuple63, 68
16Operationoperator: 19
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26, 27
23Operationoperator: 28
operand: 35
24Operationoperator: 30
operands: 31
25Operationoperator: 49
operands: 32
26Operationoperator: 49
operands: 33
27Operationoperator: 34
operands: 59
28Literal
29ExprTuple35
30Literal
31ExprTuple36, 37
32ExprTuple62, 38
33ExprTuple67, 38
34Literal
35Lambdaparameter: 55
body: 40
36Operationoperator: 65
operands: 41
37Operationoperator: 65
operands: 42
38Literal
39ExprTuple55
40Conditionalvalue: 43
condition: 44
41ExprTuple45, 46
42ExprTuple68, 47
43Operationoperator: 60
operands: 48
44Operationoperator: 49
operands: 50
45Operationoperator: 60
operands: 51
46Operationoperator: 53
operand: 57
47Operationoperator: 53
operand: 63
48ExprTuple63, 55
49Literal
50ExprTuple55, 56
51ExprTuple63, 62
52ExprTuple57
53Literal
54ExprTuple63
55Variable
56Operationoperator: 58
operands: 59
57Operationoperator: 60
operands: 61
58Literal
59ExprTuple62, 67
60Literal
61ExprTuple63, 64
62Variable
63Variable
64Operationoperator: 65
operands: 66
65Literal
66ExprTuple67, 68
67Variable
68Literal