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, i
from proveit.core_expr_types import V_1_to_i, a_1_to_i
from proveit.linear_algebra import TensorProd, VecSpaces
from proveit.logic import Forall, InSet
from proveit.numbers import NaturalPos
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [V_1_to_i]
expr = Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [i], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Forall(instance_param_or_params = [a_1_to_i], instance_expr = InSet(TensorProd(a_1_to_i), TensorProd(V_1_to_i)), domains = sub_expr1), domain = VecSpaces(K)), domain = NaturalPos))
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_{i \in \mathbb{N}^+}~\left[\forall_{V_{1}, V_{2}, \ldots, V_{i} \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{\left(a_{1} \in V_{1}\right), \left(a_{2} \in V_{2}\right), \ldots, \left(a_{i} \in V_{i}\right)}~\left(\left(a_{1} {\otimes}  a_{2} {\otimes}  \ldots {\otimes}  a_{i}\right) \in \left(V_{1} {\otimes}  V_{2} {\otimes}  \ldots {\otimes}  V_{i}\right)\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: 17
operand: 2
1ExprTuple2
2Lambdaparameter: 45
body: 3
3Operationoperator: 17
operand: 5
4ExprTuple5
5Lambdaparameter: 49
body: 7
6ExprTuple49
7Conditionalvalue: 8
condition: 9
8Operationoperator: 17
operand: 12
9Operationoperator: 50
operands: 11
10ExprTuple12
11ExprTuple49, 13
12Lambdaparameters: 38
body: 14
13Literal
14Conditionalvalue: 15
condition: 16
15Operationoperator: 17
operand: 20
16Operationoperator: 28
operands: 19
17Literal
18ExprTuple20
19ExprTuple21
20Lambdaparameters: 36
body: 22
21ExprRangelambda_map: 23
start_index: 48
end_index: 49
22Conditionalvalue: 24
condition: 25
23Lambdaparameter: 57
body: 26
24Operationoperator: 50
operands: 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operands: 31
27ExprTuple32, 33
28Literal
29ExprTuple34
30Literal
31ExprTuple53, 35
32Operationoperator: 37
operands: 36
33Operationoperator: 37
operands: 38
34ExprRangelambda_map: 39
start_index: 48
end_index: 49
35Operationoperator: 40
operand: 45
36ExprTuple42
37Literal
38ExprTuple43
39Lambdaparameter: 57
body: 44
40Literal
41ExprTuple45
42ExprRangelambda_map: 46
start_index: 48
end_index: 49
43ExprRangelambda_map: 47
start_index: 48
end_index: 49
44Operationoperator: 50
operands: 51
45Variable
46Lambdaparameter: 57
body: 52
47Lambdaparameter: 57
body: 53
48Literal
49Variable
50Literal
51ExprTuple52, 53
52IndexedVarvariable: 54
index: 57
53IndexedVarvariable: 55
index: 57
54Variable
55Variable
56ExprTuple57
57Variable