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, Q, f, j, m, n
from proveit.core_expr_types import A_1_to_m, C_1_to_n, Q__b_1_to_j, b_1_to_j, f__b_1_to_j
from proveit.linear_algebra import VecSum
from proveit.linear_algebra.addition import vec_summation_b1toj_fQ
from proveit.logic import And, Equals, Forall, Implies, InClass, InSet
from proveit.numbers import Natural, NaturalPos
from proveit.physics.quantum import Qmult, QmultCodomain
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Qmult(A_1_to_m, vec_summation_b1toj_fQ, C_1_to_n)
expr = Conditional(Forall(instance_param_or_params = [A_1_to_m, C_1_to_n, f, Q], instance_expr = Implies(InClass(sub_expr1, QmultCodomain), Equals(sub_expr1, VecSum(index_or_indices = [b_1_to_j], summand = Qmult(A_1_to_m, f__b_1_to_j, C_1_to_n), condition = Q__b_1_to_j)).with_wrapping_at(1)).with_wrapping_at(2)), And(InSet(j, 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}, C_{1}, C_{2}, \ldots, C_{n}, f, Q}~\left(\begin{array}{c} \begin{array}{l} \left(\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\right]\thinspace C_{1} \thinspace  C_{2} \thinspace  \ldots \thinspace  C_{n}\right) \\  = \left[\sum_{b_{1}, b_{2}, \ldots, b_{j}~|~Q\left(b_{1}, b_{2}, \ldots, b_{j}\right)}~\left(A_{1} \thinspace  A_{2} \thinspace  \ldots \thinspace  A_{m} \thinspace f\left(b_{1}, b_{2}, \ldots, b_{j}\right)\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 } j \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
11ExprTuple43, 45, 49, 46
12Operationoperator: 17
operands: 18
13ExprTuple59, 19
14ExprTuple48, 20
15Literal
16ExprTuple52, 20
17Literal
18ExprTuple21, 22
19Literal
20Literal
21Operationoperator: 23
operands: 24
22Operationoperator: 25
operands: 26
23Literal
24ExprTuple28, 27
25Literal
26ExprTuple28, 29
27Literal
28Operationoperator: 40
operands: 30
29Operationoperator: 34
operand: 33
30ExprTuple43, 32, 45
31ExprTuple33
32Operationoperator: 34
operand: 37
33Lambdaparameters: 50
body: 36
34Literal
35ExprTuple37
36Conditionalvalue: 38
condition: 42
37Lambdaparameters: 50
body: 39
38Operationoperator: 40
operands: 41
39Conditionalvalue: 44
condition: 42
40Literal
41ExprTuple43, 44, 45
42Operationoperator: 46
operands: 50
43ExprRangelambda_map: 47
start_index: 58
end_index: 48
44Operationoperator: 49
operands: 50
45ExprRangelambda_map: 51
start_index: 58
end_index: 52
46Variable
47Lambdaparameter: 64
body: 53
48Variable
49Variable
50ExprTuple54
51Lambdaparameter: 64
body: 55
52Variable
53IndexedVarvariable: 56
index: 64
54ExprRangelambda_map: 57
start_index: 58
end_index: 59
55IndexedVarvariable: 60
index: 64
56Variable
57Lambdaparameter: 64
body: 61
58Literal
59Variable
60Variable
61IndexedVarvariable: 62
index: 64
62Variable
63ExprTuple64
64Variable