logo

Expression of type InClass

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 n
from proveit.logic import InClass, 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 = InClass(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\{\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\}} \underset{{\scriptscriptstyle c}}{\in} \textrm{SampleSpaces}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
operation'infix' or 'function' style formattinginfixinfix
wrap_positionsposition(s) at which wrapping is to occur; '2 n - 1' is after the nth operand, '2 n' is after the nth operation.()()('with_wrapping_at', 'with_wrap_before_operator', 'with_wrap_after_operator', 'without_wrapping', 'wrap_positions')
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'centercenter('with_justification',)
directionDirection of the relation (normal or reversed)normalnormal('with_direction_reversed', 'is_reversed')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 5
operand: 7
4Literal
5Literal
6ExprTuple7
7Lambdaparameter: 63
body: 9
8ExprTuple63
9Conditionalvalue: 10
condition: 11
10Operationoperator: 12
operands: 13
11Operationoperator: 14
operands: 15
12Literal
13ExprTuple16, 17, 18
14Literal
15ExprTuple63, 19
16ExprTuple20
17ExprTuple21
18ExprTuple22
19Operationoperator: 54
operands: 23
20ExprRangelambda_map: 24
start_index: 60
end_index: 64
21ExprRangelambda_map: 25
start_index: 60
end_index: 64
22ExprRangelambda_map: 26
start_index: 60
end_index: 64
23ExprTuple27, 28
24Lambdaparameter: 59
body: 29
25Lambdaparameter: 59
body: 30
26Lambdaparameter: 59
body: 32
27Literal
28Operationoperator: 33
operands: 34
29Operationoperator: 38
operands: 35
30Operationoperator: 36
operands: 37
31ExprTuple59
32Operationoperator: 38
operands: 39
33Literal
34ExprTuple40, 41
35NamedExprselement: 42
targets: 45
36Literal
37NamedExprsbasis: 43
38Literal
39NamedExprselement: 44
targets: 45
40Operationoperator: 46
operands: 47
41Operationoperator: 48
operand: 60
42Operationoperator: 50
operands: 51
43Literal
44Operationoperator: 52
operands: 53
45Operationoperator: 54
operands: 55
46Literal
47ExprTuple56, 64
48Literal
49ExprTuple60
50Literal
51NamedExprsstate: 57
part: 59
52Literal
53NamedExprsstate: 58
part: 59
54Literal
55ExprTuple60, 64
56Literal
57Variable
58Operationoperator: 61
operands: 62
59Variable
60Literal
61Literal
62ExprTuple63, 64
63Variable
64Variable