logo

Expression of type Forall

from the theory of proveit.physics.quantum.algebra

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, i, n
from proveit.core_expr_types import v_1_to_n, v_i, w_1_to_n, w_i
from proveit.linear_algebra import OrthoNormBases, Unitary, VecSum
from proveit.logic import CartExp, Equals, Exists, Forall, InSet, Set
from proveit.numbers import Complex, Interval, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets, w_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
sub_expr1 = OrthoNormBases(CartExp(Complex, n))
expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [U], instance_expr = Exists(instance_param_or_params = [v_1_to_n, w_1_to_n], instance_expr = Equals(U, VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n))), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).with_wrapping(), domain = Unitary(n)), domain = 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())
\forall_{n \in \mathbb{N}^+}~\left[\forall_{U \in \textrm{U}\left(n\right)}~\left[\begin{array}{l}\exists_{v_{1}, v_{2}, \ldots, v_{n}, w_{1}, w_{2}, \ldots, w_{n}~|~\left\{\left\{\lvert v_{1} \rangle, \lvert v_{2} \rangle, \ldots, \lvert v_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right), \left\{\left\{\lvert w_{1} \rangle, \lvert w_{2} \rangle, \ldots, \lvert w_{n} \rangle\right\}\right\} \in \textrm{O.N.Bases}\left(\mathbb{C}^{n}\right)}~\\
\left(U = \left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right)\right)\end{array}\right]\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: 6
operand: 2
1ExprTuple2
2Lambdaparameter: 81
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 6
operand: 9
5Operationoperator: 58
operands: 8
6Literal
7ExprTuple9
8ExprTuple81, 10
9Lambdaparameter: 34
body: 12
10Literal
11ExprTuple34
12Conditionalvalue: 13
condition: 14
13Operationoperator: 15
operand: 18
14Operationoperator: 58
operands: 17
15Literal
16ExprTuple18
17ExprTuple34, 19
18Lambdaparameters: 20
body: 21
19Operationoperator: 22
operand: 81
20ExprTuple24, 25
21Conditionalvalue: 26
condition: 27
22Literal
23ExprTuple81
24ExprRangelambda_map: 28
start_index: 80
end_index: 81
25ExprRangelambda_map: 29
start_index: 80
end_index: 81
26Operationoperator: 30
operands: 31
27Operationoperator: 32
operands: 33
28Lambdaparameter: 94
body: 89
29Lambdaparameter: 94
body: 90
30Literal
31ExprTuple34, 35
32Literal
33ExprTuple36, 37
34Variable
35Operationoperator: 38
operand: 42
36Operationoperator: 58
operands: 40
37Operationoperator: 58
operands: 41
38Literal
39ExprTuple42
40ExprTuple43, 45
41ExprTuple44, 45
42Lambdaparameter: 88
body: 46
43Operationoperator: 61
operand: 53
44Operationoperator: 61
operand: 54
45Operationoperator: 49
operand: 55
46Conditionalvalue: 51
condition: 52
47ExprTuple53
48ExprTuple54
49Literal
50ExprTuple55
51Operationoperator: 56
operands: 57
52Operationoperator: 58
operands: 59
53Operationoperator: 61
operands: 60
54Operationoperator: 61
operands: 62
55Operationoperator: 63
operands: 64
56Literal
57ExprTuple65, 66
58Literal
59ExprTuple88, 67
60ExprTuple68
61Literal
62ExprTuple69
63Literal
64ExprTuple70, 81
65Operationoperator: 86
operand: 78
66Operationoperator: 72
operand: 79
67Operationoperator: 74
operands: 75
68ExprRangelambda_map: 76
start_index: 80
end_index: 81
69ExprRangelambda_map: 77
start_index: 80
end_index: 81
70Literal
71ExprTuple78
72Literal
73ExprTuple79
74Literal
75ExprTuple80, 81
76Lambdaparameter: 94
body: 82
77Lambdaparameter: 94
body: 83
78IndexedVarvariable: 91
index: 88
79IndexedVarvariable: 92
index: 88
80Literal
81Variable
82Operationoperator: 86
operand: 89
83Operationoperator: 86
operand: 90
84ExprTuple88
85ExprTuple89
86Literal
87ExprTuple90
88Variable
89IndexedVarvariable: 91
index: 94
90IndexedVarvariable: 92
index: 94
91Variable
92Variable
93ExprTuple94
94Variable