logo

Expression of type Conditional

from the theory of proveit.physics.quantum.QPE

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, Function, U, Variable, s, t
from proveit.logic import And, Forall, InSet
from proveit.physics.quantum import normalized_var_ket_u, var_ket_u
from proveit.physics.quantum.QPE import phase, s_ket_domain
In [2]:
# build up the expression from sub-expressions
expr = Conditional(Forall(instance_param_or_params = [phase], instance_expr = Function(Variable("_b", latex_format = r"{_{-}b}"), [s, t, U, var_ket_u, phase])), And(InSet(var_ket_u, s_ket_domain), normalized_var_ket_u))
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_{\varphi}~{_{-}b}\left(s, t, U, \lvert u \rangle, \varphi\right) \textrm{ if } \lvert u \rangle \in \mathbb{C}^{2^{s}} ,  \left \|\lvert u \rangle\right \| = 1\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: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8, 9
7Lambdaparameter: 23
body: 11
8Operationoperator: 12
operands: 13
9Operationoperator: 14
operands: 15
10ExprTuple23
11Operationoperator: 16
operands: 17
12Literal
13ExprTuple30, 18
14Literal
15ExprTuple19, 20
16Variable
17ExprTuple34, 21, 22, 30, 23
18Operationoperator: 24
operands: 25
19Operationoperator: 26
operand: 30
20Literal
21Variable
22Variable
23Variable
24Literal
25ExprTuple28, 29
26Literal
27ExprTuple30
28Literal
29Operationoperator: 31
operands: 32
30Variable
31Literal
32ExprTuple33, 34
33Literal
34Variable