director string
   HOME

TheInfoList



OR:

In
mathematics Mathematics is an area of knowledge that includes the topics of numbers, formulas and related structures, shapes and the spaces in which they are contained, and quantities and their changes. These topics are represented in modern mathematics ...
, in the area of
lambda calculus Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation ...
and
computation Computation is any type of arithmetic or non-arithmetic calculation that follows a well-defined model (e.g., an algorithm). Mechanical or electronic devices (or, historically, people) that perform computations are known as ''computers''. An es ...
, directors or director strings are a mechanism for keeping track of the
free variable In mathematics, and in other disciplines involving formal languages, including mathematical logic and computer science, a free variable is a notation (symbol) that specifies places in an expression where substitution may take place and is not ...
s in a
term Term may refer to: * Terminology, or term, a noun or compound word used in a specific context, in particular: **Technical term, part of the specialized vocabulary of a particular field, specifically: ***Scientific terminology, terms used by scient ...
. Loosely speaking, they can be understood as a kind of
memoization In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. Memoization ...
for free variables; that is, as an
optimization Mathematical optimization (alternatively spelled ''optimisation'') or mathematical programming is the selection of a best element, with regard to some criterion, from some set of available alternatives. It is generally divided into two subfi ...
technique for rapidly locating the free variables in a
term algebra In universal algebra and mathematical logic, a term algebra is a freely generated algebraic structure over a given signature. For example, in a signature consisting of a single binary operation, the term algebra over a set ''X'' of variables is exa ...
or in a lambda expression. Director strings were introduced by Kennaway and Sleep in 1982 and further developed by Sinot, Fernández and MackieF.-R. Sinot, M. Fernández and I. Mackie. [ftp://nozdr.ru/biblio/kolxoz/Cs/CsLn/R/Rewriting%20Techniques%20and%20Applications,%2014%20conf.,%20RTA%202003(LNCS2706,%20Springer,%202003)(ISBN%203540402543)(526s)_CsLn_.pdf#page=57 Efficient Reductions with Director Strings]. In ''Proc. Rewriting Techniques and Applications''. Springer LNCS vol 2706, 2003 as a mechanism for understanding and controlling the
computational complexity In computer science, the computational complexity or simply complexity of an algorithm is the amount of resources required to run it. Particular focus is given to computation time (generally measured by the number of needed elementary operations) ...
cost of
beta reduction Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation t ...
.


Motivation

In beta reduction, one defines the value of the expression on the left to be that on the right: :(\lambda x.E)y \equiv E := y, or (\lambda x.E)y \equiv E /x/math> (Replace all ''x'' in ''E''(body) by ''y'') While this is a conceptually simple operation, the
computational complexity In computer science, the computational complexity or simply complexity of an algorithm is the amount of resources required to run it. Particular focus is given to computation time (generally measured by the number of needed elementary operations) ...
of the step can be non-trivial: a naive algorithm would scan the expression ''E'' for all occurrences of the free variable ''x''. Such an algorithm is clearly ''O''(''n'') in the length of the expression ''E''. Thus, one is motivated to somehow track the occurrences of the free variables in the expression. One may attempt to track the position of ''every'' free variable, wherever it may occur in the expression, but this can clearly become very costly in terms of storage; furthermore, it provides a level of detail that is not really needed. Director strings suggest that the correct model is to track free variables in a hierarchical fashion, by tracking their use in component terms.


Definition

Consider, for simplicity, a
term algebra In universal algebra and mathematical logic, a term algebra is a freely generated algebraic structure over a given signature. For example, in a signature consisting of a single binary operation, the term algebra over a set ''X'' of variables is exa ...
, that is, a collection of free variables, constants, and operators which may be freely combined. Assume that a term ''t'' takes the form :t ::= f(t_1,t_2,\dots,t_n) where ''f'' is a
function Function or functionality may refer to: Computing * Function key, a type of key on computer keyboards * Function model, a structured representation of processes in a system * Function object or functor or functionoid, a concept of object-oriente ...
, of
arity Arity () is the number of arguments or operands taken by a function, operation or relation in logic, mathematics, and computer science. In mathematics, arity may also be named ''rank'', but this word can have many other meanings in mathematics. In ...
''n'', with no
free variable In mathematics, and in other disciplines involving formal languages, including mathematical logic and computer science, a free variable is a notation (symbol) that specifies places in an expression where substitution may take place and is not ...
s, and the t_i are terms that may or may not contain free variables. Let ''V'' denote the set of all free variables that may occur in the set of all terms. The director is then the map :\sigma_t: V\to P(\lbrace 1,2,\dots,n\rbrace) from the free variables to the
power set In mathematics, the power set (or powerset) of a set is the set of all subsets of , including the empty set and itself. In axiomatic set theory (as developed, for example, in the ZFC axioms), the existence of the power set of any set is po ...
P(X) of the set X=\lbrace 1,2,\dots,n\rbrace. The values taken by \sigma_t are simply a list of the indices of the t_i in which a given free variable occurs. Thus, for example, if a free variable x\in V occurs in t_3 and t_5 but in no other terms, then one has \sigma_t(x) = \lbrace 3,5\rbrace. Thus, for every term t\in T in the set of all terms ''T'', one maintains a function \sigma_t, and instead of working only with terms ''t'', one works with pairs (t,\sigma_t). Thus, the time complexity of finding the free variables in ''t'' is traded for the space complexity of maintaining a list of the terms in which a variable occurs.


General case

Although the above definition is formulated in terms of a
term algebra In universal algebra and mathematical logic, a term algebra is a freely generated algebraic structure over a given signature. For example, in a signature consisting of a single binary operation, the term algebra over a set ''X'' of variables is exa ...
, the general concept applies more generally, and can be defined both for
combinatory algebra Combinatory logic is a notation to eliminate the need for quantified variables in mathematical logic. It was introduced by Moses Schönfinkel and Haskell Curry, and has more recently been used in computer science as a theoretical model of comput ...
s and for
lambda calculus Lambda calculus (also written as ''λ''-calculus) is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation ...
proper, specifically, within the framework of
explicit substitution In computer science, lambda calculi are said to have explicit substitutions if they pay special attention to the formalization of the process of substitution. This is in contrast to the standard lambda calculus where substitutions are performed by ...
.


See also

*
Term rewrite system In mathematics, computer science, and logic, rewriting covers a wide range of methods of replacing subterms of a formula with other terms. Such methods may be achieved by rewriting systems (also known as rewrite systems, rewrite engines, or red ...
*
Explicit substitution In computer science, lambda calculi are said to have explicit substitutions if they pay special attention to the formalization of the process of substitution. This is in contrast to the standard lambda calculus where substitutions are performed by ...
*
Memoization In computing, memoization or memoisation is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again. Memoization ...


References

* F.-R. Sinot.
Director Strings Revisited: A Generic Approach to the Efficient Representation of Free Variables in Higher-order Rewriting.
''Journal of Logic and Computation'' 15(2), pages 201-218, 2005. Lambda calculus Rewriting systems Software optimization