Search code examples
functional-programmingprologfunctorcategory-theorylogic-programming

Does the term "Functor" in Prolog have any relation to the term taken from Category Theory?


I started to learn Prolog and I just read that the atom at the beginning of an structure is usually called functor.

I'm also familiar with the term functor from Category Theory and Functional Programming.

So my question is, does the choice of the word functor in Prolog have any implications on Category Theory? Are functors in Prolog a type of transformation? Or is the choice of the name mere coincidence?

Thanks so much!


Solution

  • Does the term "Functor" in Prolog have any relation to the term taken from Category Theory?

    No.


    Does the choice of the word functor in Prolog have any implications on Category Theory?

    No.


    Are functors in Prolog a type of transformation?

    Answering that subjectively can lead to many rebuttal comments; here are the facts.

    Prolog has an ISO standard and in the standard is

    §3.77 functor: An identifier together with an arity.

    If you work with Prolog enough you will learn to think symbolically and then realize that functor is just a name for something. Other common names in Prolog are term, list, atom, variable.

    See this post for more details.


    Or is the choice of the name mere coincidence?

    I would not say coincidence as if you look at the pedigree of both words you will probably arrive at a common point related to math, so it is not a coincidence it is that when people have a choice for naming something sometimes they use a familiar name or sometimes they coin a new word.

    In this case over the years people just keep using functor over and over again for various things and the tree of what it means has grown significantly.

    At least the use of the word functor is not as bad as the over use of comma as an operator in programming languages.


    Side note on possible pedigree for functor use in Prolog.

    In Googling for a definition of functor found the Wikipedia article functor which noted the Wikipedia article function word. For function word it notes

    In linguistics, function words (also called functors) are words that have little lexical meaning or have ambiguous meaning and express grammatical relationships among other words within a sentence, or specify the attitude or mood of the speaker.

    If you know that Prolog was first created for processing the French language [1] then this seems like a likely path for the pedigree of the word functor on the Prolog side.

    1 - "The birth of Prolog" by Alain Colmerauer and Philippe Roussel