logo

Expression of type Conditional

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, 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 = 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\{\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()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 6
2Operationoperator: 21
operands: 5
3Literal
4ExprTuple6
5ExprTuple69, 7
6Lambdaparameters: 71
body: 8
7Literal
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 68
13Literal
14ExprTuple16, 17
15Operationoperator: 18
operand: 23
16Operationoperator: 21
operands: 20
17Operationoperator: 21
operands: 22
18Literal
19ExprTuple23
20ExprTuple72, 24
21Literal
22ExprTuple73, 25
23Operationoperator: 26
operands: 27
24Operationoperator: 28
operand: 36
25Operationoperator: 30
operands: 31
26Literal
27ExprTuple32, 33, 34
28Literal
29ExprTuple36
30Literal
31ExprTuple35, 36
32ExprTuple37
33ExprTuple38
34ExprTuple39
35Literal
36Operationoperator: 40
operands: 41
37ExprRangelambda_map: 42
start_index: 68
end_index: 69
38ExprRangelambda_map: 43
start_index: 68
end_index: 69
39ExprRangelambda_map: 44
start_index: 68
end_index: 69
40Literal
41ExprTuple45, 69
42Lambdaparameter: 67
body: 46
43Lambdaparameter: 67
body: 47
44Lambdaparameter: 67
body: 49
45Literal
46Operationoperator: 52
operands: 50
47Operationoperator: 52
operands: 51
48ExprTuple67
49Operationoperator: 52
operands: 53
50NamedExprselement: 54
targets: 57
51NamedExprselement: 55
targets: 57
52Literal
53NamedExprselement: 56
targets: 57
54Operationoperator: 58
operands: 59
55Operationoperator: 60
operands: 61
56Operationoperator: 62
operands: 63
57Operationoperator: 64
operands: 65
58Literal
59NamedExprsstate: 73
part: 67
60Literal
61NamedExprsoperation: 72
part: 67
62Literal
63NamedExprsstate: 66
part: 67
64Literal
65ExprTuple68, 69
66Operationoperator: 70
operands: 71
67Variable
68Literal
69Variable
70Literal
71ExprTuple72, 73
72Variable
73Variable