logo

Expression of type ExprTuple

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 ExprTuple, Function, K, Lambda, 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 = ExprTuple(Lambda(P, 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())
\left(P \mapsto \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()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 69
body: 3
2ExprTuple69
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 57
operands: 8
7Operationoperator: 33
operands: 9
8ExprTuple69, 10
9ExprTuple11, 12, 13
10Operationoperator: 14
operands: 15
11Operationoperator: 35
operand: 19
12Operationoperator: 35
operand: 20
13Operationoperator: 35
operand: 21
14Literal
15ExprTuple62, 38
16ExprTuple19
17ExprTuple20
18ExprTuple21
19Lambdaparameter: 72
body: 22
20Lambdaparameters: 53
body: 23
21Lambdaparameter: 71
body: 25
22Conditionalvalue: 26
condition: 51
23Conditionalvalue: 27
condition: 28
24ExprTuple71
25Conditionalvalue: 29
condition: 30
26Operationoperator: 57
operands: 31
27Operationoperator: 55
operands: 32
28Operationoperator: 33
operands: 34
29Operationoperator: 35
operand: 42
30Operationoperator: 57
operands: 37
31ExprTuple66, 38
32ExprTuple39, 40
33Literal
34ExprTuple51, 41
35Literal
36ExprTuple42
37ExprTuple71, 43
38Variable
39Operationoperator: 69
operand: 48
40Operationoperator: 52
operands: 45
41Operationoperator: 57
operands: 46
42Lambdaparameter: 72
body: 47
43Variable
44ExprTuple48
45ExprTuple66, 49
46ExprTuple59, 62
47Conditionalvalue: 50
condition: 51
48Operationoperator: 52
operands: 53
49Operationoperator: 69
operand: 59
50Operationoperator: 55
operands: 56
51Operationoperator: 57
operands: 58
52Literal
53ExprTuple72, 59
54ExprTuple59
55Literal
56ExprTuple60, 61
57Literal
58ExprTuple72, 62
59Variable
60Operationoperator: 69
operand: 65
61Operationoperator: 67
operands: 64
62Variable
63ExprTuple65
64ExprTuple71, 66
65Operationoperator: 67
operands: 68
66Operationoperator: 69
operand: 72
67Literal
68ExprTuple71, 72
69Variable
70ExprTuple72
71Variable
72Variable