logo

Expression of type ExprTuple

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, ExprTuple, 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 = ExprTuple(Lambda(k, Conditional(Forall(instance_param_or_params = [A, B, S], instance_expr = Equals(MultiQubitElem(element = Output(state = A, part = k), targets = S), MultiQubitElem(element = Output(state = B, part = k), targets = S)), condition = 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())
\left(k \mapsto \left\{\forall_{A, B, S~|~A = B}~\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) \textrm{ if } k \in \mathbb{N}^+\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 32
body: 3
2ExprTuple32
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple32, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple30, 31, 26
13Conditionalvalue: 14
condition: 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