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 A, Conditional, m
from proveit.core_expr_types import B_1_to_m
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, Iff, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum.circuits import QcircuitEquiv, circuit_compressed_inputAm, circuit_expanded_inputBm
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [A, B_1_to_m], instance_expr = Iff(QcircuitEquiv(circuit_compressed_inputAm, circuit_expanded_inputBm), Equals(A, TensorProd(B_1_to_m)))), 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_{1}, B_{2}, \ldots, B_{m}}~\left(\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{A} & { /^{m} } \qw
} \end{array}\right) \cong \left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{B_{1}} & \qw \\
\qin{B_{2}} & \qw \\
\qin{\vdots} & \qw \\
\qin{B_{m}} & \qw
} \end{array}\right)\right) \Leftrightarrow \left(A = \left(B_{1} {\otimes}  B_{2} {\otimes}  \ldots {\otimes}  B_{m}\right)\right)\right) \textrm{ if } 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
6ExprTuple51, 8
7Lambdaparameters: 9
body: 10
8Literal
9ExprTuple49, 29
10Operationoperator: 11
operands: 12
11Literal
12ExprTuple13, 14
13Operationoperator: 15
operands: 16
14Operationoperator: 17
operands: 18
15Literal
16ExprTuple19, 20
17Literal
18ExprTuple49, 21
19Operationoperator: 23
operand: 27
20Operationoperator: 23
operand: 28
21Operationoperator: 25
operands: 26
22ExprTuple27
23Literal
24ExprTuple28
25Literal
26ExprTuple29
27ExprTuple30
28ExprTuple31
29ExprRangelambda_map: 32
start_index: 50
end_index: 51
30ExprRangelambda_map: 33
start_index: 50
end_index: 51
31ExprRangelambda_map: 34
start_index: 50
end_index: 51
32Lambdaparameter: 52
body: 42
33Lambdaparameter: 52
body: 35
34Lambdaparameter: 52
body: 36
35Operationoperator: 37
operands: 38
36Operationoperator: 43
operands: 39
37Literal
38NamedExprselement: 40
targets: 41
39NamedExprsstate: 42
40Operationoperator: 43
operands: 44
41Operationoperator: 45
operands: 46
42IndexedVarvariable: 47
index: 52
43Literal
44NamedExprsstate: 49
part: 52
45Literal
46ExprTuple50, 51
47Variable
48ExprTuple52
49Variable
50Literal
51Variable
52Variable