• No se han encontrado resultados

INFRAESTRUCTURA Y FISIOGRAFÍA 3.1 Accesibilidad

3.5 Tenencia del Terreno Superficial

In simply typed languages, we are not used to seeing functions with varying arity. Certainly, the use of curried functions is commonplace, but there is nothing serious

Á basic datatypes =?h; h D =?h1;Ah> y;4fh D =Bh;Ah> ­<­<­ other=?h1;Ah> s £ f;4› D =] £ šf ­<­<­ other=]îp¨ £ šfs f>øh D ¨nšÚij> gõyh D ¨‰š·i> Á

describing the machine

h ;A›y=?ghgš› ‡ =Bh;Ah> Ð =] £ šf Ð =?h;4h> Ð =]îp¨ £ šf Ð ¨nšÚij> h ;A›y=?ghgš›y= ‡ fg=Bhh ;A›y=?gh1gš› h; ¤ > ‡ ™ h=?gf=] £ šf Ÿ]Ð =] £ šf Ð:™ fg=?h·=Nîp¨ £ šf Ÿ klš› ¢ õe¥ ;Ahgš› ‡ =Bh;Ah> Ð h; ¤ >

(h=Bgf is the type of lists built by adding elements at the right-hand end with the

constructor=?›yšk . I overload›¦gf.)

Á

list membership (for any element typeç

) D ç à D fg=?h ç ¢ › à D ¨n>¨ £ > ™ klš›y= à Ÿ D ç ù D ¨‰>¨ £ > ž à =B>> ù D ¨n>¨ £ > žÝ™ klš›y= à Ÿ Á

updating the tape (¥

¤ 4;Ah> D h; ¤ >Uƒ ¨‰š·i> ƒ«h; ¤ >Uƒ LMNPORQ) „ D =Nîp¨ £ šf  D fg=Bh·=]îp¨ £ šf f £ f;4› „y D ¥ ¤ A;4h> ü ›¦gf x„–x1 ý(f>øh ü ›¦gf x £ f;A› x klš›y= „y ý DD h=?gf}=]îp¨ £ šf à „ D =Nîp¨ £ šf  D fg=?hÚ=]îp¨ £ šf f¨‰š·i> D à „y D ¥ ¤ 4;Ah> ü =?›yšk D à x1„¬x1 ý(f>øh ü2D x à x klš›y= „y ý DjD h1=?gf=]îp¨ £ šf „ D =]îp¨ £ šf £ f;4› D „ D ¥ ¤ 4;Ah> ü2D x1„¬x ›ygfý gõ¦h ü =?›yšk D „cx £ f;A› x ›ygfý DjD h=?gf=] £ šf „ à D =]îp¨ £ šf  D fg=?h·=] £ šf ¨nšÚij> D „ à  D ¥ ¤ A;4h> ü9D x1„¬x klš›y=tà  ý gõyh ü =?›yšk D „cx à x1 ý Á one step (=Bh> ¤ D h ;A›y=?ghgš›y=Aƒ«kš› ¢ õ4¥ ;4hgš› ƒ klš› ¢ õe¥ ;Ah1gš› ƒ LMNPOQ) à  D ¨‰>¨ £ > ü ’Rx„–x1’ Cx„ Cx2Î ý¸Ã B„ ó D ¥ ¤ 4;Ah> ü2D x1„ C x ý Î Ã ÂMzcŽ Aš à 4ó D =?h> ¤ à B„ ü ’x ü D x1„¬x1 ý?ý ü ’ Cx à Â7zcŽ ý Á halting problem (¦;4fh= D h ;4›y=?ghgš›y=4ƒ«kš› ¢ õ4¥ ;4hgš› ƒ h; ¤ >Uƒ LMNPORQ) à ?„ D h ;A›y=?ghgš›y= à Â7zcŽ D h; ¤ > =?hš ¤ à ?„ à Â7zcŽ D y;Afh=¦Ã ?„ ü y;Afh x à Â7zcŽ ýÉà Â7zcŽ „ à ŽBz D =Bh> ¤ à ?„ ¥   D à „ D y;Afh=¦Ã ?„  à ÂMzcŽ õ4š „ à Ž?z  D à „ D y;Afh1=à ?„ ¥ à Â7zcŽ

happening that · -equivalence cannot explain. There seems to be little motivation for

allowing functions to be defined with arity varying between pattern equations.

By contrast, there are some dependently typed functions for which such a relaxation in the syntax would be of genuine benefit. These tend to arise when we write one function to compute types involved in another. For example

(c¥y¨ D 88$ƒ LMNPORQ (c¥y¨ S ‡ 88 (c¥y¨ = G ‡ 88&ƒ (c¥y¨ G =?¥y¨ DsEHGÉD 88@J'(c¥y¨ G =?¥y¨ S ‡ S =?¥y¨ = S ž ‡ ž =?¥y¨ =?= G žÙw ‡ =?¥y¨ = G ™ ¤ f¥y= žÞwڟ

The first argument of =?¥y¨ is the number of subsequent arguments, and the function

computes their sum. You might well point out that I could make the arities uniform byY -abstraction, but that is because I am not doing any pattern matching on the newly

exposed arguments. Of course, in any case I can always introduce subprograms, but why should I have to?

You might also suspect that such functions are uncommon in practice, and thus not worth the trouble. There are three things to say to that:

Á

Dependently typed programming is still in its infancy—we do not know which techniques will turn out to be common in practice.

Á

This is the kind of technique which is used somewhat less frivolously in strong normalisation proofs—we compute a meta-level function type from an object- level function type, then we compute the appropriate metal-level function to in- habit it.

Á

This sort of behaviour is already supported in as industrial a programming lan- guage as C. The remarkably common printf command takes a formatting string, followed by arguments appropriate to the fields to be printed—you hope. Of course, there is no check to see that it makes sense. C compilers do not blink twice at

but the effect is seldom benign. Dependent types sanitise these rather frightening functions.

We may accommodate this behaviour by adjusting the definition of covering to allow lengthening of pattern sequences by fresh pattern variables, provided the result type beforehand is functional. These extended patterns may then be split as before. Each lengthening can, of course, be replaced by a call to a subprogram in order to recover the uniform arity of the original. The treatment of recursion is as before. Recursive calls can be recognised provided they have at least the arity of the pattern to which the guarded recursion principle was applied. Longer sequences of arguments can be cut in two, leaving a recursive‘

[Aoo

of the right length which is then applied further.