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 ExprTuple, n
from proveit.logic import SetOfAll
from proveit.physics.quantum import m_bit_interval
from proveit.physics.quantum.circuits import register_meas
from proveit.statistics import SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(SetOfAll(instance_param_or_params = [n], instance_element = register_meas, domain = m_bit_interval), SampleSpaces)
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\{\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\multiqin{3}{\lvert \psi \rangle} & \meter & \multiqout{3}{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \measure{\begin{array}{c}:\\ \left(m - 3\right) \times \\:\end{array}} \qw & \ghostqout{\lvert n \rangle_{m}} \\
\ghostqin{\lvert \psi \rangle} & \meter & \ghostqout{\lvert n \rangle_{m}}
} \end{array}\right\}_{n \in \{0~\ldotp \ldotp~2^{m} - 1\}}, \textrm{SampleSpaces}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 3
operand: 5
2Literal
3Literal
4ExprTuple5
5Lambdaparameter: 61
body: 7
6ExprTuple61
7Conditionalvalue: 8
condition: 9
8Operationoperator: 10
operands: 11
9Operationoperator: 12
operands: 13
10Literal
11ExprTuple14, 15, 16
12Literal
13ExprTuple61, 17
14ExprTuple18
15ExprTuple19
16ExprTuple20
17Operationoperator: 52
operands: 21
18ExprRangelambda_map: 22
start_index: 58
end_index: 62
19ExprRangelambda_map: 23
start_index: 58
end_index: 62
20ExprRangelambda_map: 24
start_index: 58
end_index: 62
21ExprTuple25, 26
22Lambdaparameter: 57
body: 27
23Lambdaparameter: 57
body: 28
24Lambdaparameter: 57
body: 30
25Literal
26Operationoperator: 31
operands: 32
27Operationoperator: 36
operands: 33
28Operationoperator: 34
operands: 35
29ExprTuple57
30Operationoperator: 36
operands: 37
31Literal
32ExprTuple38, 39
33NamedExprselement: 40
targets: 43
34Literal
35NamedExprsbasis: 41
36Literal
37NamedExprselement: 42
targets: 43
38Operationoperator: 44
operands: 45
39Operationoperator: 46
operand: 58
40Operationoperator: 48
operands: 49
41Literal
42Operationoperator: 50
operands: 51
43Operationoperator: 52
operands: 53
44Literal
45ExprTuple54, 62
46Literal
47ExprTuple58
48Literal
49NamedExprsstate: 55
part: 57
50Literal
51NamedExprsstate: 56
part: 57
52Literal
53ExprTuple58, 62
54Literal
55Variable
56Operationoperator: 59
operands: 60
57Variable
58Literal
59Literal
60ExprTuple61, 62
61Variable
62Variable