logo

Expression of type Lambda

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 Forall, InSet, NotEquals
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 = NotEquals(MultiQubitElem(element = Output(state = A, part = k), targets = S), MultiQubitElem(element = Output(state = B, part = k), targets = S)), condition = NotEquals(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~|~A \neq B}~\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{A~\mbox{part}~k~\mbox{on}~S} 
} \end{array} \neq \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..
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 31
body: 2
1ExprTuple31
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 9
4Operationoperator: 7
operands: 8
5Literal
6ExprTuple9
7Literal
8ExprTuple31, 10
9Lambdaparameters: 11
body: 12
10Literal
11ExprTuple29, 30, 25
12Conditionalvalue: 13
condition: 14
13Operationoperator: 16
operands: 15
14Operationoperator: 16
operands: 17
15ExprTuple18, 19
16Literal
17ExprTuple29, 30
18Operationoperator: 21
operands: 20
19Operationoperator: 21
operands: 22
20NamedExprselement: 23
targets: 25
21Literal
22NamedExprselement: 24
targets: 25
23Operationoperator: 27
operands: 26
24Operationoperator: 27
operands: 28
25Variable
26NamedExprsstate: 29
part: 31
27Literal
28NamedExprsstate: 30
part: 31
29Variable
30Variable
31Variable