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_qubit
In [2]:
# check that the built expression is the same as the stored expression
assert born_rule_on_qubit.expr == stored_expr
assert born_rule_on_qubit.expr._style_id == stored_expr._style_id
print("Passed sanity check: born_rule_on_qubit matches stored_expr")
Passed sanity check: born_rule_on_qubit matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{\lvert \psi \rangle \in \mathbb{C}^{2}, b \in \left\{0, 1\right\}~|~\left \|\lvert \psi \rangle\right \| = 1}~\left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \meter & \qout{\lvert b \rangle}
} \end{array}\right) = \left|\langle b \rvert \thinspace \lvert \psi \rangle\right|^{2}\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple60, 66
5Conditionalvalue: 6
condition: 7
6Operationoperator: 23
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple13, 14, 15
11Operationoperator: 16
operand: 25
12Operationoperator: 18
operands: 19
13Operationoperator: 21
operands: 20
14Operationoperator: 21
operands: 22
15Operationoperator: 23
operands: 24
16Literal
17ExprTuple25
18Literal
19ExprTuple26, 45
20ExprTuple60, 27
21Literal
22ExprTuple66, 28
23Literal
24ExprTuple29, 47
25Operationoperator: 30
operands: 31
26Operationoperator: 32
operand: 43
27Operationoperator: 34
operands: 35
28Operationoperator: 36
operands: 37
29Operationoperator: 38
operand: 60
30Literal
31ExprTuple40, 41, 42
32Literal
33ExprTuple43
34Literal
35ExprTuple44, 45
36Literal
37ExprTuple46, 47
38Literal
39ExprTuple60
40ExprTuple48
41ExprTuple49
42ExprTuple50
43Operationoperator: 51
operands: 52
44Literal
45Literal
46Literal
47Literal
48Operationoperator: 53
operands: 54
49Operationoperator: 55
operands: 56
50Operationoperator: 57
operands: 58
51Literal
52ExprTuple59, 60
53Literal
54NamedExprsstate: 60
55Literal
56NamedExprsbasis: 61
57Literal
58NamedExprsstate: 62
59Operationoperator: 63
operand: 66
60Variable
61Literal
62Operationoperator: 64
operand: 66
63Literal
64Literal
65ExprTuple66
66Variable