logo

Expression of type Forall

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 Variable
from proveit.logic import Boolean, Forall, InSet, NotEquals
from proveit.numbers import Add, Interval, one
from proveit.physics.quantum.QPE import _ket_u, _s, _t
from proveit.physics.quantum.circuits import MultiQubitElem, Output
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
sub_expr2 = MultiQubitElem(element = Output(state = _ket_u, part = sub_expr1), targets = Interval(Add(_t, one), Add(_t, _s)))
expr = Forall(instance_param_or_params = [sub_expr1], instance_expr = InSet(NotEquals(sub_expr2, sub_expr2), Boolean), domain = Interval(one, _s))
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())
\forall_{{_{-}a} \in \{1~\ldotp \ldotp~s\}}~\left(\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~{_{-}a}~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array} \neq \begin{array}{c} \Qcircuit@C=1em @R=.7em{
& & \qout{\lvert u \rangle~\mbox{part}~{_{-}a}~\mbox{on}~\{t + 1~\ldotp \ldotp~t + s\}} 
} \end{array}\right) \in \mathbb{B}\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 27
body: 5
4ExprTuple27
5Conditionalvalue: 6
condition: 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12
9Literal
10ExprTuple27, 13
11Operationoperator: 14
operands: 15
12Literal
13Operationoperator: 24
operands: 16
14Literal
15ExprTuple17, 17
16ExprTuple33, 35
17Operationoperator: 18
operands: 19
18Literal
19NamedExprselement: 20
targets: 21
20Operationoperator: 22
operands: 23
21Operationoperator: 24
operands: 25
22Literal
23NamedExprsstate: 26
part: 27
24Literal
25ExprTuple28, 29
26Literal
27Variable
28Operationoperator: 31
operands: 30
29Operationoperator: 31
operands: 32
30ExprTuple34, 33
31Literal
32ExprTuple34, 35
33Literal
34Literal
35Literal