logo

Expression of type Forall

from the theory of proveit.linear_algebra.tensors

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, alpha, b, i, k
from proveit.core_expr_types import U_1_to_i, W_1_to_k, a_1_to_i, c_1_to_k
from proveit.linear_algebra import ScalarMult, TensorProd, VecSpaces
from proveit.logic import Equals, Forall
from proveit.numbers import Natural
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [U_1_to_i, V, W_1_to_k]
expr = Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [alpha], instance_expr = Forall(instance_param_or_params = [i, k], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i, b, c_1_to_k], instance_expr = Equals(TensorProd(a_1_to_i, ScalarMult(alpha, b), c_1_to_k), ScalarMult(alpha, TensorProd(a_1_to_i, b, c_1_to_k))).with_wrapping_at(1), domains = sub_expr1).with_wrapping(), domain = VecSpaces(K)).with_wrapping(), domain = Natural), domain = 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_{\alpha \in K}~\left[\forall_{i, k \in \mathbb{N}}~\left[\begin{array}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V, W_{1}, W_{2}, \ldots, W_{k} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\\
\left[\begin{array}{l}\forall_{\left(a_{1} \in U_{1}\right), \left(a_{2} \in U_{2}\right), \ldots, \left(a_{i} \in U_{i}\right), b \in V,\left(c_{1} \in W_{1}\right), \left(c_{2} \in W_{2}\right), \ldots, \left(c_{k} \in W_{k}\right)}~\\
\left(\begin{array}{c} \begin{array}{l} \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} \left(\alpha \cdot b\right){\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right) \\  = \left(\alpha \cdot \left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i} {\otimes} b{\otimes} c_{1} {\otimes}  c_{2} {\otimes}  \ldots {\otimes}  c_{k}\right)\right) \end{array} \end{array}\right)\end{array}\right]\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: 33
operand: 2
1ExprTuple2
2Lambdaparameter: 73
body: 3
3Operationoperator: 33
operand: 5
4ExprTuple5
5Lambdaparameter: 81
body: 7
6ExprTuple81
7Conditionalvalue: 8
condition: 9
8Operationoperator: 33
operand: 12
9Operationoperator: 79
operands: 11
10ExprTuple12
11ExprTuple81, 73
12Lambdaparameters: 13
body: 14
13ExprTuple88, 91
14Conditionalvalue: 15
condition: 16
15Operationoperator: 33
operand: 19
16Operationoperator: 50
operands: 18
17ExprTuple19
18ExprTuple20, 21
19Lambdaparameters: 22
body: 23
20Operationoperator: 79
operands: 24
21Operationoperator: 79
operands: 25
22ExprTuple26, 71, 27
23Conditionalvalue: 28
condition: 29
24ExprTuple88, 30
25ExprTuple91, 30
26ExprRangelambda_map: 31
start_index: 90
end_index: 88
27ExprRangelambda_map: 32
start_index: 90
end_index: 91
28Operationoperator: 33
operand: 36
29Operationoperator: 50
operands: 35
30Literal
31Lambdaparameter: 99
body: 85
32Lambdaparameter: 99
body: 86
33Literal
34ExprTuple36
35ExprTuple37, 38, 39
36Lambdaparameters: 77
body: 40
37ExprRangelambda_map: 41
start_index: 90
end_index: 88
38Operationoperator: 53
operands: 42
39ExprRangelambda_map: 43
start_index: 90
end_index: 91
40Conditionalvalue: 44
condition: 45
41Lambdaparameter: 99
body: 46
42ExprTuple71, 60
43Lambdaparameter: 99
body: 47
44Operationoperator: 48
operands: 49
45Operationoperator: 50
operands: 51
46Operationoperator: 53
operands: 52
47Operationoperator: 53
operands: 54
48Literal
49ExprTuple55, 56
50Literal
51ExprTuple57, 58, 59
52ExprTuple85, 60
53Literal
54ExprTuple86, 60
55Operationoperator: 76
operands: 61
56Operationoperator: 74
operands: 62
57ExprRangelambda_map: 63
start_index: 90
end_index: 88
58Operationoperator: 79
operands: 64
59ExprRangelambda_map: 65
start_index: 90
end_index: 91
60Operationoperator: 66
operand: 73
61ExprTuple82, 68, 84
62ExprTuple81, 69
63Lambdaparameter: 99
body: 70
64ExprTuple83, 71
65Lambdaparameter: 99
body: 72
66Literal
67ExprTuple73
68Operationoperator: 74
operands: 75
69Operationoperator: 76
operands: 77
70Operationoperator: 79
operands: 78
71Variable
72Operationoperator: 79
operands: 80
73Variable
74Literal
75ExprTuple81, 83
76Literal
77ExprTuple82, 83, 84
78ExprTuple94, 85
79Literal
80ExprTuple95, 86
81Variable
82ExprRangelambda_map: 87
start_index: 90
end_index: 88
83Variable
84ExprRangelambda_map: 89
start_index: 90
end_index: 91
85IndexedVarvariable: 92
index: 99
86IndexedVarvariable: 93
index: 99
87Lambdaparameter: 99
body: 94
88Variable
89Lambdaparameter: 99
body: 95
90Literal
91Variable
92Variable
93Variable
94IndexedVarvariable: 96
index: 99
95IndexedVarvariable: 97
index: 99
96Variable
97Variable
98ExprTuple99
99Variable