logo

Expression of type Forall

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.core_expr_types import U_1_to_i, V_1_to_j
from proveit.logic import Equals, Forall, 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 = Forall(instance_param_or_params = [U_1_to_i, V_1_to_j], instance_expr = Implies(Equals(Prob(circuit_psi_m_Vj), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_Ui_psi_m)).with_wrapping_at(2)).with_wrapping_at(2)).with_wrapping()
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}{l}\forall_{U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}}~\\
\left(\begin{array}{c} \begin{array}{l} \left(\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) = 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{
& \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) \end{array} \end{array}\right) \end{array} \end{array}\right)\end{array}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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
3Lambdaparameters: 4
body: 5
4ExprTuple29, 28
5Operationoperator: 6
operands: 7
6Literal
7ExprTuple8, 9
8Operationoperator: 11
operands: 10
9Operationoperator: 11
operands: 12
10ExprTuple13, 59
11Literal
12ExprTuple14, 15
13Operationoperator: 18
operand: 20
14Operationoperator: 18
operand: 21
15Operationoperator: 18
operand: 22
16ExprTuple20
17ExprTuple21
18Literal
19ExprTuple22
20Operationoperator: 25
operands: 23
21Operationoperator: 25
operands: 24
22Operationoperator: 25
operands: 26
23ExprTuple27, 28
24ExprTuple29, 28
25Literal
26ExprTuple29, 30
27ExprTuple31
28ExprRangelambda_map: 32
start_index: 59
end_index: 33
29ExprRangelambda_map: 34
start_index: 59
end_index: 35
30ExprTuple36
31ExprRangelambda_map: 37
start_index: 59
end_index: 60
32Lambdaparameter: 58
body: 38
33Variable
34Lambdaparameter: 58
body: 39
35Variable
36ExprRangelambda_map: 40
start_index: 59
end_index: 60
37Lambdaparameter: 58
body: 41
38IndexedVarvariable: 42
index: 58
39IndexedVarvariable: 43
index: 58
40Lambdaparameter: 58
body: 45
41Operationoperator: 47
operands: 46
42Variable
43Variable
44ExprTuple58
45Operationoperator: 47
operands: 48
46NamedExprselement: 49
targets: 51
47Literal
48NamedExprselement: 50
targets: 51
49Operationoperator: 52
operands: 54
50Operationoperator: 53
operands: 54
51Operationoperator: 55
operands: 56
52Literal
53Literal
54NamedExprsstate: 57
part: 58
55Literal
56ExprTuple59, 60
57Variable
58Variable
59Literal
60Variable