logo

Expression of type SetOfAll

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 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 = 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\{\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\}}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 59
body: 5
4ExprTuple59
5Conditionalvalue: 6
condition: 7
6Operationoperator: 8
operands: 9
7Operationoperator: 10
operands: 11
8Literal
9ExprTuple12, 13, 14
10Literal
11ExprTuple59, 15
12ExprTuple16
13ExprTuple17
14ExprTuple18
15Operationoperator: 50
operands: 19
16ExprRangelambda_map: 20
start_index: 56
end_index: 60
17ExprRangelambda_map: 21
start_index: 56
end_index: 60
18ExprRangelambda_map: 22
start_index: 56
end_index: 60
19ExprTuple23, 24
20Lambdaparameter: 55
body: 25
21Lambdaparameter: 55
body: 26
22Lambdaparameter: 55
body: 28
23Literal
24Operationoperator: 29
operands: 30
25Operationoperator: 34
operands: 31
26Operationoperator: 32
operands: 33
27ExprTuple55
28Operationoperator: 34
operands: 35
29Literal
30ExprTuple36, 37
31NamedExprselement: 38
targets: 41
32Literal
33NamedExprsbasis: 39
34Literal
35NamedExprselement: 40
targets: 41
36Operationoperator: 42
operands: 43
37Operationoperator: 44
operand: 56
38Operationoperator: 46
operands: 47
39Literal
40Operationoperator: 48
operands: 49
41Operationoperator: 50
operands: 51
42Literal
43ExprTuple52, 60
44Literal
45ExprTuple56
46Literal
47NamedExprsstate: 53
part: 55
48Literal
49NamedExprsstate: 54
part: 55
50Literal
51ExprTuple56, 60
52Literal
53Variable
54Operationoperator: 57
operands: 58
55Variable
56Literal
57Literal
58ExprTuple59, 60
59Variable
60Variable