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 B, Conditional, ExprRange, IndexedVar, Variable, i, m, n
from proveit.core_expr_types import A_1_to_m, B_1_to_i, C_1_to_n
from proveit.linear_algebra import VecAdd
from proveit.logic import And, Equals, Forall, Implies, InClass, InSet
from proveit.numbers import Natural, NaturalPos, one
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Qmult(A_1_to_m, VecAdd(B_1_to_i), C_1_to_n)
expr = Conditional(Forall(instance_param_or_params = [A_1_to_m, B_1_to_i, C_1_to_n], instance_expr = Implies(InClass(sub_expr2, QmultCodomain), Equals(sub_expr2, VecAdd(ExprRange(sub_expr1, Qmult(A_1_to_m, IndexedVar(B, sub_expr1), C_1_to_n), one, i))).with_wrapping_at(2)).with_wrapping_at(2)), And(InSet(i, NaturalPos), InSet(m, Natural), InSet(n, Natural)))
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_{m}, B_{1}, B_{2}, \ldots, B_{i}, C_{1}, C_{2}, \ldots, C_{n}}~\left(\begin{array}{c} \begin{array}{l} \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left(B_{1} +  B_{2} +  \ldots +  B_{i}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \underset{{\scriptscriptstyle c}}{\in} \mathcal{Q^*}\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left(B_{1} +  B_{2} +  \ldots +  B_{i}\right)\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) =  \\ \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace B_{1}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) +  \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace B_{2}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) +  \ldots +  \left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace B_{i}\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right)\right) \end{array} \end{array}\right) \end{array} \end{array}\right) \textrm{ if } i \in \mathbb{N}^+ ,  m \in \mathbb{N} ,  n \in \mathbb{N}\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, 9, 10
7Lambdaparameters: 11
body: 12
8Operationoperator: 15
operands: 13
9Operationoperator: 15
operands: 14
10Operationoperator: 15
operands: 16
11ExprTuple44, 37, 46
12Operationoperator: 17
operands: 18
13ExprTuple40, 19
14ExprTuple48, 20
15Literal
16ExprTuple53, 20
17Literal
18ExprTuple21, 22
19Literal
20Literal
21Operationoperator: 23
operands: 24
22Operationoperator: 25
operands: 26
23Literal
24ExprTuple28, 27
25Literal
26ExprTuple28, 29
27Literal
28Operationoperator: 41
operands: 30
29Operationoperator: 34
operands: 31
30ExprTuple44, 32, 46
31ExprTuple33
32Operationoperator: 34
operands: 35
33ExprRangelambda_map: 36
start_index: 52
end_index: 40
34Literal
35ExprTuple37
36Lambdaparameter: 55
body: 38
37ExprRangelambda_map: 39
start_index: 52
end_index: 40
38Operationoperator: 41
operands: 42
39Lambdaparameter: 60
body: 43
40Variable
41Literal
42ExprTuple44, 45, 46
43IndexedVarvariable: 49
index: 60
44ExprRangelambda_map: 47
start_index: 52
end_index: 48
45IndexedVarvariable: 49
index: 55
46ExprRangelambda_map: 51
start_index: 52
end_index: 53
47Lambdaparameter: 60
body: 54
48Variable
49Variable
50ExprTuple55
51Lambdaparameter: 60
body: 56
52Literal
53Variable
54IndexedVarvariable: 57
index: 60
55Variable
56IndexedVarvariable: 58
index: 60
57Variable
58Variable
59ExprTuple60
60Variable