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
from proveit.core_expr_types import x_1_to_n
from proveit.linear_algebra import VecAdd, VecSpaces
from proveit.logic import Forall, InSet
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 = [x_1_to_n], instance_expr = InSet(VecAdd(x_1_to_n), V), domain = V), 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_{x_{1}, x_{2}, \ldots, x_{n} \in V}~\left(\left(x_{1} +  x_{2} +  \ldots +  x_{n}\right) \in V\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: 10
operand: 2
1ExprTuple2
2Lambdaparameter: 21
body: 3
3Operationoperator: 10
operand: 5
4ExprTuple5
5Lambdaparameter: 38
body: 7
6ExprTuple38
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operand: 14
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14
12Literal
13ExprTuple38, 15
14Lambdaparameters: 28
body: 16
15Operationoperator: 17
operand: 21
16Conditionalvalue: 19
condition: 20
17Literal
18ExprTuple21
19Operationoperator: 35
operands: 22
20Operationoperator: 23
operands: 24
21Variable
22ExprTuple25, 38
23Literal
24ExprTuple26
25Operationoperator: 27
operands: 28
26ExprRangelambda_map: 29
start_index: 33
end_index: 34
27Literal
28ExprTuple30
29Lambdaparameter: 41
body: 31
30ExprRangelambda_map: 32
start_index: 33
end_index: 34
31Operationoperator: 35
operands: 36
32Lambdaparameter: 41
body: 37
33Literal
34Variable
35Literal
36ExprTuple37, 38
37IndexedVarvariable: 39
index: 41
38Variable
39Variable
40ExprTuple41
41Variable