logo

Expression of type Conditional

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 import Conditional, U, m
from proveit.linear_algebra import Unitary
from proveit.logic import And, Equals, InSet
from proveit.numbers import Exp, one, two
from proveit.physics.quantum import m_ket_domain, var_ket_psi
from proveit.physics.quantum.circuits import unitary_gate_op
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Equals(Prob(unitary_gate_op), one), And(InSet(U, Unitary(Exp(two, m))), InSet(var_ket_psi, m_ket_domain)))
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\{\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) = 1 \textrm{ if } U \in \textrm{U}\left(2^{m}\right) ,  \lvert \psi \rangle \in \mathbb{C}^{2^{m}}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operands: 4
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7, 60
5Literal
6ExprTuple8, 9
7Operationoperator: 10
operand: 15
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10Literal
11ExprTuple15
12ExprTuple64, 16
13Literal
14ExprTuple65, 17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operand: 28
17Operationoperator: 22
operands: 23
18Literal
19ExprTuple24, 25, 26
20Literal
21ExprTuple28
22Literal
23ExprTuple27, 28
24ExprTuple29
25ExprTuple30
26ExprTuple31
27Literal
28Operationoperator: 32
operands: 33
29ExprRangelambda_map: 34
start_index: 60
end_index: 61
30ExprRangelambda_map: 35
start_index: 60
end_index: 61
31ExprRangelambda_map: 36
start_index: 60
end_index: 61
32Literal
33ExprTuple37, 61
34Lambdaparameter: 59
body: 38
35Lambdaparameter: 59
body: 39
36Lambdaparameter: 59
body: 41
37Literal
38Operationoperator: 44
operands: 42
39Operationoperator: 44
operands: 43
40ExprTuple59
41Operationoperator: 44
operands: 45
42NamedExprselement: 46
targets: 49
43NamedExprselement: 47
targets: 49
44Literal
45NamedExprselement: 48
targets: 49
46Operationoperator: 50
operands: 51
47Operationoperator: 52
operands: 53
48Operationoperator: 54
operands: 55
49Operationoperator: 56
operands: 57
50Literal
51NamedExprsstate: 65
part: 59
52Literal
53NamedExprsoperation: 64
part: 59
54Literal
55NamedExprsstate: 58
part: 59
56Literal
57ExprTuple60, 61
58Operationoperator: 62
operands: 63
59Variable
60Literal
61Variable
62Literal
63ExprTuple64, 65
64Variable
65Variable