logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.circuits

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 ExprRange, ExprTuple, IndexedVar, N, Variable, m
from proveit.logic import InSet
from proveit.numbers import Natural, zero
from proveit.physics.quantum.circuits import each_Nk_is_partial_sum
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(ExprRange(sub_expr1, InSet(IndexedVar(N, sub_expr1), Natural), zero, m), each_Nk_is_partial_sum)
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(\left(N_{0} \in \mathbb{N}\right), \left(N_{1} \in \mathbb{N}\right), \ldots, \left(N_{m} \in \mathbb{N}\right), \left(N_{0} = 0\right)\land \left(N_{1} = \left(N_{1 - 1} + n_{1}\right)\right) \land  \left(N_{2} = \left(N_{2 - 1} + n_{2}\right)\right) \land  \ldots \land  \left(N_{m} = \left(N_{m - 1} + n_{m}\right)\right)\right)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1ExprRangelambda_map: 3
start_index: 20
end_index: 13
2Operationoperator: 4
operands: 5
3Lambdaparameter: 33
body: 6
4Literal
5ExprTuple7, 8
6Operationoperator: 9
operands: 10
7Operationoperator: 18
operands: 11
8ExprRangelambda_map: 12
start_index: 37
end_index: 13
9Literal
10ExprTuple21, 14
11ExprTuple15, 20
12Lambdaparameter: 33
body: 16
13Variable
14Literal
15IndexedVarvariable: 26
index: 20
16Operationoperator: 18
operands: 19
17ExprTuple20
18Literal
19ExprTuple21, 22
20Literal
21IndexedVarvariable: 26
index: 33
22Operationoperator: 31
operands: 23
23ExprTuple24, 25
24IndexedVarvariable: 26
index: 30
25IndexedVarvariable: 28
index: 33
26Variable
27ExprTuple30
28Variable
29ExprTuple33
30Operationoperator: 31
operands: 32
31Literal
32ExprTuple33, 34
33Variable
34Operationoperator: 35
operand: 37
35Literal
36ExprTuple37
37Literal