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 = [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_{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]
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: 7
operand: 2
1ExprTuple2
2Lambdaparameter: 40
body: 4
3ExprTuple40
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operand: 10
6Operationoperator: 31
operands: 9
7Literal
8ExprTuple10
9ExprTuple40, 35
10Lambdaparameters: 30
body: 11
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 19
16Literal
17ExprTuple20
18Operationoperator: 21
operands: 22
19Operationoperator: 36
operands: 23
20ExprRangelambda_map: 24
start_index: 39
end_index: 40
21Literal
22ExprTuple25
23ExprTuple41, 26
24Lambdaparameter: 45
body: 27
25ExprRangelambda_map: 28
start_index: 39
end_index: 40
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operands: 32
28Lambdaparameter: 45
body: 33
29Literal
30ExprTuple34
31Literal
32ExprTuple42, 35
33Operationoperator: 36
operands: 37
34ExprRangelambda_map: 38
start_index: 39
end_index: 40
35Literal
36Literal
37ExprTuple41, 42
38Lambdaparameter: 45
body: 42
39Literal
40Variable
41Variable
42IndexedVarvariable: 43
index: 45
43Variable
44ExprTuple45
45Variable