# 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, B, Conditional, Lambda, S, k
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import NaturalPos
from proveit.physics.quantum.circuits import MultiQubitElem, Output

In [2]:
# build up the expression from sub-expressions
expr = Lambda(k, Conditional(Forall(instance_param_or_params = [A, B, S], instance_expr = Equals(Equals(MultiQubitElem(element = Output(state = A, part = k), targets = S), MultiQubitElem(element = Output(state = B, part = k), targets = S)), Equals(A, B))), InSet(k, 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())

k \mapsto \left\{\forall_{A, B, S}~\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A~\mbox{part}~k~\mbox{on}~S}
} \end{array} = \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{B~\mbox{part}~k~\mbox{on}~S}
} \end{array}\right) = \left(A = B\right)\right) \textrm{ if } k \in \mathbb{N}^+\right..

In [5]:
stored_expr.style_options()

no style options
In [6]:
# display the expression information
stored_expr.expr_info()

core typesub-expressionsexpression
0Lambdaparameter: 32
body: 2
1ExprTuple32
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple32, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple30, 31, 26
12Operationoperator: 17
operands: 13
13ExprTuple14, 15
14Operationoperator: 17
operands: 16
15Operationoperator: 17
operands: 18
16ExprTuple19, 20
17Literal
18ExprTuple30, 31
19Operationoperator: 22
operands: 21
20Operationoperator: 22
operands: 23
21NamedExprselement: 24
targets: 26
22Literal
23NamedExprselement: 25
targets: 26
24Operationoperator: 28
operands: 27
25Operationoperator: 28
operands: 29
26Variable
27NamedExprsstate: 30
part: 32
28Literal
29NamedExprsstate: 31
part: 32
30Variable
31Variable
32Variable