logo

Expression of type ExprTuple

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, ExprTuple, Lambda, 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 = ExprTuple(Lambda([U, var_ket_psi], 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(\left(U, \lvert \psi \rangle\right) \mapsto \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..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameters: 65
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operands: 6
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9, 62
7Literal
8ExprTuple10, 11
9Operationoperator: 12
operand: 17
10Operationoperator: 15
operands: 14
11Operationoperator: 15
operands: 16
12Literal
13ExprTuple17
14ExprTuple66, 18
15Literal
16ExprTuple67, 19
17Operationoperator: 20
operands: 21
18Operationoperator: 22
operand: 30
19Operationoperator: 24
operands: 25
20Literal
21ExprTuple26, 27, 28
22Literal
23ExprTuple30
24Literal
25ExprTuple29, 30
26ExprTuple31
27ExprTuple32
28ExprTuple33
29Literal
30Operationoperator: 34
operands: 35
31ExprRangelambda_map: 36
start_index: 62
end_index: 63
32ExprRangelambda_map: 37
start_index: 62
end_index: 63
33ExprRangelambda_map: 38
start_index: 62
end_index: 63
34Literal
35ExprTuple39, 63
36Lambdaparameter: 61
body: 40
37Lambdaparameter: 61
body: 41
38Lambdaparameter: 61
body: 43
39Literal
40Operationoperator: 46
operands: 44
41Operationoperator: 46
operands: 45
42ExprTuple61
43Operationoperator: 46
operands: 47
44NamedExprselement: 48
targets: 51
45NamedExprselement: 49
targets: 51
46Literal
47NamedExprselement: 50
targets: 51
48Operationoperator: 52
operands: 53
49Operationoperator: 54
operands: 55
50Operationoperator: 56
operands: 57
51Operationoperator: 58
operands: 59
52Literal
53NamedExprsstate: 67
part: 61
54Literal
55NamedExprsoperation: 66
part: 61
56Literal
57NamedExprsstate: 60
part: 61
58Literal
59ExprTuple62, 63
60Operationoperator: 64
operands: 65
61Variable
62Literal
63Variable
64Literal
65ExprTuple66, 67
66Variable
67Variable