logo

Expression of type Lambda

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, IndexedVar, Lambda, T, Variable, k, m
from proveit.logic import Disjoint
from proveit.numbers import Interval, one
In [2]:
# build up the expression from sub-expressions
sub_expr1 = Variable("_b", latex_format = r"{_{-}b}")
sub_expr2 = Variable("_a", latex_format = r"{_{-}a}")
expr = Lambda(sub_expr1, ExprRange(sub_expr2, Disjoint(IndexedVar(T, [sub_expr1, sub_expr2]), Interval(one, k)), 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())
{_{-}b} \mapsto \textrm{disjoint}\left(T_{{_{-}b}, 1}, \{1~\ldotp \ldotp~k\}\right), \textrm{disjoint}\left(T_{{_{-}b}, 2}, \{1~\ldotp \ldotp~k\}\right), \ldots, \textrm{disjoint}\left(T_{{_{-}b}, m}, \{1~\ldotp \ldotp~k\}\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Lambdaparameter: 15
body: 2
1ExprTuple15
2ExprRangelambda_map: 3
start_index: 17
end_index: 4
3Lambdaparameter: 16
body: 6
4Variable
5ExprTuple16
6Operationoperator: 7
operands: 8
7Literal
8ExprTuple9, 10
9IndexedVarvariable: 11
indices: 12
10Operationoperator: 13
operands: 14
11Variable
12ExprTuple15, 16
13Literal
14ExprTuple17, 18
15Variable
16Variable
17Literal
18Variable