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 = [K], instance_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_{K}~\left[\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]\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: 22
operand: 2
1ExprTuple2
2Lambdaparameter: 21
body: 3
3Operationoperator: 22
operand: 5
4ExprTuple5
5Lambdaparameter: 74
body: 7
6ExprTuple74
7Conditionalvalue: 8
condition: 9
8Operationoperator: 22
operand: 13
9Operationoperator: 11
operands: 12
10ExprTuple13
11Literal
12ExprTuple74, 14
13Lambdaparameters: 15
body: 16
14Operationoperator: 17
operand: 21
15ExprTuple61, 63, 66
16Conditionalvalue: 19
condition: 20
17Literal
18ExprTuple21
19Operationoperator: 22
operand: 25
20Operationoperator: 38
operands: 24
21Variable
22Literal
23ExprTuple25
24ExprTuple26, 27, 28
25Lambdaparameters: 46
body: 29
26Operationoperator: 69
operands: 30
27Operationoperator: 69
operands: 31
28Operationoperator: 69
operands: 32
29Conditionalvalue: 33
condition: 34
30ExprTuple61, 35
31ExprTuple63, 35
32ExprTuple66, 35
33Operationoperator: 36
operands: 37
34Operationoperator: 38
operands: 39
35Literal
36Literal
37ExprTuple40, 41
38Literal
39ExprTuple42, 43, 44, 45
40Operationoperator: 47
operands: 46
41Operationoperator: 47
operands: 48
42ExprRangelambda_map: 49
start_index: 65
end_index: 61
43ExprRangelambda_map: 50
start_index: 65
end_index: 63
44Operationoperator: 69
operands: 51
45ExprRangelambda_map: 52
start_index: 65
end_index: 66
46ExprTuple53, 54, 58, 55
47Literal
48ExprTuple53, 58, 54, 55
49Lambdaparameter: 79
body: 56
50Lambdaparameter: 79
body: 57
51ExprTuple58, 74
52Lambdaparameter: 79
body: 59
53ExprRangelambda_map: 60
start_index: 65
end_index: 61
54ExprRangelambda_map: 62
start_index: 65
end_index: 63
55ExprRangelambda_map: 64
start_index: 65
end_index: 66
56Operationoperator: 69
operands: 67
57Operationoperator: 69
operands: 68
58Variable
59Operationoperator: 69
operands: 70
60Lambdaparameter: 79
body: 71
61Variable
62Lambdaparameter: 79
body: 72
63Variable
64Lambdaparameter: 79
body: 73
65Literal
66Variable
67ExprTuple71, 74
68ExprTuple72, 74
69Literal
70ExprTuple73, 74
71IndexedVarvariable: 75
index: 79
72IndexedVarvariable: 76
index: 79
73IndexedVarvariable: 77
index: 79
74Variable
75Variable
76Variable
77Variable
78ExprTuple79
79Variable