logo

Expression of type Conditional

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 Conditional, a, b, k, m
from proveit.core_expr_types import U_1_to_m
from proveit.logic import And, Forall, Implies, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_aU, circuit_aUb, circuit_b
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [a, b, U_1_to_m], instance_expr = Implies(circuit_aUb, QcircuitEquiv(circuit_aU, circuit_b))), And(InSet(k, NaturalPos), InSet(m, NaturalPos)))
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\{\forall_{a, b, U_{1}, U_{2}, \ldots, U_{m}}~\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \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_{m} \\ \downarrow\end{array}} & \qout{b}
} \end{array}\right) \Rightarrow \left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{a} & \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_{m} \\ \downarrow\end{array}} & { /^{k} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{b} & { /^{k} } \qw
} \end{array}\right)\right)\right) \textrm{ if } k \in \mathbb{N}^+ ,  m \in \mathbb{N}^+\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9
7Lambdaparameters: 10
body: 11
8Operationoperator: 13
operands: 12
9Operationoperator: 13
operands: 14
10ExprTuple60, 61, 32
11Operationoperator: 15
operands: 16
12ExprTuple64, 17
13Literal
14ExprTuple37, 17
15Literal
16ExprTuple18, 19
17Literal
18Operationoperator: 28
operands: 20
19Operationoperator: 21
operands: 22
20ExprTuple31, 32, 23
21Literal
22ExprTuple24, 25
23ExprTuple26
24Operationoperator: 28
operands: 27
25Operationoperator: 28
operand: 33
26ExprRangelambda_map: 30
start_index: 63
end_index: 64
27ExprTuple31, 32
28Literal
29ExprTuple33
30Lambdaparameter: 62
body: 34
31ExprTuple35
32ExprRangelambda_map: 36
start_index: 63
end_index: 37
33ExprTuple38
34Operationoperator: 50
operands: 39
35ExprRangelambda_map: 40
start_index: 63
end_index: 64
36Lambdaparameter: 62
body: 41
37Variable
38ExprRangelambda_map: 42
start_index: 63
end_index: 64
39NamedExprselement: 43
targets: 54
40Lambdaparameter: 62
body: 44
41IndexedVarvariable: 45
index: 62
42Lambdaparameter: 62
body: 47
43Operationoperator: 48
operands: 57
44Operationoperator: 50
operands: 49
45Variable
46ExprTuple62
47Operationoperator: 50
operands: 51
48Literal
49NamedExprselement: 52
targets: 54
50Literal
51NamedExprselement: 53
targets: 54
52Operationoperator: 56
operands: 55
53Operationoperator: 56
operands: 57
54Operationoperator: 58
operands: 59
55NamedExprsstate: 60
part: 62
56Literal
57NamedExprsstate: 61
part: 62
58Literal
59ExprTuple63, 64
60Variable
61Variable
62Variable
63Literal
64Variable