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 ExprRange, IndexedVar, Variable, b, j
from proveit.core_expr_types import a_1_to_i, b_1_to_j, c_1_to_k
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Complex, Mult, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c_1_to_k], instance_expr = Equals(Mult(a_1_to_i, Add(b_1_to_j), c_1_to_k), Add(ExprRange(sub_expr1, Mult(a_1_to_i, IndexedVar(b, sub_expr1), c_1_to_k), one, j))).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}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, 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(b_{1} +  b_{2} +  \ldots +  b_{j}\right)\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{1}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{2}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\right) +  \ldots +  \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot b_{j}\cdot c_{1} \cdot  c_{2} \cdot  \ldots \cdot  c_{k}\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
4ExprTuple42, 34, 44
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13
10Literal
11ExprTuple14, 15, 16
12Operationoperator: 39
operands: 17
13Operationoperator: 27
operands: 18
14ExprRangelambda_map: 19
start_index: 50
end_index: 46
15ExprRangelambda_map: 20
start_index: 50
end_index: 38
16ExprRangelambda_map: 21
start_index: 50
end_index: 51
17ExprTuple42, 22, 44
18ExprTuple23
19Lambdaparameter: 58
body: 24
20Lambdaparameter: 58
body: 25
21Lambdaparameter: 58
body: 26
22Operationoperator: 27
operands: 28
23ExprRangelambda_map: 29
start_index: 50
end_index: 38
24Operationoperator: 32
operands: 30
25Operationoperator: 32
operands: 31
26Operationoperator: 32
operands: 33
27Literal
28ExprTuple34
29Lambdaparameter: 53
body: 35
30ExprTuple52, 36
31ExprTuple41, 36
32Literal
33ExprTuple54, 36
34ExprRangelambda_map: 37
start_index: 50
end_index: 38
35Operationoperator: 39
operands: 40
36Literal
37Lambdaparameter: 58
body: 41
38Variable
39Literal
40ExprTuple42, 43, 44
41IndexedVarvariable: 47
index: 58
42ExprRangelambda_map: 45
start_index: 50
end_index: 46
43IndexedVarvariable: 47
index: 53
44ExprRangelambda_map: 49
start_index: 50
end_index: 51
45Lambdaparameter: 58
body: 52
46Variable
47Variable
48ExprTuple53
49Lambdaparameter: 58
body: 54
50Literal
51Variable
52IndexedVarvariable: 55
index: 58
53Variable
54IndexedVarvariable: 56
index: 58
55Variable
56Variable
57ExprTuple58
58Variable