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 c, d, f, fj, g, gj, j, x
from proveit.logic import Equals, Forall
from proveit.numbers import Complex, Integer, Interval, Mult, Sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [j]
sub_expr2 = Interval(c, d)
expr = Forall(instance_param_or_params = [f, g], instance_expr = Forall(instance_param_or_params = [x], instance_expr = Forall(instance_param_or_params = [c, d], instance_expr = Equals(Sum(index_or_indices = sub_expr1, summand = Mult(Mult(x, gj), fj), domain = sub_expr2), Mult(x, Sum(index_or_indices = sub_expr1, summand = Mult(gj, fj), domain = sub_expr2))), domain = Integer), domain = Complex))
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_{f, g}~\left[\forall_{x \in \mathbb{C}}~\left[\forall_{c, d \in \mathbb{Z}}~\left(\left(\sum_{j = c}^{d} \left(\left(x \cdot g\left(j\right)\right) \cdot f\left(j\right)\right)\right) = \left(x \cdot \left(\sum_{j = c}^{d} \left(g\left(j\right) \cdot f\left(j\right)\right)\right)\right)\right)\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: 11
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple54, 53
4Operationoperator: 11
operand: 6
5ExprTuple6
6Lambdaparameter: 49
body: 8
7ExprTuple49
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 47
operands: 13
11Literal
12ExprTuple14
13ExprTuple49, 15
14Lambdaparameters: 57
body: 16
15Literal
16Conditionalvalue: 17
condition: 18
17Operationoperator: 19
operands: 20
18Operationoperator: 21
operands: 22
19Literal
20ExprTuple23, 24
21Literal
22ExprTuple25, 26
23Operationoperator: 35
operand: 31
24Operationoperator: 45
operands: 28
25Operationoperator: 47
operands: 29
26Operationoperator: 47
operands: 30
27ExprTuple31
28ExprTuple49, 32
29ExprTuple59, 33
30ExprTuple60, 33
31Lambdaparameter: 58
body: 34
32Operationoperator: 35
operand: 38
33Literal
34Conditionalvalue: 37
condition: 43
35Literal
36ExprTuple38
37Operationoperator: 45
operands: 39
38Lambdaparameter: 58
body: 40
39ExprTuple41, 51
40Conditionalvalue: 42
condition: 43
41Operationoperator: 45
operands: 44
42Operationoperator: 45
operands: 46
43Operationoperator: 47
operands: 48
44ExprTuple49, 50
45Literal
46ExprTuple50, 51
47Literal
48ExprTuple58, 52
49Variable
50Operationoperator: 53
operand: 58
51Operationoperator: 54
operand: 58
52Operationoperator: 56
operands: 57
53Variable
54Variable
55ExprTuple58
56Literal
57ExprTuple59, 60
58Variable
59Variable
60Variable