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 = [K], instance_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_{K}~\left[\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]\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: 53
operand: 2
1ExprTuple2
2Lambdaparameter: 61
body: 3
3Operationoperator: 53
operand: 5
4ExprTuple5
5Lambdaparameters: 33
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 53
operand: 11
8Operationoperator: 51
operands: 10
9ExprTuple11
10ExprTuple12, 13
11Lambdaparameter: 87
body: 15
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple87
15Operationoperator: 19
operands: 20
16ExprTuple80, 21
17Literal
18ExprTuple56, 21
19Literal
20ExprTuple22, 23
21Operationoperator: 24
operand: 61
22Operationoperator: 75
operands: 26
23Operationoperator: 51
operands: 27
24Literal
25ExprTuple61
26ExprTuple87, 28
27ExprTuple29, 30, 31
28Operationoperator: 32
operands: 33
29Operationoperator: 53
operand: 37
30Operationoperator: 53
operand: 38
31Operationoperator: 53
operand: 39
32Literal
33ExprTuple80, 56
34ExprTuple37
35ExprTuple38
36ExprTuple39
37Lambdaparameter: 90
body: 40
38Lambdaparameters: 71
body: 41
39Lambdaparameter: 89
body: 43
40Conditionalvalue: 44
condition: 69
41Conditionalvalue: 45
condition: 46
42ExprTuple89
43Conditionalvalue: 47
condition: 48
44Operationoperator: 75
operands: 49
45Operationoperator: 73
operands: 50
46Operationoperator: 51
operands: 52
47Operationoperator: 53
operand: 60
48Operationoperator: 75
operands: 55
49ExprTuple84, 56
50ExprTuple57, 58
51Literal
52ExprTuple69, 59
53Literal
54ExprTuple60
55ExprTuple89, 61
56Variable
57Operationoperator: 87
operand: 66
58Operationoperator: 70
operands: 63
59Operationoperator: 75
operands: 64
60Lambdaparameter: 90
body: 65
61Variable
62ExprTuple66
63ExprTuple84, 67
64ExprTuple77, 80
65Conditionalvalue: 68
condition: 69
66Operationoperator: 70
operands: 71
67Operationoperator: 87
operand: 77
68Operationoperator: 73
operands: 74
69Operationoperator: 75
operands: 76
70Literal
71ExprTuple90, 77
72ExprTuple77
73Literal
74ExprTuple78, 79
75Literal
76ExprTuple90, 80
77Variable
78Operationoperator: 87
operand: 83
79Operationoperator: 85
operands: 82
80Variable
81ExprTuple83
82ExprTuple89, 84
83Operationoperator: 85
operands: 86
84Operationoperator: 87
operand: 90
85Literal
86ExprTuple89, 90
87Variable
88ExprTuple90
89Variable
90Variable