logo

Expression of type Prob

from the theory of proveit.physics.quantum.circuits

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.physics.quantum.circuits import unitary_gate_op
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Prob(unitary_gate_op)
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())
\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{U} & \qout{U \thinspace \lvert \psi \rangle}
} \end{array}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7, 8
6ExprTuple9
7ExprTuple10
8ExprTuple11
9ExprRangelambda_map: 12
start_index: 37
end_index: 38
10ExprRangelambda_map: 13
start_index: 37
end_index: 38
11ExprRangelambda_map: 14
start_index: 37
end_index: 38
12Lambdaparameter: 36
body: 15
13Lambdaparameter: 36
body: 16
14Lambdaparameter: 36
body: 18
15Operationoperator: 21
operands: 19
16Operationoperator: 21
operands: 20
17ExprTuple36
18Operationoperator: 21
operands: 22
19NamedExprselement: 23
targets: 26
20NamedExprselement: 24
targets: 26
21Literal
22NamedExprselement: 25
targets: 26
23Operationoperator: 27
operands: 28
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26Operationoperator: 33
operands: 34
27Literal
28NamedExprsstate: 42
part: 36
29Literal
30NamedExprsoperation: 41
part: 36
31Literal
32NamedExprsstate: 35
part: 36
33Literal
34ExprTuple37, 38
35Operationoperator: 39
operands: 40
36Variable
37Literal
38Variable
39Literal
40ExprTuple41, 42
41Variable
42Variable