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, 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 = [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))
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(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]
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: 8
operand: 11
7Operationoperator: 51
operands: 10
8Literal
9ExprTuple11
10ExprTuple27, 12
11Lambdaparameters: 13
body: 14
12Operationoperator: 15
operand: 74
13ExprTuple17, 18
14Conditionalvalue: 19
condition: 20
15Literal
16ExprTuple74
17ExprRangelambda_map: 21
start_index: 73
end_index: 74
18ExprRangelambda_map: 22
start_index: 73
end_index: 74
19Operationoperator: 23
operands: 24
20Operationoperator: 25
operands: 26
21Lambdaparameter: 87
body: 82
22Lambdaparameter: 87
body: 83
23Literal
24ExprTuple27, 28
25Literal
26ExprTuple29, 30
27Variable
28Operationoperator: 31
operand: 35
29Operationoperator: 51
operands: 33
30Operationoperator: 51
operands: 34
31Literal
32ExprTuple35
33ExprTuple36, 38
34ExprTuple37, 38
35Lambdaparameter: 81
body: 39
36Operationoperator: 54
operand: 46
37Operationoperator: 54
operand: 47
38Operationoperator: 42
operand: 48
39Conditionalvalue: 44
condition: 45
40ExprTuple46
41ExprTuple47
42Literal
43ExprTuple48
44Operationoperator: 49
operands: 50
45Operationoperator: 51
operands: 52
46Operationoperator: 54
operands: 53
47Operationoperator: 54
operands: 55
48Operationoperator: 56
operands: 57
49Literal
50ExprTuple58, 59
51Literal
52ExprTuple81, 60
53ExprTuple61
54Literal
55ExprTuple62
56Literal
57ExprTuple63, 74
58Operationoperator: 79
operand: 71
59Operationoperator: 65
operand: 72
60Operationoperator: 67
operands: 68
61ExprRangelambda_map: 69
start_index: 73
end_index: 74
62ExprRangelambda_map: 70
start_index: 73
end_index: 74
63Literal
64ExprTuple71
65Literal
66ExprTuple72
67Literal
68ExprTuple73, 74
69Lambdaparameter: 87
body: 75
70Lambdaparameter: 87
body: 76
71IndexedVarvariable: 84
index: 81
72IndexedVarvariable: 85
index: 81
73Literal
74Variable
75Operationoperator: 79
operand: 82
76Operationoperator: 79
operand: 83
77ExprTuple81
78ExprTuple82
79Literal
80ExprTuple83
81Variable
82IndexedVarvariable: 84
index: 87
83IndexedVarvariable: 85
index: 87
84Variable
85Variable
86ExprTuple87
87Variable