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 Conditional, Lambda, U, m
from proveit.linear_algebra import Unitary
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import Exp, NaturalPos, one, two
from proveit.physics.quantum import m_ket_domain, var_ket_psi
from proveit.physics.quantum.circuits import unitary_gate_op
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = Lambda(m, Conditional(Forall(instance_param_or_params = [U, var_ket_psi], instance_expr = Equals(Prob(unitary_gate_op), one), domains = [Unitary(Exp(two, m)), m_ket_domain]), 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())
m \mapsto \left\{\forall_{U \in \textrm{U}\left(2^{m}\right), \lvert \psi \rangle \in \mathbb{C}^{2^{m}}}~\left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{U} & \qout{U \thinspace \lvert \psi \rangle}
} \end{array}\right) = 1\right) \textrm{ if } m \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: 71
body: 2
1ExprTuple71
2Conditionalvalue: 3
condition: 4
3Operationoperator: 5
operand: 8
4Operationoperator: 23
operands: 7
5Literal
6ExprTuple8
7ExprTuple71, 9
8Lambdaparameters: 73
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 13
operands: 14
12Operationoperator: 15
operands: 16
13Literal
14ExprTuple17, 70
15Literal
16ExprTuple18, 19
17Operationoperator: 20
operand: 25
18Operationoperator: 23
operands: 22
19Operationoperator: 23
operands: 24
20Literal
21ExprTuple25
22ExprTuple74, 26
23Literal
24ExprTuple75, 27
25Operationoperator: 28
operands: 29
26Operationoperator: 30
operand: 38
27Operationoperator: 32
operands: 33
28Literal
29ExprTuple34, 35, 36
30Literal
31ExprTuple38
32Literal
33ExprTuple37, 38
34ExprTuple39
35ExprTuple40
36ExprTuple41
37Literal
38Operationoperator: 42
operands: 43
39ExprRangelambda_map: 44
start_index: 70
end_index: 71
40ExprRangelambda_map: 45
start_index: 70
end_index: 71
41ExprRangelambda_map: 46
start_index: 70
end_index: 71
42Literal
43ExprTuple47, 71
44Lambdaparameter: 69
body: 48
45Lambdaparameter: 69
body: 49
46Lambdaparameter: 69
body: 51
47Literal
48Operationoperator: 54
operands: 52
49Operationoperator: 54
operands: 53
50ExprTuple69
51Operationoperator: 54
operands: 55
52NamedExprselement: 56
targets: 59
53NamedExprselement: 57
targets: 59
54Literal
55NamedExprselement: 58
targets: 59
56Operationoperator: 60
operands: 61
57Operationoperator: 62
operands: 63
58Operationoperator: 64
operands: 65
59Operationoperator: 66
operands: 67
60Literal
61NamedExprsstate: 75
part: 69
62Literal
63NamedExprsoperation: 74
part: 69
64Literal
65NamedExprsstate: 68
part: 69
66Literal
67ExprTuple70, 71
68Operationoperator: 72
operands: 73
69Variable
70Literal
71Variable
72Literal
73ExprTuple74, 75
74Variable
75Variable