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 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, 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 = [v_1_to_n, w_1_to_n], instance_expr = InSet(VecSum(index_or_indices = [i], summand = Qmult(Ket(v_i), Bra(w_i)), domain = Interval(one, n)), Unitary(n)), conditions = [InSet(Set(v_1_to_n_kets), sub_expr1), InSet(Set(w_1_to_n_kets), sub_expr1)]).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}, 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(\left(\sum_{i=1}^{n} \left(\lvert v_{i} \rangle \thinspace \langle w_{i} \rvert\right)\right) \in \textrm{U}\left(n\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: 1
operand: 3
1Literal
2ExprTuple3
3Lambdaparameters: 4
body: 5
4ExprTuple6, 7
5Conditionalvalue: 8
condition: 9
6ExprRangelambda_map: 10
start_index: 63
end_index: 64
7ExprRangelambda_map: 11
start_index: 63
end_index: 64
8Operationoperator: 41
operands: 12
9Operationoperator: 13
operands: 14
10Lambdaparameter: 77
body: 72
11Lambdaparameter: 77
body: 73
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Operationoperator: 19
operand: 25
16Operationoperator: 21
operand: 64
17Operationoperator: 41
operands: 23
18Operationoperator: 41
operands: 24
19Literal
20ExprTuple25
21Literal
22ExprTuple64
23ExprTuple26, 28
24ExprTuple27, 28
25Lambdaparameter: 71
body: 29
26Operationoperator: 44
operand: 36
27Operationoperator: 44
operand: 37
28Operationoperator: 32
operand: 38
29Conditionalvalue: 34
condition: 35
30ExprTuple36
31ExprTuple37
32Literal
33ExprTuple38
34Operationoperator: 39
operands: 40
35Operationoperator: 41
operands: 42
36Operationoperator: 44
operands: 43
37Operationoperator: 44
operands: 45
38Operationoperator: 46
operands: 47
39Literal
40ExprTuple48, 49
41Literal
42ExprTuple71, 50
43ExprTuple51
44Literal
45ExprTuple52
46Literal
47ExprTuple53, 64
48Operationoperator: 69
operand: 61
49Operationoperator: 55
operand: 62
50Operationoperator: 57
operands: 58
51ExprRangelambda_map: 59
start_index: 63
end_index: 64
52ExprRangelambda_map: 60
start_index: 63
end_index: 64
53Literal
54ExprTuple61
55Literal
56ExprTuple62
57Literal
58ExprTuple63, 64
59Lambdaparameter: 77
body: 65
60Lambdaparameter: 77
body: 66
61IndexedVarvariable: 74
index: 71
62IndexedVarvariable: 75
index: 71
63Literal
64Variable
65Operationoperator: 69
operand: 72
66Operationoperator: 69
operand: 73
67ExprTuple71
68ExprTuple72
69Literal
70ExprTuple73
71Variable
72IndexedVarvariable: 74
index: 77
73IndexedVarvariable: 75
index: 77
74Variable
75Variable
76ExprTuple77
77Variable