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 ExprRange, IndexedVar, Variable, a, c, l
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Complex, Integer, Mult, Sum, one, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = [l]
sub_expr3 = IndexedVar(a, one)
sub_expr4 = Add(l, one)
sub_expr5 = ExprRange(sub_expr1, IndexedVar(c, sub_expr1), one, zero)
expr = Forall(instance_param_or_params = [sub_expr3, sub_expr5], instance_expr = Equals(Mult(sub_expr3, Sum(index_or_indices = sub_expr2, summand = sub_expr4, domain = Integer), sub_expr5), Sum(index_or_indices = sub_expr2, summand = Mult(sub_expr3, sub_expr4, sub_expr5), domain = Integer)).with_wrapping_at(2), domain = Complex).with_wrapping()
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())
\begin{array}{l}\forall_{a_{1}, c_{1}, c_{2}, \ldots, c_{0} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot \left[\sum_{l \in \mathbb{Z}}~\left(l + 1\right)\right]\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right) =  \\ \left[\sum_{l \in \mathbb{Z}}~\left(a_{1} \cdot \left(l + 1\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{0}\right)\right] \end{array} \end{array}\right)\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple35, 37
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15
12Operationoperator: 32
operands: 16
13Operationoperator: 23
operand: 21
14Operationoperator: 38
operands: 18
15ExprRangelambda_map: 19
start_index: 48
end_index: 45
16ExprTuple35, 20, 37
17ExprTuple21
18ExprTuple35, 29
19Lambdaparameter: 52
body: 22
20Operationoperator: 23
operand: 27
21Lambdaparameter: 47
body: 25
22Operationoperator: 38
operands: 26
23Literal
24ExprTuple27
25Conditionalvalue: 28
condition: 34
26ExprTuple49, 29
27Lambdaparameter: 47
body: 31
28Operationoperator: 32
operands: 33
29Literal
30ExprTuple47
31Conditionalvalue: 36
condition: 34
32Literal
33ExprTuple35, 36, 37
34Operationoperator: 38
operands: 39
35IndexedVarvariable: 40
index: 48
36Operationoperator: 42
operands: 43
37ExprRangelambda_map: 44
start_index: 48
end_index: 45
38Literal
39ExprTuple47, 46
40Variable
41ExprTuple48
42Literal
43ExprTuple47, 48
44Lambdaparameter: 52
body: 49
45Literal
46Literal
47Variable
48Literal
49IndexedVarvariable: 50
index: 52
50Variable
51ExprTuple52
52Variable