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, i, j, k
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, Natural, NaturalPos, 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 = [i, j, k], instance_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)), domains = [Natural, NaturalPos, Natural])
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_{i \in \mathbb{N}, j \in \mathbb{N}^+, k \in \mathbb{N}}~\left[\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)\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: 25
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple70, 81, 74
4Conditionalvalue: 5
condition: 6
5Operationoperator: 25
operand: 9
6Operationoperator: 38
operands: 8
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 56
operands: 15
11Operationoperator: 56
operands: 16
12Operationoperator: 56
operands: 17
13ExprTuple71, 68
14Operationoperator: 18
operands: 19
15ExprTuple70, 21
16ExprTuple81, 20
17ExprTuple74, 21
18Literal
19ExprTuple22, 23
20Literal
21Literal
22Operationoperator: 25
operand: 27
23Operationoperator: 25
operand: 28
24ExprTuple27
25Literal
26ExprTuple28
27Lambdaparameters: 72
body: 29
28Lambdaparameters: 30
body: 31
29Conditionalvalue: 32
condition: 64
30ExprTuple65, 67
31Conditionalvalue: 33
condition: 34
32Operationoperator: 56
operands: 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35ExprTuple66, 60
36Literal
37ExprTuple40, 41
38Literal
39ExprTuple42, 43
40Operationoperator: 62
operands: 44
41Operationoperator: 52
operand: 49
42ExprRangelambda_map: 46
start_index: 80
end_index: 70
43ExprRangelambda_map: 47
start_index: 80
end_index: 74
44ExprTuple65, 48, 67
45ExprTuple49
46Lambdaparameter: 86
body: 50
47Lambdaparameter: 86
body: 51
48Operationoperator: 52
operand: 58
49Lambdaparameters: 72
body: 54
50Operationoperator: 56
operands: 55
51Operationoperator: 56
operands: 57
52Literal
53ExprTuple58
54Conditionalvalue: 59
condition: 64
55ExprTuple75, 60
56Literal
57ExprTuple77, 60
58Lambdaparameters: 72
body: 61
59Operationoperator: 62
operands: 63
60Literal
61Conditionalvalue: 66
condition: 64
62Literal
63ExprTuple65, 66, 67
64Operationoperator: 68
operands: 72
65ExprRangelambda_map: 69
start_index: 80
end_index: 70
66Operationoperator: 71
operands: 72
67ExprRangelambda_map: 73
start_index: 80
end_index: 74
68Variable
69Lambdaparameter: 86
body: 75
70Variable
71Variable
72ExprTuple76
73Lambdaparameter: 86
body: 77
74Variable
75IndexedVarvariable: 78
index: 86
76ExprRangelambda_map: 79
start_index: 80
end_index: 81
77IndexedVarvariable: 82
index: 86
78Variable
79Lambdaparameter: 86
body: 83
80Literal
81Variable
82Variable
83IndexedVarvariable: 84
index: 86
84Variable
85ExprTuple86
86Variable