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_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).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{
& \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}\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
4ExprTuple28, 30
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
23ExprTuple28, 27
24ExprTuple28, 30
25Literal
26ExprTuple29, 30
27ExprTuple31
28ExprRangelambda_map: 32
start_index: 59
end_index: 33
29ExprTuple34
30ExprRangelambda_map: 35
start_index: 59
end_index: 36
31ExprRangelambda_map: 37
start_index: 59
end_index: 60
32Lambdaparameter: 58
body: 38
33Variable
34ExprRangelambda_map: 39
start_index: 59
end_index: 60
35Lambdaparameter: 58
body: 40
36Variable
37Lambdaparameter: 58
body: 41
38IndexedVarvariable: 42
index: 58
39Lambdaparameter: 58
body: 43
40IndexedVarvariable: 44
index: 58
41Operationoperator: 47
operands: 46
42Variable
43Operationoperator: 47
operands: 48
44Variable
45ExprTuple58
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