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, a, k
from proveit.core_expr_types import a_1_to_k
from proveit.linear_algebra import TensorProd
from proveit.logic import Equals, Forall, InSet
from proveit.numbers import BinarySequence, Bit, NaturalPos, one
from proveit.physics.quantum import Ket, NumKet
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_k], instance_expr = Equals(NumKet(BinarySequence(a_1_to_k), k), TensorProd(ExprRange(sub_expr1, Ket(IndexedVar(a, sub_expr1)), one, k))), domain = Bit), InSet(k, NaturalPos))
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_{k} \in \mathbb{N}^{\leq 1}}~\left(\lvert \texttt{\#}\texttt{b}(a_{1}, a_{2}, \ldots, a_{k}) \rangle_{k} = \left(\lvert a_{1} \rangle {\otimes}  \lvert a_{2} \rangle {\otimes}  \ldots {\otimes}  \lvert a_{k} \rangle\right)\right) \textrm{ if } k \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: 6
2Operationoperator: 29
operands: 5
3Literal
4ExprTuple6
5ExprTuple36, 7
6Lambdaparameters: 27
body: 8
7Literal
8Conditionalvalue: 9
condition: 10
9Operationoperator: 11
operands: 12
10Operationoperator: 13
operands: 14
11Literal
12ExprTuple15, 16
13Literal
14ExprTuple17
15Operationoperator: 18
operands: 19
16Operationoperator: 20
operands: 21
17ExprRangelambda_map: 22
start_index: 35
end_index: 36
18Literal
19ExprTuple23, 36
20Literal
21ExprTuple24
22Lambdaparameter: 42
body: 25
23Operationoperator: 26
operands: 27
24ExprRangelambda_map: 28
start_index: 35
end_index: 36
25Operationoperator: 29
operands: 30
26Literal
27ExprTuple31
28Lambdaparameter: 42
body: 32
29Literal
30ExprTuple39, 33
31ExprRangelambda_map: 34
start_index: 35
end_index: 36
32Operationoperator: 37
operand: 39
33Literal
34Lambdaparameter: 42
body: 39
35Literal
36Variable
37Literal
38ExprTuple39
39IndexedVarvariable: 40
index: 42
40Variable
41ExprTuple42
42Variable