logo

Expression of type Implies

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, Implies
from proveit.numbers import one
from proveit.physics.quantum.circuits import circuit_Ui_Vj, circuit_Ui_psi_m, circuit_psi_m_Vj
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Implies(Equals(Prob(circuit_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).with_wrapping_at(2)).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(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \qout{\lvert \psi \rangle}
} \end{array}\right) = 1\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & \qw
} \end{array}\right) =  \\ \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & { /^{m} } \qw
} \end{array}\right) \end{array} \end{array}\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: 1
operands: 2
1Literal
2ExprTuple3, 4
3Operationoperator: 6
operands: 5
4Operationoperator: 6
operands: 7
5ExprTuple8, 54
6Literal
7ExprTuple9, 10
8Operationoperator: 13
operand: 15
9Operationoperator: 13
operand: 16
10Operationoperator: 13
operand: 17
11ExprTuple15
12ExprTuple16
13Literal
14ExprTuple17
15Operationoperator: 20
operands: 18
16Operationoperator: 20
operands: 19
17Operationoperator: 20
operands: 21
18ExprTuple23, 22
19ExprTuple23, 25
20Literal
21ExprTuple24, 25
22ExprTuple26
23ExprRangelambda_map: 27
start_index: 54
end_index: 28
24ExprTuple29
25ExprRangelambda_map: 30
start_index: 54
end_index: 31
26ExprRangelambda_map: 32
start_index: 54
end_index: 55
27Lambdaparameter: 53
body: 33
28Variable
29ExprRangelambda_map: 34
start_index: 54
end_index: 55
30Lambdaparameter: 53
body: 35
31Variable
32Lambdaparameter: 53
body: 36
33IndexedVarvariable: 37
index: 53
34Lambdaparameter: 53
body: 38
35IndexedVarvariable: 39
index: 53
36Operationoperator: 42
operands: 41
37Variable
38Operationoperator: 42
operands: 43
39Variable
40ExprTuple53
41NamedExprselement: 44
targets: 46
42Literal
43NamedExprselement: 45
targets: 46
44Operationoperator: 47
operands: 49
45Operationoperator: 48
operands: 49
46Operationoperator: 50
operands: 51
47Literal
48Literal
49NamedExprsstate: 52
part: 53
50Literal
51ExprTuple54, 55
52Variable
53Variable
54Literal
55Variable