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, n
from proveit.logic import Equals
from proveit.numbers import Add, one, subtract, zero
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_a", latex_format = r"{_{-}a}")
expr = ExprTuple(Equals(IndexedVar(N, zero), zero), ExprRange(sub_expr1, Equals(IndexedVar(N, sub_expr1), Add(IndexedVar(N, subtract(sub_expr1, one)), IndexedVar(n, sub_expr1))), one, m))
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(N_{0} = 0,\left(N_{1} = \left(N_{1 - 1} + n_{1}\right)\right), \left(N_{2} = \left(N_{2 - 1} + n_{2}\right)\right), \ldots, \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
1Operationoperator: 9
operands: 3
2ExprRangelambda_map: 4
start_index: 28
end_index: 5
3ExprTuple6, 11
4Lambdaparameter: 24
body: 7
5Variable
6IndexedVarvariable: 17
index: 11
7Operationoperator: 9
operands: 10
8ExprTuple11
9Literal
10ExprTuple12, 13
11Literal
12IndexedVarvariable: 17
index: 24
13Operationoperator: 22
operands: 14
14ExprTuple15, 16
15IndexedVarvariable: 17
index: 21
16IndexedVarvariable: 19
index: 24
17Variable
18ExprTuple21
19Variable
20ExprTuple24
21Operationoperator: 22
operands: 23
22Literal
23ExprTuple24, 25
24Variable
25Operationoperator: 26
operand: 28
26Literal
27ExprTuple28
28Literal