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, b
from proveit.logic import Set, SetOfAll
from proveit.numbers import one, zero
from proveit.physics.quantum.circuits import qubit_meas
from proveit.statistics import SampleSpaces
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(SetOfAll(instance_param_or_params = [b], instance_element = qubit_meas, domain = Set(zero, one)), 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{
\qin{\lvert \psi \rangle} & \meter & \qout{\lvert b \rangle}
} \end{array}\right\}_{b \in \left\{0, 1\right\}}, \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: 35
body: 6
6Conditionalvalue: 7
condition: 8
7Operationoperator: 9
operands: 10
8Operationoperator: 11
operands: 12
9Literal
10ExprTuple13, 14, 15
11Literal
12ExprTuple35, 16
13ExprTuple17
14ExprTuple18
15ExprTuple19
16Operationoperator: 20
operands: 21
17Operationoperator: 22
operands: 23
18Operationoperator: 24
operands: 25
19Operationoperator: 26
operands: 27
20Literal
21ExprTuple28, 29
22Literal
23NamedExprsstate: 30
24Literal
25NamedExprsbasis: 31
26Literal
27NamedExprsstate: 32
28Literal
29Literal
30Variable
31Literal
32Operationoperator: 33
operand: 35
33Literal
34ExprTuple35
35Variable