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 Conditional, ExprTuple, 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 = ExprTuple(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())
\left(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..\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: 72
body: 3
2ExprTuple72
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 24
operands: 8
6Literal
7ExprTuple9
8ExprTuple72, 10
9Lambdaparameters: 74
body: 11
10Literal
11Conditionalvalue: 12
condition: 13
12Operationoperator: 14
operands: 15
13Operationoperator: 16
operands: 17
14Literal
15ExprTuple18, 71
16Literal
17ExprTuple19, 20
18Operationoperator: 21
operand: 26
19Operationoperator: 24
operands: 23
20Operationoperator: 24
operands: 25
21Literal
22ExprTuple26
23ExprTuple75, 27
24Literal
25ExprTuple76, 28
26Operationoperator: 29
operands: 30
27Operationoperator: 31
operand: 39
28Operationoperator: 33
operands: 34
29Literal
30ExprTuple35, 36, 37
31Literal
32ExprTuple39
33Literal
34ExprTuple38, 39
35ExprTuple40
36ExprTuple41
37ExprTuple42
38Literal
39Operationoperator: 43
operands: 44
40ExprRangelambda_map: 45
start_index: 71
end_index: 72
41ExprRangelambda_map: 46
start_index: 71
end_index: 72
42ExprRangelambda_map: 47
start_index: 71
end_index: 72
43Literal
44ExprTuple48, 72
45Lambdaparameter: 70
body: 49
46Lambdaparameter: 70
body: 50
47Lambdaparameter: 70
body: 52
48Literal
49Operationoperator: 55
operands: 53
50Operationoperator: 55
operands: 54
51ExprTuple70
52Operationoperator: 55
operands: 56
53NamedExprselement: 57
targets: 60
54NamedExprselement: 58
targets: 60
55Literal
56NamedExprselement: 59
targets: 60
57Operationoperator: 61
operands: 62
58Operationoperator: 63
operands: 64
59Operationoperator: 65
operands: 66
60Operationoperator: 67
operands: 68
61Literal
62NamedExprsstate: 76
part: 70
63Literal
64NamedExprsoperation: 75
part: 70
65Literal
66NamedExprsstate: 69
part: 70
67Literal
68ExprTuple71, 72
69Operationoperator: 73
operands: 74
70Variable
71Literal
72Variable
73Literal
74ExprTuple75, 76
75Variable
76Variable