logo

Expression of type Conditional

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 Conditional, ExprRange, IndexedVar, Variable, b, j
from proveit.core_expr_types import A_1_to_l, b_1_to_j
from proveit.logic import And, Equals, Forall, InClass, InSet
from proveit.numbers import Complex, Mult, one
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = Conditional(Forall(instance_param_or_params = [A_1_to_l], instance_expr = Equals(Qmult(b_1_to_j, A_1_to_l), Qmult(Mult(b_1_to_j), A_1_to_l)).with_wrapping_at(2), condition = InClass(Qmult(A_1_to_l), QmultCodomain)), And(ExprRange(sub_expr1, InSet(IndexedVar(b, sub_expr1), Complex), one, j)))
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())
\left\{\forall_{A_{1}, A_{2}, \ldots, A_{l}~|~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}}~\left(\begin{array}{c} \begin{array}{l} \left(b_{1} \thinspace  b_{2} \thinspace  \ldots \thinspace  b_{j}\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) =  \\ \left(\left(b_{1} \cdot  b_{2} \cdot  \ldots \cdot  b_{j}\right)\thinspace A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{l}\right) \end{array} \end{array}\right) \textrm{ if } \left(b_{1} \in \mathbb{C}\right) \land  \left(b_{2} \in \mathbb{C}\right) \land  \ldots \land  \left(b_{j} \in \mathbb{C}\right)\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 3
operand: 7
2Operationoperator: 5
operands: 6
3Literal
4ExprTuple7
5Literal
6ExprTuple8
7Lambdaparameters: 28
body: 9
8ExprRangelambda_map: 10
start_index: 38
end_index: 39
9Conditionalvalue: 11
condition: 12
10Lambdaparameter: 44
body: 13
11Operationoperator: 14
operands: 15
12Operationoperator: 16
operands: 17
13Operationoperator: 18
operands: 19
14Literal
15ExprTuple20, 21
16Literal
17ExprTuple22, 23
18Literal
19ExprTuple41, 24
20Operationoperator: 27
operands: 25
21Operationoperator: 27
operands: 26
22Operationoperator: 27
operands: 28
23Literal
24Literal
25ExprTuple35, 30
26ExprTuple29, 30
27Literal
28ExprTuple30
29Operationoperator: 31
operands: 32
30ExprRangelambda_map: 33
start_index: 38
end_index: 34
31Literal
32ExprTuple35
33Lambdaparameter: 44
body: 36
34Variable
35ExprRangelambda_map: 37
start_index: 38
end_index: 39
36IndexedVarvariable: 40
index: 44
37Lambdaparameter: 44
body: 41
38Literal
39Variable
40Variable
41IndexedVarvariable: 42
index: 44
42Variable
43ExprTuple44
44Variable