Download Y and Recursion - CamTools

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Function of several real variables wikipedia , lookup

Transcript
Y and Recursion:
A Threshold Concept in Computer Science
Dan Sheppard, CARET, University of Cambridge
Fixed-Point Combinators in Recursion
Reasoning with things which refer to themselves in their own definition is troublesome,
particularly in proving their general properties mathematically. This presents a problem for
recursion.
The Fixed Point Combinator is a higher-order function, that is, a function which takes a
function as an argument (rather than a particular value), and returns the values for which
the function supplied is equal to its own argument. In a common domain the fixed-point
combinator is often denoted Y. A symbolic statement of the above is Y(f(x)) = f(Y(f(x))). The
surprising thing is that Y is also quite easy to define in an evaluable, non-self-referring form,
and is quite well-behaved. (But it's a bit too complicated for this small box). Therefore, Y is
actually useful, not something only of interest to mathematicians!
Say you want to define a factorial function f, to reason with, not merely to evaluate, as
Teacher Perspectives
The main problem I find is that
students just don't believe that a thing
such as Y could actually exist: that
something so elegant and subtle
mathematically could actually be a
simple practical device. Those that try
too early, without understanding
evaluation strategies properly get
their fingers blown off, and end up
thinking you're conning them.
f(n) := (iszero n) then 1 else n*f(n-1)
but that definition is no good to you because of its self-reference. First you can define a
function g which takes a function as its argument and generates another:
g(h) := [ f(n) := (iszero n) then 1 else n*h(n-1) ]
which is not self-referring, and then define
f = Y(g)
which is also not self-referring, and if you believe me that there's a non self-referring
definition of Y, you have a complete definition for f which is not forward- or self-referring but
which defines a recursive procedure! You can see this because f = Y(g) = g(Y(g)) from the
definition of Y, and from the definition of f, Y(g)=f. Therefore f=g(f), ie the definition of f, but
with h substituted with f, ie the recursive definition!
Learner Perspectives
Informal feedback from other
students suggest that most simply
write off areas which depend on
fixed-point combinators on the basis
of this and similar thresholds. The
ones who eventually succeed tend to
be the self-destructively tenacious
ones, with a 3am epiphany, not the
brighter, skittish students.
What we've done is that the “unrolling” of recursive definitions is handled by the very clever
people who designed Y (Haskell B Curry, for example), and they've done it in such a way
that your particular problem is just a matter of plugging the right things into their function.
Why a Threshold Concept?
Implications
Students find this concept immensely problematic, most never grasp it. It
is bounded to particular areas of mathematics and computer science,
though the concept of the fixed-point can be used elsewhere. You cannot
really understand much the theory of programs without it. It requires the
simultaneous perspectives of mathematical abstraction and practical
operation which are very complex to hold in your head simultaneously,
and integrates ideas from diverse areas: compiler design, logic and proof,
semantics, lambda calculus, evaluation strategy, recursive programming,
and theory of computation. In practice, once you've grasped it you don't
forget it, as it's actually quite a simple idea (though difficult to articulate,
both mathematically and textually).
We have worked (informally), in the past,
on animations of the Y-combinator in
action at the Rainbow Group of the CL. I
believe students responded positively to
this approach, but no formal study was
performed.
Along with a co-teacher, we believe that
animation may be the simplest articulation
of this concept, and some similar ones.
This is unconventional and sometimes
controversial.
“Transforming Perspectives: Technology to Support Teaching and Learning of Threshold Concepts” is an ESRC/EPSRC
Technology Enhanced Learning Project and is part of the Teaching and Learning Research Programme.
It is directed from the Centre for Applied Research into Educational Technologies by Dr. Patrick Carmichael.
Project Contact: Dr. Naomi Irvine, CARET, 16 Mill Lane, Cambridge, CB2 1SB.
Email: 01223 765362 Project Website: http://www.caret.cam.ac.uk/tel