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 ExprRange, IndexedVar, K, Variable, m, n
from proveit.core_expr_types import n_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import CartExp, Forall, SubsetEq
from proveit.numbers import Mult, NaturalPos, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Forall(instance_param_or_params = [K], instance_expr = Forall(instance_param_or_params = [m], instance_expr = Forall(instance_param_or_params = [n_1_to_m], instance_expr = SubsetEq(TensorProd(ExprRange(sub_expr1, CartExp(K, IndexedVar(n, sub_expr1)), one, m)), CartExp(K, Mult(n_1_to_m))), domain = NaturalPos), 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_{m \in \mathbb{N}^+}~\left[\forall_{n_{1}, n_{2}, \ldots, n_{m} \in \mathbb{N}^+}~\left(\left(K^{n_{1}} {\otimes}  K^{n_{2}} {\otimes}  \ldots {\otimes}  K^{n_{m}}\right) \subseteq K^{n_{1} \cdot  n_{2} \cdot  \ldots \cdot  n_{m}}\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: 11
operand: 2
1ExprTuple2
2Lambdaparameter: 45
body: 4
3ExprTuple45
4Operationoperator: 11
operand: 6
5ExprTuple6
6Lambdaparameter: 44
body: 8
7ExprTuple44
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operand: 14
10Operationoperator: 35
operands: 13
11Literal
12ExprTuple14
13ExprTuple44, 39
14Lambdaparameters: 34
body: 15
15Conditionalvalue: 16
condition: 17
16Operationoperator: 18
operands: 19
17Operationoperator: 20
operands: 21
18Literal
19ExprTuple22, 23
20Literal
21ExprTuple24
22Operationoperator: 25
operands: 26
23Operationoperator: 40
operands: 27
24ExprRangelambda_map: 28
start_index: 43
end_index: 44
25Literal
26ExprTuple29
27ExprTuple45, 30
28Lambdaparameter: 49
body: 31
29ExprRangelambda_map: 32
start_index: 43
end_index: 44
30Operationoperator: 33
operands: 34
31Operationoperator: 35
operands: 36
32Lambdaparameter: 49
body: 37
33Literal
34ExprTuple38
35Literal
36ExprTuple46, 39
37Operationoperator: 40
operands: 41
38ExprRangelambda_map: 42
start_index: 43
end_index: 44
39Literal
40Literal
41ExprTuple45, 46
42Lambdaparameter: 49
body: 46
43Literal
44Variable
45Variable
46IndexedVarvariable: 47
index: 49
47Variable
48ExprTuple49
49Variable