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 Function, K, P, Px, Py, V, W, c, x, y
from proveit.linear_algebra import LinMap, ScalarMult, VecAdd, VecSpaces
from proveit.logic import And, Equals, Forall, Iff, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
expr = Forall(instance_param_or_params = [V, W], instance_expr = Forall(instance_param_or_params = [P], instance_expr = Iff(InSet(P, LinMap(V, W)), And(Forall(instance_param_or_params = sub_expr1, instance_expr = InSet(Px, W), domain = V), Forall(instance_param_or_params = [x, y], instance_expr = Equals(Function(P, [VecAdd(x, y)]), VecAdd(Px, Py)), domain = V), Forall(instance_param_or_params = [c], instance_expr = Forall(instance_param_or_params = sub_expr1, instance_expr = Equals(Function(P, [ScalarMult(c, x)]), ScalarMult(c, Px)), domain = V), domain = K)).with_wrapping_at(2,4)).with_wrapping_at(2)), 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_{V, W \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)}~\left[\forall_{P}~\left(\begin{array}{c} \begin{array}{l} \left(P \in \mathcal{L}\left(V, W\right)\right) \Leftrightarrow  \\ \left(\begin{array}{c} \left[\forall_{x \in V}~\left(P\left(x\right) \in W\right)\right] \land  \\ \left[\forall_{x, y \in V}~\left(P\left(x + y\right) = \left(P\left(x\right) + P\left(y\right)\right)\right)\right] \land  \\ \left[\forall_{c \in K}~\left[\forall_{x \in V}~\left(P\left(c \cdot x\right) = \left(c \cdot P\left(x\right)\right)\right)\right]\right] \end{array}\right) \end{array} \end{array}\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: 50
operand: 2
1ExprTuple2
2Lambdaparameters: 30
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 50
operand: 8
5Operationoperator: 48
operands: 7
6ExprTuple8
7ExprTuple9, 10
8Lambdaparameter: 84
body: 12
9Operationoperator: 14
operands: 13
10Operationoperator: 14
operands: 15
11ExprTuple84
12Operationoperator: 16
operands: 17
13ExprTuple77, 18
14Literal
15ExprTuple53, 18
16Literal
17ExprTuple19, 20
18Operationoperator: 21
operand: 58
19Operationoperator: 72
operands: 23
20Operationoperator: 48
operands: 24
21Literal
22ExprTuple58
23ExprTuple84, 25
24ExprTuple26, 27, 28
25Operationoperator: 29
operands: 30
26Operationoperator: 50
operand: 34
27Operationoperator: 50
operand: 35
28Operationoperator: 50
operand: 36
29Literal
30ExprTuple77, 53
31ExprTuple34
32ExprTuple35
33ExprTuple36
34Lambdaparameter: 87
body: 37
35Lambdaparameters: 68
body: 38
36Lambdaparameter: 86
body: 40
37Conditionalvalue: 41
condition: 66
38Conditionalvalue: 42
condition: 43
39ExprTuple86
40Conditionalvalue: 44
condition: 45
41Operationoperator: 72
operands: 46
42Operationoperator: 70
operands: 47
43Operationoperator: 48
operands: 49
44Operationoperator: 50
operand: 57
45Operationoperator: 72
operands: 52
46ExprTuple81, 53
47ExprTuple54, 55
48Literal
49ExprTuple66, 56
50Literal
51ExprTuple57
52ExprTuple86, 58
53Variable
54Operationoperator: 84
operand: 63
55Operationoperator: 67
operands: 60
56Operationoperator: 72
operands: 61
57Lambdaparameter: 87
body: 62
58Variable
59ExprTuple63
60ExprTuple81, 64
61ExprTuple74, 77
62Conditionalvalue: 65
condition: 66
63Operationoperator: 67
operands: 68
64Operationoperator: 84
operand: 74
65Operationoperator: 70
operands: 71
66Operationoperator: 72
operands: 73
67Literal
68ExprTuple87, 74
69ExprTuple74
70Literal
71ExprTuple75, 76
72Literal
73ExprTuple87, 77
74Variable
75Operationoperator: 84
operand: 80
76Operationoperator: 82
operands: 79
77Variable
78ExprTuple80
79ExprTuple86, 81
80Operationoperator: 82
operands: 83
81Operationoperator: 84
operand: 87
82Literal
83ExprTuple86, 87
84Variable
85ExprTuple87
86Variable
87Variable