logo

Expression of type Forall

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 U, m
from proveit.linear_algebra import Unitary
from proveit.logic import Equals, Forall
from proveit.numbers import Exp, 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 = 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])
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_{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)
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
3Lambdaparameters: 67
body: 4
4Conditionalvalue: 5
condition: 6
5Operationoperator: 7
operands: 8
6Operationoperator: 9
operands: 10
7Literal
8ExprTuple11, 64
9Literal
10ExprTuple12, 13
11Operationoperator: 14
operand: 19
12Operationoperator: 17
operands: 16
13Operationoperator: 17
operands: 18
14Literal
15ExprTuple19
16ExprTuple68, 20
17Literal
18ExprTuple69, 21
19Operationoperator: 22
operands: 23
20Operationoperator: 24
operand: 32
21Operationoperator: 26
operands: 27
22Literal
23ExprTuple28, 29, 30
24Literal
25ExprTuple32
26Literal
27ExprTuple31, 32
28ExprTuple33
29ExprTuple34
30ExprTuple35
31Literal
32Operationoperator: 36
operands: 37
33ExprRangelambda_map: 38
start_index: 64
end_index: 65
34ExprRangelambda_map: 39
start_index: 64
end_index: 65
35ExprRangelambda_map: 40
start_index: 64
end_index: 65
36Literal
37ExprTuple41, 65
38Lambdaparameter: 63
body: 42
39Lambdaparameter: 63
body: 43
40Lambdaparameter: 63
body: 45
41Literal
42Operationoperator: 48
operands: 46
43Operationoperator: 48
operands: 47
44ExprTuple63
45Operationoperator: 48
operands: 49
46NamedExprselement: 50
targets: 53
47NamedExprselement: 51
targets: 53
48Literal
49NamedExprselement: 52
targets: 53
50Operationoperator: 54
operands: 55
51Operationoperator: 56
operands: 57
52Operationoperator: 58
operands: 59
53Operationoperator: 60
operands: 61
54Literal
55NamedExprsstate: 69
part: 63
56Literal
57NamedExprsoperation: 68
part: 63
58Literal
59NamedExprsstate: 62
part: 63
60Literal
61ExprTuple64, 65
62Operationoperator: 66
operands: 67
63Variable
64Literal
65Variable
66Literal
67ExprTuple68, 69
68Variable
69Variable