Научная статья на тему 'Non-standard reductions and categorical models in typed lambda-calculus'

Non-standard reductions and categorical models in typed lambda-calculus Текст научной статьи по специальности «Математика»

CC BY
53
40
i Надоели баннеры? Вы всегда можете отключить рекламу.
Журнал
Логические исследования
ВАК
zbMATH
Область наук

Аннотация научной статьи по математике, автор научной работы — Barral F., Chemouil D., Soloviev S.

We consider the problem of incorporation of new computational rules in lambda calculus with inductive types and recursion. We consider the extensions of standard reduction systems by certain new reductions preserving strong normalization and Church-Rosser property with possible applications to proof assistants and computer algebra systems.

i Надоели баннеры? Вы всегда можете отключить рекламу.
iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.
i Надоели баннеры? Вы всегда можете отключить рекламу.

Текст научной работы на тему «Non-standard reductions and categorical models in typed lambda-calculus»

F. Barral, D. Chemouil, S. Soloviev

NON-STANDARD REDUCTIONS AND CATEGORICAL MODELS IN TYPED LAMBDA-CALCULUS

Abstract. We consider the problem of incorporation of new computational rules in lambda calculus with inductive types and recursion. We consider the extensions of standard reduction systems by certain new reductions preserving strong normalization and Church-Rosser property with possible applications to proof assistants and computer algebra systems.

Абстракт. Рассматривается проблема добавления новых правил вычисления к лямбда-исчислению с индуктивными типами и рекурсией. Рассматриваются расширения стандартных систем редукции при помощи новых редукций, сохраняющих строгую нормализацию и свойство Черча-Россера. Эти расширения имеют возможные приложения в областях компьютерных помощников поиска доказательств и систем компьютерной алгебры.

1. Introduction

Computational power of untyped lambda-calculus is sufficient to represent any partial recursive function. One of obvious drawbacks is that some basic questions (like termination) are undecidable. Nowadays more and more attention is paid to various systems of typed lambda-calculi since typing provides greater safety. In "non-pathological" systems, computation represented by well-typed term always terminates.

Another positive aspect of typed calculi in comparison with untyped case is due to so called "proofs as programs paradigm". The type of a term can be considered as logical formula and the term represents its proof. At the same time it can be considered as a program. This explains why typed lambda-calculi are often used in modern proof-assistants. In perspective, this is one of possible ways to unification of proof and computation.

Of course, typing doesn't resolve all the difficulties. One of them is that the representation of real computations in lambda-calculus including only the fundamental term and type constructors (application and abstraction for terms, functional arrow for types) is very indirect, it is in fact complex coding, satisfactory for theoretical results but lacking directness and transparency required for efficient applications. Extensions of typed systems with "real-life" inductive types like natural

numbers, lists, trees and corresponding functional constants and recursion operators are helpful but not sufficient. Mathematics computations are seldom represented in the form of recursive functions even if they are fully constructive.

Symbolic computations, for example, often include the transformations of symbolic expressions that were never studied from the point of view of properties of corresponding rewriting system. The importance of the problem of certified computation, symbolic or numerical (i.e., computation that is completed with the proof of its correctness) was emphasized several years ago in [4] but it was studied since in very limited number of cases.

The possibility usually provided by proof-assistants based on type theory is to obtain a proof-term that represents the proof of equality of two terms representing computations. This term should be carried everywhere the equality should be used, and this turns out to be very heavy and inefficient.

One of the reasons is that the system of reductions of terms incorporated in the underlying typed lambda-calculus is very restrictive. Because of this even very simple equalities used routinely very often require the proof-term corresponding to this equality to be carried around. It may require quite complex manipulations if the equality is used within another computation.

The approach we are studying in this paper is based on extension of the systems of reductions preserving good properties of the reduction system as a whole. Such properties as Strong Normalization (SN) and Church-Rosser property, or confluence (CR) need to be proved only once. Afterwards the use of the lambda-calculus may follow similar schema: some equalities are proved by reduction (this is much more efficient) and for some others we need to find a proof-term, but the classes of these "intensional" and "extensional" equalities are different, we have more "intensional" equalities. As result the transparency and efficiency of a system may be improved.

In this paper we consider several model cases of extensions of reduction systems in the calculus that doesn't contain the type Prop and terms representing proofs, i.e., we concentrate on the computational part. This permits to simplify the technical side of the presentation. The calculus under consideration is simply typed lambda-calculus with inductive types.

Three cases are considered:

- the notion of a copy of inductive type and the reductions necessary to make it an isomorphism (it is not an isomorphism w.r.t. standard system of reductions and this complicates a lot the handling of copies of inductive types);

- the reductions to incorporate into lambda-calculus certain algebraic structures, such as groups of permutations;

- functoriality of the schema of inductive type (a schema of parameterized inductive type, like List(A), does not represent a functor w.r.t. standard reductions).

The aim of this paper is to present an approach that would help to bring closer proof and computation. The results concerning functo-riality are completely new, the results concerning copy and groups of permutations were partly published (see [5], [9]).

2. Simply-typed lambda-calculus with inductive types

We will consider infinite sets of constructor name (Const), term variables (Var) and type variables (Tvar), with ConstnVar = ConstnTvar = VarnTvar = 0. We will reserve the letters x, y and z for term variables, a and p for type variables, r, s, t and u for arbitrary terms, p and t for arbitrary types, and k for constructor schemas. The letters i, j, k, l will only be used for indexes and, respectively, n, m, p, q for their upper bound. Finally, constructor names will be denoted either by ci, c2, ..., c'i, c'2... or by the generic name in. Definitions will be introduced by the symbol =def , as in id =def A,xT .x. Terms and types will be considered up to a-congruence (that is, the names of bound variables are meaningless) and this last relation will be denoted = , thus one has A,xT.x =A,y:T .y. Sequences of types or terms (ti)i=1,n will be written as t1+n. Using this notation we will sometimes write p1+n^T to mean pi^...^pn^-T, associated to the right. Furthermore, set1+n will mean that there is an i such that s^ti, and ti+ne S will mean that all the ti' s belong to the set S. Finally, if some indexes depend on other ones, we shall write j(i), and tj(1+n) will stand for tj(1),., tj(n). We will also need the notion of "curried" composition: for given lambda-terms f: p1+n^T and g:T^u, gof will be defined as A,z1+n:p1+n.g(fz1+n), with z1+ngFV(g) and z1+ngFV(f). We shall also use the following notation, provided of course that f and g are of suitable types: gf gof if f and g are composable, gf if they are not, but g can be applied to f.

Definition 1. (Prototypes.) The grammar of prototypes is defined as follows:

T::=a|T^T|^a(c1+n:T1+n), with aeTvar.

Definition 2. (Types). We define simultaneously: The set Ty of types:

ueTvar p,TeTy c1+n eConst;aeTvar;Ki+„e Sch(a)

ueTy p^TeTy ^,a(c1+n:K1+n)eTy

and the set Sch(a)of constructor schemas over type variable a :

Pl+m

As usual, constructor names can only belong to one inductive type. Thus, an inductive type is also defined by names of its constructors. Remarks:

An inductive type is a recursive type built from a sequence of (constructor) schemas.

Every schema Kk over a is of the form p1+m^(CT1,1+](1)^a)^ ..^(anj1+](n)^a)^a and each premise is called an operator over a. The number of operators in a schema is denoted ar(Kk) (arity). We write nbP(Kk)=m for the number of p's and nbR(Kk )=n for the number of operators (a^^^-a), thus we have ar(Kk) = nbP(Kk) + nbR(Kk ) = n+m.

The p's and ct's are in Ty, which implies they don't contain any free type variable. They are called parameter types. The occurrences belonging to p1+m are called covariant and to ct1,1+](1) ,..., an,1+](n) contravariant. The fact that they don't contain any free type variable implies also that the only occurrences of a are those explicitly shown and a occurs only strictly positively in the operators of the schema. The operators containing a are recursive (correspond to "recursive calls"). if the list CTi,1+](i) is empty, such operator is called 0-recursive otherwise 1-recursive (by analogy with the functionals of types 0 and 1 in Godel's system T). By definition of schemas, parameter types can only occur at the beginning of the schema: this restriction is useful for technical reasons, most notably for the typing of recursors and the definition of their computation rules. it will be clear to the reader that this is a minor restriction which does not impair the system at all.

Example 1. With the rules for inductive types described above, it is

possible to define the types of natural numbers, of Brouwer's ordinals

and of lists of natural numbers:

Nat =def ^a[0:a, succ:a^a]

Ord =def ^a[0ord:a, succord:a^-a, lim: (Nat^a)^a]

List(Nat) =def ^a[nil:a, cons: Nat^a^a]

Note that every inductive type t generates a recursor (or structural-recursion operator) to any type This is explained below.

Definition 3. (Terms). The set of terms is generated by the following grammar (with xe Var, keN\{0} and t, ^eTy ):

t::= x | ^xt t | (t t ) | ink1 | (| t^ ir Here ink1 is the k-th constructor of the inductive type ^ (in practice, we actually have constructor names ce Const) and (|t1+n |)^'x is a recursor (or structural recursion operator) from ^ to another type t.

Definition 4. (Step type.) Given inductive type(s) ^ = ^,a(c1+n:Ki+n) and a result type t, we define for every

Kk — p1+m —(CT1,H(1)—a)—...—(On^jn—a^a in Sch(a) the step type

— pi+m—(CT1,H(1)—M.)—. • • —(On,H(n)—^ —(®1,H(1)—T)—... ^(On,1^(n) —-T)—-T

Definition 5. (Typing.) We define the following typing rules of the calculus:

_(Var)

r, x:t |- x:t

r, x:p |- t:T r |- t:p—-T r|- u:p

-(Lambda) -(App)

r |- A,x:p.t:p—-T r |- (t u ):t

ce Const r |- t1+n : 51+n

-(In) -(Rec)

r |- ck : KkM r |- (|t1+n

Sometimes for typographical reasons we shall write types of variables as superscripts.

Reduction. We take most of our terminology and notation in [2]. Given a binary relation R on a set A, we will denote the induced rewrite relation —but shall sometimes write R for —and vice-versa. We will respectively write —*R, —R, and =R for its transitive, reflexivetransitive and reflexive-symmetric-transitive closures. Sometimes we may write R*, R+ and R=. We say that a term t rewrites to u if there is a term u such that t—R u and it reduces to u if there is a derivation t—R+ u. The union RuS of binary relations on the same set will be denoted RS. We also write R;S for the set {(r,s) | 3t. rRtAtSs}. A term is in normal form if it is not rewriteable. A rewrite relation R is strongly normalizing (terminating) is there is no infinite derivation t1—R t2 —r..., for any term t1.

Given two rewrite relations R and S: R commutes with S if *Rc —*R; —S, R commutes strictly locally over S if -Rc

—r;

This definition is made in [8], and by R. Di Cosmo in [9] to state Akama - Di Cosmo's lemma under the name of (DPG) condition (see lemma 1 below).

A relation R is confluent (resp. locally confluent) if it commutes (resp. commutes locally) with itself. A strongly normalizing and confluent relation is said convergent. We will also write R/S to represent the quotient of a relation R by the reflexive-symmetric-transitive closure of S.

The usual notion of substitution is written t{u/x} to mean that u replaces every free occurrence of x in t, avoiding capture. Finally, as usual in this kind of work, we will consider contexts, written C[], that is, terms with a "hole" inside which can be filled (giving for example C[(AxT.p)q].

Definition 6. (P-conversion.) We define the relation of p-conversion by the following rule: (P).(AxT.t)u—P t{u/x}.

Definition 7. (n-conversion.) We define n-conversion by the following rule (n) t—^n AxTtx if t of type T—u is not in applicative position, does not begin with A and x gFV(t).

(This rule is also called n-expansion and is known to be more convenient for categorical applications than n-reduction oriented in opposite way.)

Definition 8. (i-conversion.) Let ^=^a(c1+n:Ki+n), and Kk= p1+m —(CT1,1+j(1)—a)—...— (CTn,1+](n)—a)—a over a in Let v1+m:p1+m and u1+n with uiR: ai1+](i)—^, for any 1< i <n. Then, we define i-reduction by the rule

(i) (| t D^k (v1+m , u1+n) —i tk (v1+m, u1+n , ((| t1+p |f T • u1+n)). Remark 1. Recall that gf is just an abbreviation. Hence, we may describe i-reductions as (|t1+p D^in^ (v1+m , u1+n)—i tk (v1+m, u1 +n 9 1+n (u1+n)) where

Ai(ui) = (|t1+p |)^'x ui if uiR (i.e., uiR is 0-recursive), and Ai(ui) = (|t1+p |)^'x o ui if ui : CTi,1+](i)—^ (i.e., ui is 1-recursive).

Example 2. If we take the type of Brouwer's ordinals, Ord =def ^a[0ord:a, succord:a—a, lim: (Nat—a)—a], then, given some type t (the type of result), the step types corresponding to 0ord, succord and lim will be respectively t, Ord—T—T and (Nat—Ord)—(Nat—T) — t, the recursor will be of the form (|t1,t2,t3|) with t1:T, t2:Ord—T—T, t3:(Nat—Ord)—(Nat—T) — t and the i-reduction will take the following forms:

(|t1,t2,t3|) 0ord —i t1, (|t1,t2,t3|) succord(uO —i (t2 u1)((|t1,t2,t3|)u1), (|t1,t2,t3|) lim (u2) —i (t3 u2) ((|t1,t2,t3|) o u2) = (t3

(AxNat.((|t1,t2,t3|)(u2xNat))

(here u1:Ord, u2:Nat — Ord).

The A-calculus thus defined, together with Pni-conversion, is called pni.

In the rest of this paper, we will often omit type indications, except for abstracted variables, to lighten the notation.

3. Main results

3.1. Copy

Let us consider the type ^ = ^a[c1:o1,1+j(1)— a, ... cp: op,1+j(p) — a].

An exact copy of this type differs only by names of introduction operators, e.g., ^ ' with introduction operators c'1+p. It is faithful or isomorphic copy of ^ if some of the parameters n are replaced by isomorphic types n'.

Remark 2. The types n and n ' are isomorphic if there exist f: n — n' and f: n'— n such that f of and fof can be reduced to idn, idn respectively. In this case we write f:n n': f.

In general we call "copy" of ^ any type that differs by names of introduction operators and some parameters n are replaced by n' with f: n — n' and f: n'—n, but it is no more required that f, f were mutually inverse.

Let one occurrence of n into = ^,a[ c1:o1,1+j(1)— a, ... cp: op,1+j(p)— a] be fixed and be a copy of ^ such that the occurrence of n is replaced by n' (other changes concern only the names of introduction operators). We shall consider only the case when n occurs as a parameter type. Assume that it is given f: n —n' when the occurrence is covariant and f: n'— n it is contravariant. The function Cp(f): is

defined as (| t1+p|) where the terms t1,..., tp are defined in the following way.

We shall note by f r the application fr if r:n or r:n' corresponds to an occurrence to be replaced and r otherwise. Similarly, we shall write g o f for g o f if g has n or n' as its domain and for g otherwise.

Let us consider the introduction operator ci :oi,i+j(i)— We may assume that oi,i+j(i)— ^ = n1+k (n1,1+n(1) —

(nm,1+n(m) (with l premises of the form

We define:

—T.ci'(f x)r(s o f).

Example 3. Take again the type of Brouwer's ordinals and let f: Nat'— Nat. We have Cp(f) — (| tM|), t1 — 0'orf, t2 — tyOrd. ^uOrd' .succ'OTd(u), t3 — \z Nat—Ord lvNat—Ord' .lim'(v o f).

When f is an isomorphism with inverse f1, the function Cp(f) is an extensional isomorphism in the sense that for every canonical element e of type ^ (constant term containing only c1,..., cp) Cp(f-1 )(Cp(f) e)— pni e. One of main motivations to study non-standard reductions and their properties was for us the fact that within standard system of reductions Pnv many equalities are only extensional, for example Cp(f-1 ) o Cp(f) does not reduce to id^ or, equivalently, Cp(f-1 )(Cp(f) x) does not reduce to x if x is a variable, so, in practice, we have either to carry

everywhere proof-term or we cannot verify the equalities before some constant value is called.

This will be the case even if we take f to be identity. For example, the composition of Cp(id) for Ord = ^a[0ord:a, succord:a—a, lim: (Nat—a)—a] and Ord'=^a[0'ord:a, succ'ord:a—a, lim': (Nat—a)—a] will not be reducible to idOrd= AxOrd.x. In fact the term (| t'1+3|) ((| t1+3|)x) will be Pni-normal.

Meanwhile, as the results below show, reductions can be added to Pni to make the resulting system SN and CR.

Definition 9. (x-reduction.) Let f be an isomorphism and f-1 its inverse. The x-rewriting rule is defined by (X1) Cp(f1)(Cp(f)r)—x r (X2) Cp(f1)(Cp(f)r)—x r, where it is supposed that f and f-1 act at the same occurrence of parameter of some inductive type ^ and its faithful copy r is arbitrary term.The x-reduction is its contextual closure.

For lambda-calculus with inductive types considered in this paper the following theorem holds: Theorem 1. The Pnix reduction is SN and CR.

The detailed proof of this theorem may be found in [5]. Here we rather would like to discuss in more concrete way than before the specifics of the proofs of SN and CR for the extensions of reduction systems of the type we consider in this paper, both its technical and conceptual aspect.

The proof of SN for Pnix reduction uses some standard lemmas, first of all, the Akama - Di Cosmo Lemma:

Lemma 1. Let R and S be two convergent relations, such that R preserves S-normal forms. Then RS is convergent if R commutes strictly locally over S. [1, 8].

Standard techniques are sufficient to prove convergence of Pni part. To prove SN property in theorem 1 we need some more definitions and lemmas.

Definition 10. (Adjournment.) Given two binary relations R and S, S is adjournable w.r.t. R if S; R c R, (RS)*.

Lemma 2. (Adjournment lemma.) Given two strongly normalizing relations R and S, RS is strongly normalizing if S is adjournable w.r.t. R. Proofs of (variants of) this lemma can be found in literature [1, 3, 7, 8]. A subtle point in the proof of SN for Pnix is that there are cases when the adjournment lemma can be used only on condition that certain 1-recursive arguments of i-redex are n-expanded. The idea is therefore to

insert suitable n-expansions in a term before x-conversion, so that the adjournment remains possible.

Definition 11. (Conditional adjournment.) Let R and S be some reduction relations and P be a predicate on terms. Then S is adjournable w.r.t. R under condition P if VtVt'Vt''. P(t)A t — S t'A t'—R t'' ^ 3 u.

t—R u —*RS t''.

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

Definition 12. (Realization.) Let T be a reduction relation, P be a predicate on terms and t some term. Then T realize P for t if 3 t'. t—*T t'A P(t'). It will be said that T realizes P if this is true for every term t. Definition 13. (Insertability.) Let U, T be two reduction relations and Q a binary relation on terms. Then T is insertable in U w.r.t. S if:

- Tc U,

- If t1 Q t2 and t1—>{U\T}t1' then there exists t2' such that t2—+U t2' and

t1' Q t2', *

- If t1 Q t2 and t1—Tt1' then there exists t2' such that t2—*U t2' and t1'

Q t2'

Lemma 3. (Insertion.) Let U, T be two reduction relations and Q a binary relation such that:

- T is insertable in U w.r.t. Q,

- T is SN.

Then for every infinite sequence of U-reductions u beginning at the term t, and every T-reduction t—T t' such that t' Q t there exists an infinite sequence of U-reductions that has as its first step t—T t'.

The principal idea of insertion and insertion lemma is that we can add necessary reductions and preserve infinite sequences of reductions if they exist. This is useful for the proofs of strong normalization "ad absurdum". In the proof of theorem 1 this lemma is used with n-expansions as T, the whole Pnix as U, and the relation of n-reduction inverse to n-expansion as Q.

Lemma 4. (Pre-adjusted adjournment.) Let R, S, T be reduction relations, Q a binary relation and P a predicate on terms such that:

- Tc R,

- R is SN,

- S is SN,

- T realizes P,

- S is adjournable w.r.t. R under condition P,

- T is insertable into RS w.r.t. Q. Then RS is SN.

This lemma is used in the setting similar to lemma 3, with P(t) meaning that the term t is in n-expanded form. T corresponds to n-expansion.

These lemmas are sufficient to prove SN property.

The proof of CR property (confluence) is based on routine check of possible critical pairs.

The following example shows how the notion of copy may be used to define easily interesting data structure.

Example 4. In type theory the (easily defined) embeddings of Nat into Nat are used to define even and odd numbers. In the definition of even numbers 0 is mapped to 0, 1 to 2 etc., and in case of odd numbers 0 is mapped to 1, 1 to 3... In fact, to make this definition "clean" the copies of Nat should be used. Let us note these copies by Nat', Nat''. Let E: Nat'—Nat and O: Nat''— Nat be corresponding embeddings. We have also Cp': Nat—Nat' and Cp'': Nat—Nat'' (there is no change of parameter, so there is no parameter f in Cp', Cp''). Combining E, O, Cp' and Cp'' we can now iterate the whole construction: E Cp' E Nat ^ Nat' ^ Nat ^ ... Cp'' Ot Cp't Ot — Nat — Nat'' Nat^ t t Cp'' t —Nat

t

and within this structure define all subtypes of Nat defined via divisibility by 2n.

3.2. Algebraic Structures

In this part we consider the extensions of reduction systems used to provide good representation of algebraic structures on finite types.

Finite set |n| = {1,..., n} will be represented by the type n = def ^a(cn1:a,..., cnn:a) (of course many representations that differ only by the names of the constructors are possible).

To every function f: |n|— |m| corresponds a term f:n— m of the form (|cmf(1),..., cmf(n) |) where m is ^a(cm1:a,..., cmm:a). Note that the terms f are normal.

We considered two problems concerning finite types and terms f : (a) What categorical structure can be introduced on this calculus and (b) what can be done to represent symmetric group using finite types and corresponding representation of permutations.

The difficulty in type theory as usual is that w.r.t. standard reductions one doesn't for example have g(f r) =Pni (g o f) r for arbitrary term r.

Definition 14. We define u-rewriting by

g(fr) —u (g_of) r and u-reduction as its contextual closure.

The u-reduction is thus defined for all recursors in normal form representing the applications f: |n|— |m|, g: |m|— |p|. It is supposed, of course, that "externally" the functions f and g are known. Theorem 2. The Pniu reduction is SN and CR.

The proof of this theorem uses essentially the same lemmas as in case of copy (the details may be found in [5], cf. also [6, 9]).

Categorical structure. As soon as the u-reduction is integrated in the calculus, it becomes possible to define categorical structure on this calculus, in the following way:

- the objects are the types representing |n| for all neN (let us recall that there is infinitely many of them because the names of the constructors may be different);

- the arrows between n and m are the equivalence classes modulo Pniu of the recursors f : n—m for every f: |n|—|m|.

One may consider ida,=def (|cn1,..., cnn |), one of many representations (associated with n ) of the identity map on |n|. Let us recall that one has also idn_= A,xnx . This term doesn't belong obviously to the categorical structure described above. It may be noticed that the reduction of id^, to idn is not necessary for the categorical construction described above because it would lead us outside this categorical structure and, moreover, one already has f o idn * f *jdQ o f. This is a case when in certain categorical structures within A-calculus the term chosen to represent identity is not necessarily of the form Ax.x .

Interaction with the copies. The results concerning u-reduction presented above didn't take into account copies and x-reduction. In fact when the x-reduction is added, the identification of id^ and idn =_A,xax may be necessary, since with x-reduction the following critical pair appears. Let us take Cp: n—n' and Cp':nl—n (the copy map without change of parameter). We'll have:

id^x Cp'(Cp x) —x x To avoid non-confluence one can add the following new reduction rule. Definition 15. (ra-reduction.) The ra-rewriting relation is defined by:

idnr—ra r for every ne N and term r and ra-reduction relation is its contextual closure. Theorem 3. The Pniux reduction is SN and CR.

Group structure. Now we consider only the case of f: |n|—|n| associated term representation f: n—n. The set of (equivalence classes of) these terms, in presence of u-reduction, may be considered as a representation of symmetric group, i.e., the group of permutations of the set {1,..., n}. But the groups are often defined in mathematics using

generators and relations, and it is natural to ask, if there is any connection between this definition and the notion of normal form used in lambda-calculus. The normal forms w.r.t. Pniu-reduction have little to do with generators-and-relations representation of symmetric group. But instead of u-reduction we may consider reductions going in opposite direction, i.e., "splitting" f into composition.

It is well known that every permutation f: |n|—>|n| can be represented as a product of disjoint cycles.

More precisely, f is called cycle if there exists some subset (ii,..., ik}e (1,..., n} such that f(ii) = i2,..., f(ik-i) = ik, f(ik) = ii and f(i) = i if ig(ii,..., ik}.

Two cycles are disjoint if the corresponding sets (ii,..., ik} and (ji,..., ji} have no common elements.

Product in Sn is represented by functional composition of permutations.

If f: |n|—|n| then f = fi o ... fm where fi,..., fm are disjoints cycles and the cycles that appear in the product are unique.

Product (composition) of disjoint cycles is commutative but it is possible to order cycles (for example, lexicographically) and to have for every f unique decomposition f = fi o ... fm with fi<... < fm . This suggests to study the conversion f r — fi ( ... (fm r)..) instead of — where f : |n| — |n| and fi,..., fm are disjoints cycles of the unique decomposition of f.

Definition 16. The u'-rewriting is defined by

f r — fi ( ... f r)..) for every permutation f : |n|— |n|, with n> 2, where f is decompose in m>2 pairwise disjoint cycles. The u'-reduction is defined as its contextual closure.

Theorem 4. Pniu reduction is SN and CR.

(See [5], [9])

3.3. Functoriality of schemas

In this part we consider most recent results obtained by Freiric Barral. These results concern more general categorical structures in lambda-calculus with inductive types.

When a schema of inductive type ^ = ^a[in1:o1,1+J(1)— a, ... inp: op,H(p) — a] is given, to everybody familiar with category theory it suggests the question of functoriality of this schema w. r. t. its parameters. Assume that for every choice of parameters the names of introduction operators are fixed. The choice of parameters may be limited in advance by some set of possible values.

In fact, since many categorical structures (with types as objects) were considered on the fragments of lambda-calculus, it may be the set of objects of one of such syntactic categories.

For example, it could be certain set of types of the form n.

It may be also that only some functions f: n—n' are admitted (are considered as morphisms of the underlying category).

If we want to define a functor using the schema of inductive type, it is natural to take as its values on objects the types corresponding to the values of parameter. For simplicity we shall assume that only one occurrence of parameter is modified.

For example, we may consider

List(n) =def ^,a[niln:a, consn: n—a—a] (we added the index n to show that the names of introduction operators are different for different values of parameter).

Or we may consider

Ord =def ^a[0ord(V):a, succord(V):a—a, limv: (v—a)—a] where v is taking only copies of Nat as values.

Notice that in the first case we have covariant occurrence of the parameter and in another contravariant.

The function Cp(f) may be suggested now as the value on morphism f: n—n'. Indeed, if we shall denote by M.(n), ^(n') the types corresponding to the values n, n' of parameter, we shall have Cp(f): —^,(n') for covariant occurrence and Cp(f): M.(n') —M.(n) for the contravariant.

The problem will be that the equalities required in category theory: Cp(f) o Cp(g) = Cp(f o g) for covariant occurrence and Cp(f) o Cp(g) = Cp(g o f) for contravariant, and Cp(idn) = id^ will not hold. It turns out that this problem can be solved by appropriate extension of the system of reductions.

Definition 17. The 9-rewriting is defined by

Cp(g)(Cp(f) r)—9 Cp( (f o g)*) r in case of covariant occurrence of a parameter, and

Cp(g)(Cp(f) r)—9 Cp( (g o f)*) r in case of contravariant one. Here it is assumed that f, g act on the same occurrence of a parameter, and (f o g)* denotes the Pni-normal form of (f o g). The 0-reduction is defined as its contextual closure.

The main reason to consider this reduction is to obtain new categorical structures from already defined ones together with a functor given by the schema of inductive type. It should be noted that in general one may have difficulties with the proof of SN and CR for the calculus extended by 0-reduction but since the underlying categorical structure doesn't necessarily include all the functions f: n—n' definable

in our calculus it is natural to consider certain restrictions on the structure of term representing f.

Theorem 5. Let in the definition of e-reduction the following additional constraint be satisfied: f and g should be of the form A,xn.x, of the form (| t1+n |) (or expansions of such terms) where t1+n do not contain free variables. Then the PniQ reduction is SN and CR.

The proof of this theorem is more complex than in previous cases, especially in the part SN. The proof uses again conditional adjournment (in principal case —e of followed by —t), but in addition we need to prove that in a special case p-reduction is inserable. (In general of course it is not, because, for example, when the term contains a redex of the form the term s can disappear because of p-reduction, and original infinite sequence may originate from s.) The inserability proof uses parallel construction of several partly defined insertion operators and the proof that at least one will indeed produce an infinite sequence of reductions if input sequence was infinite. This is used to obtain a contradiction with SN for Pni reduction.

The constraints we had to impose on the structure of f and g in e-reduction were necessary for the proof of confluence.

It should be noted that this variant of constraint is not the only possible constraint that will provide the "good behavior" of extended system of reductions. The fact that there are other possibilities is demonstrated by the following example.

We may take as the only object of underlying category the object Nat and as morphisms the functions succ, succ o succ, ... , succ o succ ... o succ: Nat— Nat. If we shall restrict e-reduction to the case when f and g are of this form only, the Pn^e reduction will be SN and CR.

At the moment we work on more general description of possible constraints to be imposed on e-reduction.

4. Conclusion

Probably one of the main reasons why the "Types" community didn't yet study actively the extensions of standard reduction systems is that very little success and a lot of technical difficulties was expected. There are some exceptions [10], and hopefully more and more. Another reason is that there is still too much separation between groups working on theoretical aspects of formal methods and their applications, and between different approaches. One may mention two European research projects: "Types" and "Calculemus". While the people working on theoretical analysis of formal systems possess necessary methods and could prove useful innovative results, they are often satisfied with much less innovative solutions of standard problems. Within the class of

problems we consider here it might be standard Pn normalizability for slightly modified calculus.

The groups working on practical aspects and implementation of theorem provers, proof assistants and alike, leave fundamental questions unanswered, or provide makeshift answers that, in long term, cannot satisfy competent user. One example cited above is the problem of extensional versus intensional equality. It is difficult to imagine a user, if only this user does not consider the answer provided by "scientifically approved" proof assistant as an oracle, who would accept that, for example, that the multiplication by 2 followed by (integer) division by 2 does not define identity on Nat. But with respect to intentional equality is not identity function.

Our methods permit to introduce simple extension of reduction system where it will be identity function.

In general the properties of extensions of reduction systems are not always easily proved, and there is many cases when they do not have good properties with respect to reduction at all.

One example "close at hand" would be the isomorphism between Nat and Nat x Nat. It holds extensionally because Nat x Nat can be enumerated, but the attempt to add "supporting" reductions, following x-reduction as a model, fails (one doesn't obtain SN and CR system).

The point is that in many cases extensions with good properties can be successfully obtained. Moreover, this is true for some cases that are conceptually important, as with copies.

One may note that the Cp(f) permits to obtain new isomorphisms from already existing. The isomorphisms already have important role in applications, for example, for invertible transformations of data, so called "middleware", data search etc.

The same potential to generate new categorical structures from already existing within lambda-calculus has the theorem about functoriality of the schemas of inductive types w.r.t their parameters in an extension of standard reduction system that still has good properties, i.e., is convergent.

REFERENCES

1. Akama Y. On Mints' reductions for ccc-calculus // Lecture Notes in

Computer Science. Vol. 664. P.1-12 (1993).

2. Baader F. and Nipkow T. Term rewriting and all that. Cambridge University Press, N. Y., 1998.

3. Bachmair L. and Dershowitz N. Commutation, transformation and termination // Lecture Notes in Computer Science. Vol. 230. P. 5-20 (1986).

4. Barendreg H. and Barendsen E. Autarkic computations in formal proofs //

J. Autom. Reasoning. Vol. 28(3). P. 321-336 (2002).

5. Chemouil D. "Types inductifs, isomorphismes et recriture extensionnelle".

Ph.d. thesis. Universite Toulouse 3 (2004).

6. Chemouil D. and Soloviev S. Remarks on Isomorphisms of Simple Inductive Types // H. Geuvers, F. Kamareddine, eds. Electronic Notes in Theoretical Computer Science. Vol. 85. Elsevier (2003).

7. Di Cosmo R.. On the power of simple diagrams // Harald Ganzinger,

iНе можете найти то, что вам нужно? Попробуйте сервис подбора литературы.

ed. Proceedings of the 7-th International Conference on Rewriting Techniques and Applications (RTA- 96). Lecture Notes in Computer Science. Vol. 1103. P. 200-214,Springer (1996).

8. GezerA.. "Relative termination". Ph.D. thesis. University of Passau,

Germany (1990).

9. Soloviev S. and Chemouil D. Some algebraic structures in lambda-calculus with inductive types // Stefano Berardi, Mario Coppo and Ferruccio Damiani, eds. Proc. Types'03. Lecture Notes in Computer Science. Vol. 3085, Springer (2004).

10. Walukiewicz-Chrzaszcz D. Termination of rewriting in the calculus of constructions // J. of Functional Programming. Vol. 13(2). P. 339-414 (2003).

i Надоели баннеры? Вы всегда можете отключить рекламу.