logo

Expression of type Forall

from the theory of proveit.numbers.multiplication

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 Function, Q, f
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import Equals, Forall, Implies, InSet
from proveit.numbers import Complex, Mult, Sum
from proveit.numbers.summation import summation_b1toj_fQ
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [b_1_to_j]
sub_expr2 = Function(f, sub_expr1)
sub_expr3 = Function(Q, sub_expr1)
expr = Forall(instance_param_or_params = [f, Q], instance_expr = Implies(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(sub_expr2, Complex), condition = sub_expr3), Forall(instance_param_or_params = [a_1_to_i, c_1_to_k], instance_expr = Equals(Mult(a_1_to_i, summation_b1toj_fQ, c_1_to_k), Sum(index_or_indices = sub_expr1, summand = Mult(a_1_to_i, sub_expr2, c_1_to_k), condition = sub_expr3)).with_wrapping_at(2), domain = Complex).with_wrapping()).with_wrapping_at(2))
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, Q}~\left(\begin{array}{c} \begin{array}{l} \left[\forall_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(f\left(b_{1}, b_{2}, \ldots, b_{j}\right) \in \mathbb{C}\right)\right] \Rightarrow  \\ \left[\begin{array}{l}\forall_{a_{1}, a_{2}, \ldots, a_{i}, c_{1}, c_{2}, \ldots, c_{k} \in \mathbb{C}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right)\right] \end{array} \end{array}\right)\end{array}\right] \end{array} \end{array}\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: 10
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple56, 53
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 10
operand: 12
8Operationoperator: 10
operand: 13
9ExprTuple12
10Literal
11ExprTuple13
12Lambdaparameters: 57
body: 14
13Lambdaparameters: 15
body: 16
14Conditionalvalue: 17
condition: 49
15ExprTuple50, 52
16Conditionalvalue: 18
condition: 19
17Operationoperator: 41
operands: 20
18Operationoperator: 21
operands: 22
19Operationoperator: 23
operands: 24
20ExprTuple51, 45
21Literal
22ExprTuple25, 26
23Literal
24ExprTuple27, 28
25Operationoperator: 47
operands: 29
26Operationoperator: 37
operand: 34
27ExprRangelambda_map: 31
start_index: 65
end_index: 55
28ExprRangelambda_map: 32
start_index: 65
end_index: 59
29ExprTuple50, 33, 52
30ExprTuple34
31Lambdaparameter: 71
body: 35
32Lambdaparameter: 71
body: 36
33Operationoperator: 37
operand: 43
34Lambdaparameters: 57
body: 39
35Operationoperator: 41
operands: 40
36Operationoperator: 41
operands: 42
37Literal
38ExprTuple43
39Conditionalvalue: 44
condition: 49
40ExprTuple60, 45
41Literal
42ExprTuple62, 45
43Lambdaparameters: 57
body: 46
44Operationoperator: 47
operands: 48
45Literal
46Conditionalvalue: 51
condition: 49
47Literal
48ExprTuple50, 51, 52
49Operationoperator: 53
operands: 57
50ExprRangelambda_map: 54
start_index: 65
end_index: 55
51Operationoperator: 56
operands: 57
52ExprRangelambda_map: 58
start_index: 65
end_index: 59
53Variable
54Lambdaparameter: 71
body: 60
55Variable
56Variable
57ExprTuple61
58Lambdaparameter: 71
body: 62
59Variable
60IndexedVarvariable: 63
index: 71
61ExprRangelambda_map: 64
start_index: 65
end_index: 66
62IndexedVarvariable: 67
index: 71
63Variable
64Lambdaparameter: 71
body: 68
65Literal
66Variable
67Variable
68IndexedVarvariable: 69
index: 71
69Variable
70ExprTuple71
71Variable