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, j, n
from proveit.core_expr_types import v_1_to_n, v_i, v_j
from proveit.linear_algebra import Adj, MatrixSpace, OrthoNormBases, Unitary
from proveit.logic import CartExp, Equals, Forall, Implies, InSet, Set
from proveit.numbers import Complex, Interval, KroneckerDelta, NaturalPos, one
from proveit.physics.quantum import Bra, Ket, Qmult
from proveit.physics.quantum.algebra import v_1_to_n_kets
In [2]:
# build up the expression from sub-expressions
expr = Forall(instance_param_or_params = [n], instance_expr = Forall(instance_param_or_params = [U], instance_expr = Forall(instance_param_or_params = [v_1_to_n], instance_expr = Implies(Forall(instance_param_or_params = [i, j], instance_expr = Equals(Qmult(Bra(v_i), Adj(U), U, Ket(v_j)), KroneckerDelta(i, j)), domain = Interval(one, n)), InSet(U, Unitary(n))), condition = InSet(Set(v_1_to_n_kets), OrthoNormBases(CartExp(Complex, n)))).with_wrapping(), domain = MatrixSpace(field = Complex, rows = n, columns = 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 \mathbb{C}^{n \times n}}~\left[\begin{array}{l}\forall_{v_{1}, v_{2}, \ldots, v_{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[\forall_{i, j \in \{1~\ldotp \ldotp~n\}}~\left(\left(\langle v_{i} \rvert \thinspace U^{\dagger} \thinspace U \thinspace \lvert v_{j} \rangle\right) = \delta_{i, j}\right)\right] \Rightarrow \left(U \in \textrm{U}\left(n\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: 32
operand: 2
1ExprTuple2
2Lambdaparameter: 89
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 32
operand: 8
5Operationoperator: 68
operands: 7
6ExprTuple8
7ExprTuple89, 9
8Lambdaparameter: 86
body: 10
9Literal
10Conditionalvalue: 11
condition: 12
11Operationoperator: 32
operand: 15
12Operationoperator: 68
operands: 14
13ExprTuple15
14ExprTuple86, 16
15Lambdaparameters: 17
body: 18
16Operationoperator: 19
operands: 20
17ExprTuple21
18Conditionalvalue: 22
condition: 23
19Literal
20NamedExprsfield: 52
rows: 89
columns: 89
21ExprRangelambda_map: 24
start_index: 88
end_index: 89
22Operationoperator: 25
operands: 26
23Operationoperator: 68
operands: 27
24Lambdaparameter: 90
body: 75
25Literal
26ExprTuple28, 29
27ExprTuple30, 31
28Operationoperator: 32
operand: 38
29Operationoperator: 68
operands: 34
30Operationoperator: 45
operand: 40
31Operationoperator: 36
operand: 41
32Literal
33ExprTuple38
34ExprTuple86, 39
35ExprTuple40
36Literal
37ExprTuple41
38Lambdaparameters: 66
body: 42
39Operationoperator: 43
operand: 89
40Operationoperator: 45
operands: 46
41Operationoperator: 47
operands: 48
42Conditionalvalue: 49
condition: 50
43Literal
44ExprTuple89
45Literal
46ExprTuple51
47Literal
48ExprTuple52, 89
49Operationoperator: 53
operands: 54
50Operationoperator: 55
operands: 56
51ExprRangelambda_map: 57
start_index: 88
end_index: 89
52Literal
53Literal
54ExprTuple58, 59
55Literal
56ExprTuple60, 61
57Lambdaparameter: 90
body: 62
58Operationoperator: 63
operands: 64
59Operationoperator: 65
operands: 66
60Operationoperator: 68
operands: 67
61Operationoperator: 68
operands: 69
62Operationoperator: 80
operand: 75
63Literal
64ExprTuple71, 72, 86, 73
65Literal
66ExprTuple94, 95
67ExprTuple94, 74
68Literal
69ExprTuple95, 74
70ExprTuple75
71Operationoperator: 76
operand: 85
72Operationoperator: 78
operand: 86
73Operationoperator: 80
operand: 87
74Operationoperator: 82
operands: 83
75IndexedVarvariable: 92
index: 90
76Literal
77ExprTuple85
78Literal
79ExprTuple86
80Literal
81ExprTuple87
82Literal
83ExprTuple88, 89
84ExprTuple90
85IndexedVarvariable: 92
index: 94
86Variable
87IndexedVarvariable: 92
index: 95
88Literal
89Variable
90Variable
91ExprTuple94
92Variable
93ExprTuple95
94Variable
95Variable