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, 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 = [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))
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 \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]
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: 25
operand: 2
1ExprTuple2
2Lambdaparameter: 79
body: 3
3Conditionalvalue: 4
condition: 5
4Operationoperator: 25
operand: 8
5Operationoperator: 61
operands: 7
6ExprTuple8
7ExprTuple79, 9
8Lambdaparameters: 10
body: 11
9Operationoperator: 12
operands: 13
10ExprTuple14
11Conditionalvalue: 15
condition: 16
12Literal
13NamedExprsfield: 45
rows: 82
columns: 82
14ExprRangelambda_map: 17
start_index: 81
end_index: 82
15Operationoperator: 18
operands: 19
16Operationoperator: 61
operands: 20
17Lambdaparameter: 83
body: 68
18Literal
19ExprTuple21, 22
20ExprTuple23, 24
21Operationoperator: 25
operand: 31
22Operationoperator: 61
operands: 27
23Operationoperator: 38
operand: 33
24Operationoperator: 29
operand: 34
25Literal
26ExprTuple31
27ExprTuple79, 32
28ExprTuple33
29Literal
30ExprTuple34
31Lambdaparameters: 59
body: 35
32Operationoperator: 36
operand: 82
33Operationoperator: 38
operands: 39
34Operationoperator: 40
operands: 41
35Conditionalvalue: 42
condition: 43
36Literal
37ExprTuple82
38Literal
39ExprTuple44
40Literal
41ExprTuple45, 82
42Operationoperator: 46
operands: 47
43Operationoperator: 48
operands: 49
44ExprRangelambda_map: 50
start_index: 81
end_index: 82
45Literal
46Literal
47ExprTuple51, 52
48Literal
49ExprTuple53, 54
50Lambdaparameter: 83
body: 55
51Operationoperator: 56
operands: 57
52Operationoperator: 58
operands: 59
53Operationoperator: 61
operands: 60
54Operationoperator: 61
operands: 62
55Operationoperator: 73
operand: 68
56Literal
57ExprTuple64, 65, 79, 66
58Literal
59ExprTuple87, 88
60ExprTuple87, 67
61Literal
62ExprTuple88, 67
63ExprTuple68
64Operationoperator: 69
operand: 78
65Operationoperator: 71
operand: 79
66Operationoperator: 73
operand: 80
67Operationoperator: 75
operands: 76
68IndexedVarvariable: 85
index: 83
69Literal
70ExprTuple78
71Literal
72ExprTuple79
73Literal
74ExprTuple80
75Literal
76ExprTuple81, 82
77ExprTuple83
78IndexedVarvariable: 85
index: 87
79Variable
80IndexedVarvariable: 85
index: 88
81Literal
82Variable
83Variable
84ExprTuple87
85Variable
86ExprTuple88
87Variable
88Variable