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, b
from proveit.logic import And, Bijections, InSet, Set, SetOfAll
from proveit.numbers import one, zero
from proveit.physics.quantum import QubitSpace, normalized_var_ket_psi, var_ket_psi
from proveit.physics.quantum.circuits import qubit_meas
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Set(zero, one)
expr = ExprTuple(Lambda(var_ket_psi, Conditional(InSet(Lambda(b, qubit_meas), Bijections(sub_expr1, SetOfAll(instance_param_or_params = [b], instance_element = qubit_meas, domain = sub_expr1))).with_wrapping_at(2), And(InSet(var_ket_psi, QubitSpace), normalized_var_ket_psi))))
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(\lvert \psi \rangle \mapsto \left\{\begin{array}{c} \begin{array}{l} \left[b \mapsto \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \meter & \qout{\lvert b \rangle}
} \end{array}\right)\right] \in  \\ \left[\left\{0, 1\right\} \xrightarrow[\text{onto}]{\text{1-to-1}} \left\{\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \meter & \qout{\lvert b \rangle}
} \end{array}\right\}_{b \in \left\{0, 1\right\}}\right] \end{array} \end{array} \textrm{ if } \lvert \psi \rangle \in \mathbb{C}^{2} ,  \left \|\lvert \psi \rangle\right \| = 1\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
1Lambdaparameter: 53
body: 2
2Conditionalvalue: 3
condition: 4
3Operationoperator: 34
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 9
6Literal
7ExprTuple10, 11
8Lambdaparameter: 58
body: 30
9Operationoperator: 12
operands: 13
10Operationoperator: 34
operands: 14
11Operationoperator: 15
operands: 16
12Literal
13ExprTuple39, 17
14ExprTuple53, 18
15Literal
16ExprTuple19, 52
17Operationoperator: 20
operand: 26
18Operationoperator: 22
operands: 23
19Operationoperator: 24
operand: 53
20Literal
21ExprTuple26
22Literal
23ExprTuple27, 28
24Literal
25ExprTuple53
26Lambdaparameter: 58
body: 29
27Literal
28Literal
29Conditionalvalue: 30
condition: 31
30Operationoperator: 32
operands: 33
31Operationoperator: 34
operands: 35
32Literal
33ExprTuple36, 37, 38
34Literal
35ExprTuple58, 39
36ExprTuple40
37ExprTuple41
38ExprTuple42
39Operationoperator: 43
operands: 44
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operands: 48
42Operationoperator: 49
operands: 50
43Literal
44ExprTuple51, 52
45Literal
46NamedExprsstate: 53
47Literal
48NamedExprsbasis: 54
49Literal
50NamedExprsstate: 55
51Literal
52Literal
53Variable
54Literal
55Operationoperator: 56
operand: 58
56Literal
57ExprTuple58
58Variable