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 Conditional, ExprTuple, Function, K, Lambda, 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, InClass, InSet
In [2]:
# build up the expression from sub-expressions
sub_expr1 = [x]
sub_expr2 = VecSpaces(K)
expr = ExprTuple(Lambda([V, W], Conditional(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)), And(InClass(V, sub_expr2), InClass(W, sub_expr2)))))
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(\left(V, W\right) \mapsto \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) \textrm{ if } V \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right) ,  W \underset{{\scriptscriptstyle c}}{\in} \textrm{VecSpaces}\left(K\right)\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
1Lambdaparameters: 29
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 49
operand: 7
4Operationoperator: 47
operands: 6
5ExprTuple7
6ExprTuple8, 9
7Lambdaparameter: 83
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple83
11Operationoperator: 15
operands: 16
12ExprTuple76, 17
13Literal
14ExprTuple52, 17
15Literal
16ExprTuple18, 19
17Operationoperator: 20
operand: 57
18Operationoperator: 71
operands: 22
19Operationoperator: 47
operands: 23
20Literal
21ExprTuple57
22ExprTuple83, 24
23ExprTuple25, 26, 27
24Operationoperator: 28
operands: 29
25Operationoperator: 49
operand: 33
26Operationoperator: 49
operand: 34
27Operationoperator: 49
operand: 35
28Literal
29ExprTuple76, 52
30ExprTuple33
31ExprTuple34
32ExprTuple35
33Lambdaparameter: 86
body: 36
34Lambdaparameters: 67
body: 37
35Lambdaparameter: 85
body: 39
36Conditionalvalue: 40
condition: 65
37Conditionalvalue: 41
condition: 42
38ExprTuple85
39Conditionalvalue: 43
condition: 44
40Operationoperator: 71
operands: 45
41Operationoperator: 69
operands: 46
42Operationoperator: 47
operands: 48
43Operationoperator: 49
operand: 56
44Operationoperator: 71
operands: 51
45ExprTuple80, 52
46ExprTuple53, 54
47Literal
48ExprTuple65, 55
49Literal
50ExprTuple56
51ExprTuple85, 57
52Variable
53Operationoperator: 83
operand: 62
54Operationoperator: 66
operands: 59
55Operationoperator: 71
operands: 60
56Lambdaparameter: 86
body: 61
57Variable
58ExprTuple62
59ExprTuple80, 63
60ExprTuple73, 76
61Conditionalvalue: 64
condition: 65
62Operationoperator: 66
operands: 67
63Operationoperator: 83
operand: 73
64Operationoperator: 69
operands: 70
65Operationoperator: 71
operands: 72
66Literal
67ExprTuple86, 73
68ExprTuple73
69Literal
70ExprTuple74, 75
71Literal
72ExprTuple86, 76
73Variable
74Operationoperator: 83
operand: 79
75Operationoperator: 81
operands: 78
76Variable
77ExprTuple79
78ExprTuple85, 80
79Operationoperator: 81
operands: 82
80Operationoperator: 83
operand: 86
81Literal
82ExprTuple85, 86
83Variable
84ExprTuple86
85Variable
86Variable