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 k
from proveit.linalg import TensorProd
from proveit.logic import Equals, Forall
from proveit.numbers import Add, Interval, Neg, one
from proveit.physics.quantum.QPE import p_k, psi_k, psi_next, t_
In [2]:
# build up the expression from sub-expressions
expr = Forall([k], Equals(psi_next, TensorProd(p_k, psi_k)), domain = Interval(one, Add(t_, Neg(one))))
Out[2]:
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(expr.latex())
\forall_{k \in \{1~\ldotp \ldotp~t - 1\}}~\left(\psi_{k + 1} = \left(p_{k} {\otimes} \psi_{k}\right)\right)
In [5]:
expr.style_options()
Out[5]:
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
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
expr.expr_info()
Out[6]:
 core typesub-expressionsexpression
0Operationoperator: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameter: 31
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 12
9Literal
10ExprTuple31, 13
11Operationoperator: 25
operands: 14
12Operationoperator: 15
operands: 16
13Operationoperator: 17
operands: 18
14ExprTuple30, 19
15Literal
16ExprTuple20, 21
17Literal
18ExprTuple36, 22
19Operationoperator: 27
operands: 23
20Operationoperator: 25
operands: 24
21Operationoperator: 25
operands: 26
22Operationoperator: 27
operands: 28
23ExprTuple31, 36
24ExprTuple29, 31
25Literal
26ExprTuple30, 31
27Literal
28ExprTuple32, 33
29Literal
30Literal
31Variable
32Literal
33Operationoperator: 34
operand: 36
34Literal
35ExprTuple36
36Literal