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 i, j, x, y
from proveit.core_expr_types import a_1_to_i, b_1_to_j
from proveit.logic import Equals, Forall
from proveit.numbers import Complex, Mult, Natural, subtract
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [i, j], instance_expr = Forall(instance_param_or_params = [a_1_to_i, x, y, b_1_to_j], instance_expr = Equals(Mult(a_1_to_i, subtract(x, y), b_1_to_j), subtract(Mult(a_1_to_i, x, b_1_to_j), Mult(a_1_to_i, y, b_1_to_j))).with_wrapping_at(2), domain = Complex), domain = 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, j \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, x, y, b_{1}, b_{2}, \ldots, b_{j} \in \mathbb{C}}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot \left(x - y\right)\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) =  \\ \left(\left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot x\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right) - \left(a_{1} \cdot  a_{2} \cdot  \ldots \cdot  a_{i} \cdot y\cdot b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\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: 7
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple60, 63
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 22
operands: 9
7Literal
8ExprTuple10
9ExprTuple11, 12
10Lambdaparameters: 13
body: 14
11Operationoperator: 46
operands: 15
12Operationoperator: 46
operands: 16
13ExprTuple56, 49, 57, 58
14Conditionalvalue: 17
condition: 18
15ExprTuple60, 19
16ExprTuple63, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operands: 23
19Literal
20Literal
21ExprTuple24, 25
22Literal
23ExprTuple26, 27, 28, 29
24Operationoperator: 54
operands: 30
25Operationoperator: 41
operands: 31
26ExprRangelambda_map: 32
start_index: 62
end_index: 60
27Operationoperator: 46
operands: 33
28Operationoperator: 46
operands: 34
29ExprRangelambda_map: 35
start_index: 62
end_index: 63
30ExprTuple56, 36, 58
31ExprTuple37, 38
32Lambdaparameter: 69
body: 39
33ExprTuple49, 51
34ExprTuple57, 51
35Lambdaparameter: 69
body: 40
36Operationoperator: 41
operands: 42
37Operationoperator: 54
operands: 43
38Operationoperator: 52
operand: 50
39Operationoperator: 46
operands: 45
40Operationoperator: 46
operands: 47
41Literal
42ExprTuple49, 48
43ExprTuple56, 49, 58
44ExprTuple50
45ExprTuple64, 51
46Literal
47ExprTuple65, 51
48Operationoperator: 52
operand: 57
49Variable
50Operationoperator: 54
operands: 55
51Literal
52Literal
53ExprTuple57
54Literal
55ExprTuple56, 57, 58
56ExprRangelambda_map: 59
start_index: 62
end_index: 60
57Variable
58ExprRangelambda_map: 61
start_index: 62
end_index: 63
59Lambdaparameter: 69
body: 64
60Variable
61Lambdaparameter: 69
body: 65
62Literal
63Variable
64IndexedVarvariable: 66
index: 69
65IndexedVarvariable: 67
index: 69
66Variable
67Variable
68ExprTuple69
69Variable