logo

Expression of type Forall

from the theory of proveit.linear_algebra.linear_maps

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 Conditional, K, Lambda, P, Px, V, W, c, x
from proveit.linear_algebra import LinMap, ScalarMult, VecSpaces
from proveit.logic import Equals, 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, W], instance_expr = Forall(instance_param_or_params = [c], instance_expr = Forall(instance_param_or_params = [P], instance_expr = Equals(ScalarMult(c, P), Lambda(x, Conditional(ScalarMult(c, Px), InSet(x, V)))), domain = LinMap(V, W)), domain = K), 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, W \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{c \in K}~\left[\forall_{P \in \mathcal{L}\left(V, W\right)}~\left(\left(c \cdot P\right) = \left[x \mapsto \left\{c \cdot P\left(x\right) \textrm{ if } x \in V\right..\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: 23
operand: 2
1ExprTuple2
2Lambdaparameter: 29
body: 3
3Operationoperator: 23
operand: 5
4ExprTuple5
5Lambdaparameters: 43
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 23
operand: 12
8Operationoperator: 10
operands: 11
9ExprTuple12
10Literal
11ExprTuple13, 14
12Lambdaparameter: 51
body: 16
13Operationoperator: 18
operands: 17
14Operationoperator: 18
operands: 19
15ExprTuple51
16Conditionalvalue: 20
condition: 21
17ExprTuple53, 22
18Literal
19ExprTuple46, 22
20Operationoperator: 23
operand: 28
21Operationoperator: 49
operands: 25
22Operationoperator: 26
operand: 29
23Literal
24ExprTuple28
25ExprTuple51, 29
26Literal
27ExprTuple29
28Lambdaparameter: 54
body: 31
29Variable
30ExprTuple54
31Conditionalvalue: 32
condition: 33
32Operationoperator: 34
operands: 35
33Operationoperator: 49
operands: 36
34Literal
35ExprTuple37, 38
36ExprTuple54, 39
37Operationoperator: 47
operands: 40
38Lambdaparameter: 56
body: 41
39Operationoperator: 42
operands: 43
40ExprTuple51, 54
41Conditionalvalue: 44
condition: 45
42Literal
43ExprTuple53, 46
44Operationoperator: 47
operands: 48
45Operationoperator: 49
operands: 50
46Variable
47Literal
48ExprTuple51, 52
49Literal
50ExprTuple56, 53
51Variable
52Operationoperator: 54
operand: 56
53Variable
54Variable
55ExprTuple56
56Variable