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
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(m_bit_interval, SetOfAll(instance_param_or_params = [n], instance_element = register_meas, domain = m_bit_interval))
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(\{0~\ldotp \ldotp~2^{m} - 1\}, \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\}}\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
0ExprTuple16, 1
1Operationoperator: 2
operand: 4
2Literal
3ExprTuple4
4Lambdaparameter: 60
body: 6
5ExprTuple60
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14, 15
11Literal
12ExprTuple60, 16
13ExprTuple17
14ExprTuple18
15ExprTuple19
16Operationoperator: 51
operands: 20
17ExprRangelambda_map: 21
start_index: 57
end_index: 61
18ExprRangelambda_map: 22
start_index: 57
end_index: 61
19ExprRangelambda_map: 23
start_index: 57
end_index: 61
20ExprTuple24, 25
21Lambdaparameter: 56
body: 26
22Lambdaparameter: 56
body: 27
23Lambdaparameter: 56
body: 29
24Literal
25Operationoperator: 30
operands: 31
26Operationoperator: 35
operands: 32
27Operationoperator: 33
operands: 34
28ExprTuple56
29Operationoperator: 35
operands: 36
30Literal
31ExprTuple37, 38
32NamedExprselement: 39
targets: 42
33Literal
34NamedExprsbasis: 40
35Literal
36NamedExprselement: 41
targets: 42
37Operationoperator: 43
operands: 44
38Operationoperator: 45
operand: 57
39Operationoperator: 47
operands: 48
40Literal
41Operationoperator: 49
operands: 50
42Operationoperator: 51
operands: 52
43Literal
44ExprTuple53, 61
45Literal
46ExprTuple57
47Literal
48NamedExprsstate: 54
part: 56
49Literal
50NamedExprsstate: 55
part: 56
51Literal
52ExprTuple57, 61
53Literal
54Variable
55Operationoperator: 58
operands: 59
56Variable
57Literal
58Literal
59ExprTuple60, 61
60Variable
61Variable