logo

Expression of type Forall

from the theory of proveit.linear_algebra.addition

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 K, V, c, i, j, k
from proveit.core_expr_types import a_1_to_i, b_1_to_j, d_1_to_k
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [V], instance_expr = Forall(instance_param_or_params = [i, j, k], instance_expr = Forall(instance_param_or_params = [a_1_to_i, b_1_to_j, c, d_1_to_k], instance_expr = Equals(VecAdd(a_1_to_i, b_1_to_j, c, d_1_to_k), VecAdd(a_1_to_i, c, b_1_to_j, d_1_to_k)).with_wrapping_at(2), domain = V), domain = Natural), domain = VecSpaces(K))
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_{V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{i, j, k \in \mathbb{N}}~\left[\forall_{a_{1}, a_{2}, \ldots, a_{i}, b_{1}, b_{2}, \ldots, b_{j}, c, d_{1}, d_{2}, \ldots, d_{k} \in V}~\left(\begin{array}{c} \begin{array}{l} \left(a_{1} +  a_{2} +  \ldots +  a_{i}+ b_{1} +  b_{2} +  \ldots +  b_{j} + c+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) =  \\ \left(a_{1} +  a_{2} +  \ldots +  a_{i} + c+ b_{1} +  b_{2} +  \ldots +  b_{j}+ d_{1} +  d_{2} +  \ldots +  d_{k}\right) \end{array} \end{array}\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: 19
operand: 2
1ExprTuple2
2Lambdaparameter: 71
body: 4
3ExprTuple71
4Conditionalvalue: 5
condition: 6
5Operationoperator: 19
operand: 10
6Operationoperator: 8
operands: 9
7ExprTuple10
8Literal
9ExprTuple71, 11
10Lambdaparameters: 12
body: 13
11Operationoperator: 14
operand: 18
12ExprTuple58, 60, 63
13Conditionalvalue: 16
condition: 17
14Literal
15ExprTuple18
16Operationoperator: 19
operand: 22
17Operationoperator: 35
operands: 21
18Variable
19Literal
20ExprTuple22
21ExprTuple23, 24, 25
22Lambdaparameters: 43
body: 26
23Operationoperator: 66
operands: 27
24Operationoperator: 66
operands: 28
25Operationoperator: 66
operands: 29
26Conditionalvalue: 30
condition: 31
27ExprTuple58, 32
28ExprTuple60, 32
29ExprTuple63, 32
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Literal
33Literal
34ExprTuple37, 38
35Literal
36ExprTuple39, 40, 41, 42
37Operationoperator: 44
operands: 43
38Operationoperator: 44
operands: 45
39ExprRangelambda_map: 46
start_index: 62
end_index: 58
40ExprRangelambda_map: 47
start_index: 62
end_index: 60
41Operationoperator: 66
operands: 48
42ExprRangelambda_map: 49
start_index: 62
end_index: 63
43ExprTuple50, 51, 55, 52
44Literal
45ExprTuple50, 55, 51, 52
46Lambdaparameter: 76
body: 53
47Lambdaparameter: 76
body: 54
48ExprTuple55, 71
49Lambdaparameter: 76
body: 56
50ExprRangelambda_map: 57
start_index: 62
end_index: 58
51ExprRangelambda_map: 59
start_index: 62
end_index: 60
52ExprRangelambda_map: 61
start_index: 62
end_index: 63
53Operationoperator: 66
operands: 64
54Operationoperator: 66
operands: 65
55Variable
56Operationoperator: 66
operands: 67
57Lambdaparameter: 76
body: 68
58Variable
59Lambdaparameter: 76
body: 69
60Variable
61Lambdaparameter: 76
body: 70
62Literal
63Variable
64ExprTuple68, 71
65ExprTuple69, 71
66Literal
67ExprTuple70, 71
68IndexedVarvariable: 72
index: 76
69IndexedVarvariable: 73
index: 76
70IndexedVarvariable: 74
index: 76
71Variable
72Variable
73Variable
74Variable
75ExprTuple76
76Variable