logo
In [1]:
import proveit
# Automation is not needed when only building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_theorem_expr # Load the stored theorem expression as 'stored_expr'
# import the special expression
from proveit.physics.quantum.algebra import operator_function
In [2]:
# check that the built expression is the same as the stored expression
assert operator_function.expr == stored_expr
assert operator_function.expr._style_id == stored_expr._style_id
print("Passed sanity check: operator_function matches stored_expr")
Passed sanity check: operator_function matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{n \in \mathbb{N}^+}~\left[\begin{array}{l}\forall_{\mathcal{H} \underset{{\scriptscriptstyle c}}{\in} \textrm{HilbertSpaces}~|~\textrm{Dim}\left(\mathcal{H}\right) = n}~\\
\left[\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathcal{H}\right)}~\\
\left[\forall_{a_{1}, a_{2}, \ldots, a_{n} \in \mathbb{C}}~\left[\forall_{f \in \left[\mathbb{C} \rightarrow \mathbb{C}\right]}~\left(f\left(\sum_{i=1}^{n} \left(a_{i} \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right) = \left(\sum_{i=1}^{n} \left(f\left(a_{i}\right) \cdot \left(\lvert v_{i} \rangle \thinspace \langle v_{i} \rvert\right)\right)\right)\right)\right]\right]\end{array}\right]\end{array}\right]
In [4]:
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 [5]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 47
operand: 2
1ExprTuple2
2Lambdaparameter: 110
body: 4
3ExprTuple110
4Conditionalvalue: 5
condition: 6
5Operationoperator: 47
operand: 9
6Operationoperator: 95
operands: 8
7ExprTuple9
8ExprTuple110, 10
9Lambdaparameter: 45
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 47
operand: 16
13Operationoperator: 49
operands: 15
14ExprTuple16
15ExprTuple17, 18
16Lambdaparameters: 19
body: 20
17Operationoperator: 21
operands: 22
18Operationoperator: 64
operands: 23
19ExprTuple24
20Conditionalvalue: 25
condition: 26
21Literal
22ExprTuple45, 27
23ExprTuple28, 110
24ExprRangelambda_map: 29
start_index: 109
end_index: 110
25Operationoperator: 47
operand: 33
26Operationoperator: 95
operands: 31
27Literal
28Operationoperator: 32
operand: 45
29Lambdaparameter: 82
body: 73
30ExprTuple33
31ExprTuple34, 35
32Literal
33Lambdaparameters: 36
body: 37
34Operationoperator: 51
operand: 44
35Operationoperator: 39
operand: 45
36ExprTuple41
37Conditionalvalue: 42
condition: 43
38ExprTuple44
39Literal
40ExprTuple45
41ExprRangelambda_map: 46
start_index: 109
end_index: 110
42Operationoperator: 47
operand: 53
43Operationoperator: 49
operands: 50
44Operationoperator: 51
operands: 52
45Variable
46Lambdaparameter: 82
body: 72
47Literal
48ExprTuple53
49Literal
50ExprTuple54
51Literal
52ExprTuple55
53Lambdaparameter: 97
body: 57
54ExprRangelambda_map: 58
start_index: 109
end_index: 110
55ExprRangelambda_map: 59
start_index: 109
end_index: 110
56ExprTuple97
57Conditionalvalue: 60
condition: 61
58Lambdaparameter: 82
body: 62
59Lambdaparameter: 82
body: 63
60Operationoperator: 64
operands: 65
61Operationoperator: 95
operands: 66
62Operationoperator: 95
operands: 67
63Operationoperator: 111
operand: 73
64Literal
65ExprTuple69, 70
66ExprTuple97, 71
67ExprTuple72, 81
68ExprTuple73
69Operationoperator: 97
operand: 79
70Operationoperator: 83
operand: 80
71Operationoperator: 76
operands: 77
72IndexedVarvariable: 106
index: 82
73IndexedVarvariable: 115
index: 82
74ExprTuple79
75ExprTuple80
76Literal
77ExprTuple81, 81
78ExprTuple82
79Operationoperator: 83
operand: 86
80Lambdaparameter: 117
body: 85
81Literal
82Variable
83Literal
84ExprTuple86
85Conditionalvalue: 87
condition: 91
86Lambdaparameter: 117
body: 88
87Operationoperator: 93
operands: 89
88Conditionalvalue: 90
condition: 91
89ExprTuple92, 99
90Operationoperator: 93
operands: 94
91Operationoperator: 95
operands: 96
92Operationoperator: 97
operand: 101
93Literal
94ExprTuple101, 99
95Literal
96ExprTuple117, 100
97Variable
98ExprTuple101
99Operationoperator: 102
operands: 103
100Operationoperator: 104
operands: 105
101IndexedVarvariable: 106
index: 117
102Literal
103ExprTuple107, 108
104Literal
105ExprTuple109, 110
106Variable
107Operationoperator: 111
operand: 114
108Operationoperator: 112
operand: 114
109Literal
110Variable
111Literal
112Literal
113ExprTuple114
114IndexedVarvariable: 115
index: 117
115Variable
116ExprTuple117
117Variable