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
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 = [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))
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_{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)
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: 36
operand: 2
1ExprTuple2
2Lambdaparameter: 70
body: 4
3ExprTuple70
4Operationoperator: 5
operands: 6
5Literal
6ExprTuple7, 8
7Operationoperator: 58
operands: 9
8Operationoperator: 34
operands: 10
9ExprTuple70, 11
10ExprTuple12, 13, 14
11Operationoperator: 15
operands: 16
12Operationoperator: 36
operand: 20
13Operationoperator: 36
operand: 21
14Operationoperator: 36
operand: 22
15Literal
16ExprTuple63, 39
17ExprTuple20
18ExprTuple21
19ExprTuple22
20Lambdaparameter: 73
body: 23
21Lambdaparameters: 54
body: 24
22Lambdaparameter: 72
body: 26
23Conditionalvalue: 27
condition: 52
24Conditionalvalue: 28
condition: 29
25ExprTuple72
26Conditionalvalue: 30
condition: 31
27Operationoperator: 58
operands: 32
28Operationoperator: 56
operands: 33
29Operationoperator: 34
operands: 35
30Operationoperator: 36
operand: 43
31Operationoperator: 58
operands: 38
32ExprTuple67, 39
33ExprTuple40, 41
34Literal
35ExprTuple52, 42
36Literal
37ExprTuple43
38ExprTuple72, 44
39Variable
40Operationoperator: 70
operand: 49
41Operationoperator: 53
operands: 46
42Operationoperator: 58
operands: 47
43Lambdaparameter: 73
body: 48
44Variable
45ExprTuple49
46ExprTuple67, 50
47ExprTuple60, 63
48Conditionalvalue: 51
condition: 52
49Operationoperator: 53
operands: 54
50Operationoperator: 70
operand: 60
51Operationoperator: 56
operands: 57
52Operationoperator: 58
operands: 59
53Literal
54ExprTuple73, 60
55ExprTuple60
56Literal
57ExprTuple61, 62
58Literal
59ExprTuple73, 63
60Variable
61Operationoperator: 70
operand: 66
62Operationoperator: 68
operands: 65
63Variable
64ExprTuple66
65ExprTuple72, 67
66Operationoperator: 68
operands: 69
67Operationoperator: 70
operand: 73
68Literal
69ExprTuple72, 73
70Variable
71ExprTuple73
72Variable
73Variable