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, 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 = [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()
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())
\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}
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneTrue('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: 16
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple5
4Conditionalvalue: 6
condition: 7
5ExprRangelambda_map: 8
start_index: 72
end_index: 73
6Operationoperator: 9
operands: 10
7Operationoperator: 52
operands: 11
8Lambdaparameter: 74
body: 59
9Literal
10ExprTuple12, 13
11ExprTuple14, 15
12Operationoperator: 16
operand: 22
13Operationoperator: 52
operands: 18
14Operationoperator: 29
operand: 24
15Operationoperator: 20
operand: 25
16Literal
17ExprTuple22
18ExprTuple70, 23
19ExprTuple24
20Literal
21ExprTuple25
22Lambdaparameters: 50
body: 26
23Operationoperator: 27
operand: 73
24Operationoperator: 29
operands: 30
25Operationoperator: 31
operands: 32
26Conditionalvalue: 33
condition: 34
27Literal
28ExprTuple73
29Literal
30ExprTuple35
31Literal
32ExprTuple36, 73
33Operationoperator: 37
operands: 38
34Operationoperator: 39
operands: 40
35ExprRangelambda_map: 41
start_index: 72
end_index: 73
36Literal
37Literal
38ExprTuple42, 43
39Literal
40ExprTuple44, 45
41Lambdaparameter: 74
body: 46
42Operationoperator: 47
operands: 48
43Operationoperator: 49
operands: 50
44Operationoperator: 52
operands: 51
45Operationoperator: 52
operands: 53
46Operationoperator: 64
operand: 59
47Literal
48ExprTuple55, 56, 70, 57
49Literal
50ExprTuple78, 79
51ExprTuple78, 58
52Literal
53ExprTuple79, 58
54ExprTuple59
55Operationoperator: 60
operand: 69
56Operationoperator: 62
operand: 70
57Operationoperator: 64
operand: 71
58Operationoperator: 66
operands: 67
59IndexedVarvariable: 76
index: 74
60Literal
61ExprTuple69
62Literal
63ExprTuple70
64Literal
65ExprTuple71
66Literal
67ExprTuple72, 73
68ExprTuple74
69IndexedVarvariable: 76
index: 78
70Variable
71IndexedVarvariable: 76
index: 79
72Literal
73Variable
74Variable
75ExprTuple78
76Variable
77ExprTuple79
78Variable
79Variable