logo

Expression of type InSet

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 Lambda, b
from proveit.logic import Bijections, InSet, Set, SetOfAll
from proveit.numbers import one, zero
from proveit.physics.quantum.circuits import qubit_meas
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Set(zero, one)
expr = 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)
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())
\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}
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.()(2)('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: 15
operands: 1
1ExprTuple2, 3
2Lambdaparameter: 39
body: 11
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple20, 6
6Operationoperator: 7
operand: 9
7Literal
8ExprTuple9
9Lambdaparameter: 39
body: 10
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 18, 19
15Literal
16ExprTuple39, 20
17ExprTuple21
18ExprTuple22
19ExprTuple23
20Operationoperator: 24
operands: 25
21Operationoperator: 26
operands: 27
22Operationoperator: 28
operands: 29
23Operationoperator: 30
operands: 31
24Literal
25ExprTuple32, 33
26Literal
27NamedExprsstate: 34
28Literal
29NamedExprsbasis: 35
30Literal
31NamedExprsstate: 36
32Literal
33Literal
34Variable
35Literal
36Operationoperator: 37
operand: 39
37Literal
38ExprTuple39
39Variable