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 Input, MultiQubitElem
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(Equals(MultiQubitElem(element = Input(state = A, part = k), targets = S), MultiQubitElem(element = Input(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())
\left(k \mapsto \left\{\forall_{A, B, S}~\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{A~\mbox{part}~k~\mbox{on}~S} & \qw 
} \end{array} = \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \qin{B~\mbox{part}~k~\mbox{on}~S} & \qw 
} \end{array}\right) = \left(A = B\right)\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: 33
body: 3
2ExprTuple33
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 10
5Operationoperator: 8
operands: 9
6Literal
7ExprTuple10
8Literal
9ExprTuple33, 11
10Lambdaparameters: 12
body: 13
11Literal
12ExprTuple31, 32, 27
13Operationoperator: 18
operands: 14
14ExprTuple15, 16
15Operationoperator: 18
operands: 17
16Operationoperator: 18
operands: 19
17ExprTuple20, 21
18Literal
19ExprTuple31, 32
20Operationoperator: 23
operands: 22
21Operationoperator: 23
operands: 24
22NamedExprselement: 25
targets: 27
23Literal
24NamedExprselement: 26
targets: 27
25Operationoperator: 29
operands: 28
26Operationoperator: 29
operands: 30
27Variable
28NamedExprsstate: 31
part: 33
29Literal
30NamedExprsstate: 32
part: 33
31Variable
32Variable
33Variable