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.circuits import born_rule_on_register
In [2]:
# check that the built expression is the same as the stored expression
assert born_rule_on_register.expr == stored_expr
assert born_rule_on_register.expr._style_id == stored_expr._style_id
print("Passed sanity check: born_rule_on_register matches stored_expr")
Passed sanity check: born_rule_on_register matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{m \in \mathbb{N}^+}~\left[\forall_{n \in \{0~\ldotp \ldotp~2^{m} - 1\}}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{2^{m}}~|~\left \|\lvert \psi \rangle\right \| = 1}~\left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\multiqin{3}{\lvert \psi \rangle} & \meter & \multiqout{3}{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \measure{\begin{array}{c}:\\ \left(m - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}}
} \end{array}\right) = \left|{_{m}}\langle n \rvert \thinspace \lvert \psi \rangle\right|^{2}\right)\right]\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: 15
operand: 2
1ExprTuple2
2Lambdaparameter: 102
body: 4
3ExprTuple102
4Conditionalvalue: 5
condition: 6
5Operationoperator: 15
operand: 9
6Operationoperator: 39
operands: 8
7ExprTuple9
8ExprTuple102, 10
9Lambdaparameter: 101
body: 12
10Literal
11ExprTuple101
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operand: 18
14Operationoperator: 39
operands: 17
15Literal
16ExprTuple18
17ExprTuple101, 19
18Lambdaparameter: 95
body: 20
19Operationoperator: 93
operands: 21
20Conditionalvalue: 22
condition: 23
21ExprTuple24, 25
22Operationoperator: 41
operands: 26
23Operationoperator: 27
operands: 28
24Literal
25Operationoperator: 29
operands: 30
26ExprTuple31, 32
27Literal
28ExprTuple33, 34
29Literal
30ExprTuple62, 35
31Operationoperator: 36
operand: 45
32Operationoperator: 68
operands: 38
33Operationoperator: 39
operands: 40
34Operationoperator: 41
operands: 42
35Operationoperator: 43
operand: 98
36Literal
37ExprTuple45
38ExprTuple46, 74
39Literal
40ExprTuple95, 47
41Literal
42ExprTuple48, 98
43Literal
44ExprTuple98
45Operationoperator: 49
operands: 50
46Operationoperator: 51
operand: 60
47Operationoperator: 53
operands: 54
48Operationoperator: 55
operand: 95
49Literal
50ExprTuple57, 58, 59
51Literal
52ExprTuple60
53Literal
54ExprTuple61, 62
55Literal
56ExprTuple95
57ExprTuple63
58ExprTuple64
59ExprTuple65
60Operationoperator: 66
operands: 67
61Literal
62Operationoperator: 68
operands: 69
63ExprRangelambda_map: 70
start_index: 98
end_index: 102
64ExprRangelambda_map: 71
start_index: 98
end_index: 102
65ExprRangelambda_map: 72
start_index: 98
end_index: 102
66Literal
67ExprTuple73, 95
68Literal
69ExprTuple74, 102
70Lambdaparameter: 97
body: 75
71Lambdaparameter: 97
body: 76
72Lambdaparameter: 97
body: 78
73Operationoperator: 79
operands: 100
74Literal
75Operationoperator: 83
operands: 80
76Operationoperator: 81
operands: 82
77ExprTuple97
78Operationoperator: 83
operands: 84
79Literal
80NamedExprselement: 85
targets: 88
81Literal
82NamedExprsbasis: 86
83Literal
84NamedExprselement: 87
targets: 88
85Operationoperator: 89
operands: 90
86Literal
87Operationoperator: 91
operands: 92
88Operationoperator: 93
operands: 94
89Literal
90NamedExprsstate: 95
part: 97
91Literal
92NamedExprsstate: 96
part: 97
93Literal
94ExprTuple98, 102
95Variable
96Operationoperator: 99
operands: 100
97Variable
98Literal
99Literal
100ExprTuple101, 102
101Variable
102Variable