3
votes

I posted this question on the SWI Prolog Discourse forum and got some useful comments, but maybe people here might also have some ideas about this topic.

I am somewhat confused about how to use the word “atom” in a paper we are writing.

(1) In Prolog an atom is said to be a “Textual constant. Used as name for compound terms, to represent constants or text.”. See here. Accordingly these are atoms: john, grandparent, etc.

(2) In texts about logic programming, e.g. Riguzzi (2018) and Baral and Gelfond (1994), “atoms” are said to be terms with the form p(t1, t2, ..., tn), where the ts are terms and p is a predicate symbol. This corresponds to the use of “atom” in classical first order logic.

Am I correct in assuming that (1) is the proper definition for “atom” when talking about Prolog, and that (2) is the proper definition for “atom” when talking about logic programming? I think that a reason for my confusion is that I think of Prolog as an instance of logic programming.

Cheers/JC

EDIT 2020-08-18**********************************************

It was somewhat challenging to explain unification when using LP terminology; i made an attempt.

Unification with typical Prolog terminology:

  • Atoms, numbers, variables and compounds are terms
  • Atom = string that starts with a lower case letter
  • Number = a number
  • Variable = string that starts with a capital letter
  • Compound = p(t1, t2, ..., tn) where p is a predicate symbol and ts are terms.

Unification:

  • Two atoms unify if they are the same
  • Two numbers unify if they are the same
  • A variable unifies with any kind of term
  • Two compounds unify if (1) they have the same name, (2) the same number of arguments, (3) all of their arguments unify, (4) their variables can be instantiated consistently

Unification with typical LP terminology:

  • Constants, variables and functions are terms
  • Constant = a string that starts with a lower case letter or a number
  • Variable = a string that starts with an upper case letter
  • Function = f(t1, t3, ..., tn) where f is a function symbol and the ts are terms
  • Atomic formula = p(t1, t2, ..., tn) where p is a predicate symbol and the ts are terms

Unification:

  • Two constants unify if they are the same
  • A variable unifies with any kind of term
  • Two atomic formulas, or two functions, unify if (1) they have the same name, (2) the same number of arguments, (3) all of their arguments unify, (4) their variables can be instantiated consistently
1
I think you are right: Prolog uses "atom" for (a certain class of) what formal logic calls "constant". The texts you quoted use it as shorthand for "atomic formula". It might make sense in your paper to avoid the term "atom" altogether and use "constant" or "atomic formula" instead, unless you are writing specifically about Prolog. As for Prolog being an instance of "logic programming", the term is so vague that this doesn't have a yes/no answer.Isabelle Newbie
Yes, same word but different meaning depending on context. I'm rather certain Prolog's "atom" comes from LISP's "atom", where it is analogously "a short string that stands for itself", something like a "keyword" from other programming languages but one that can be used flexibly by the programmer (in particular, outside of designated places like enums for example).David Tonhofer
Same ambiguity for Prolog's "functor", which stands for the same notion as the "predicate": a symbolic constant (i.e. an atom) and an arity -- but "functor" is used in Category Theory since the 40's and has a very different meaning there.David Tonhofer

1 Answers