logo

Expression of type Equals

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.logic import Equals
from proveit.numbers import one
from proveit.physics.quantum.circuits import unitary_gate_op
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Equals(Prob(unitary_gate_op), one)
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())
\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{U} & \qout{U \thinspace \lvert \psi \rangle}
} \end{array}\right) = 1
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, 40
3Operationoperator: 4
operand: 6
4Literal
5ExprTuple6
6Operationoperator: 7
operands: 8
7Literal
8ExprTuple9, 10, 11
9ExprTuple12
10ExprTuple13
11ExprTuple14
12ExprRangelambda_map: 15
start_index: 40
end_index: 41
13ExprRangelambda_map: 16
start_index: 40
end_index: 41
14ExprRangelambda_map: 17
start_index: 40
end_index: 41
15Lambdaparameter: 39
body: 18
16Lambdaparameter: 39
body: 19
17Lambdaparameter: 39
body: 21
18Operationoperator: 24
operands: 22
19Operationoperator: 24
operands: 23
20ExprTuple39
21Operationoperator: 24
operands: 25
22NamedExprselement: 26
targets: 29
23NamedExprselement: 27
targets: 29
24Literal
25NamedExprselement: 28
targets: 29
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Operationoperator: 34
operands: 35
29Operationoperator: 36
operands: 37
30Literal
31NamedExprsstate: 45
part: 39
32Literal
33NamedExprsoperation: 44
part: 39
34Literal
35NamedExprsstate: 38
part: 39
36Literal
37ExprTuple40, 41
38Operationoperator: 42
operands: 43
39Variable
40Literal
41Variable
42Literal
43ExprTuple44, 45
44Variable
45Variable