McCarthy Formalism
   HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
and
recursion theory Computability theory, also known as recursion theory, is a branch of mathematical logic, computer science, and the theory of computation that originated in the 1930s with the study of computable functions and Turing degrees. The field has since ex ...
the McCarthy Formalism (1963) of
computer A computer is a machine that can be Computer programming, programmed to automatically Execution (computing), carry out sequences of arithmetic or logical operations (''computation''). Modern digital electronic computers can perform generic set ...
scientist John McCarthy clarifies the notion of recursive functions by use of the IF-THEN-ELSE construction common to computer science, together with four of the operators of
primitive recursive function In computability theory, a primitive recursive function is, roughly speaking, a function that can be computed by a computer program whose loops are all "for" loops (that is, an upper bound of the number of iterations of every loop is fixed befor ...
s: zero, successor, equality of numbers and composition. The conditional operator replaces both primitive recursion and the mu-operator.


Introduction


McCarthy's notion of ''conditional expression''

McCarthy (1960) described his formalism this way: :"In this article, we first describe a formalism for defining functions recursively. We believe this formalism has advantages both as a programming language and as a vehicle for developing a theory of computation.... :We shall need a number of mathematical ideas and notations concerning functions in general. Most of the ideas are well known, but the notion of ''conditional expression'' is believed to be new, and the use of ''conditional expressions'' permits functions to be defined recursively in a new and convenient way."


Minsky's explanation of the "formalism"

In
Marvin Minsky Marvin Lee Minsky (August 9, 1927 – January 24, 2016) was an American cognitive scientist, cognitive and computer scientist concerned largely with research in artificial intelligence (AI). He co-founded the Massachusetts Institute of Technology ...
s 1967 book ''Computation: Finite and Infinite Machines'', § 10.7 Conditional Expressions: The McCarthy Formalism, he describes the "formalism" as follows: : "Practical computer languages do not lend themselves to formal mathematical treatment--they are not designed to make it easy to prove theorems about the procedures they describe. In a paper by McCarthy 963we find a formalism that enhances the practical aspect of the recursive-function concept, while preserving and improving its mathematical clarity. ¶ McCarthy introduces "conditional expressions" of the form :: f = (if ''p''1 then ''e''1 else ''e''2) : where the ''e''i are expressions and ''p''1 is a statement (or equation) that may be true or false. ¶ This expression means :: See if ''p''1 is true; if so the value of ''f'' is given by ''e''1. :: IF ''p1'' is false, the value of ''f'' is given by ''e''2. :This conditional expression . . . has also the power of the minimization operator. . .. :The McCarthy formalism is like the general recursive (Kleene) system, in being based on some basic functions, composition, and equality, but with the conditional expression alone replacing both the primitive-recursive scheme and the minimization operator." (Minsky 1967:192-193) Minsky uses the following operators in his demonstrations: * Zero * Successor * Equality of numbers * Composition (substitution, replacement, assignment) * Conditional expression From these he shows how to derive the ''predecessor'' function (i.e. DECREMENT); with this tool he derives the minimization operator necessary for "general"
recursion Recursion occurs when the definition of a concept or process depends on a simpler or previous version of itself. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in m ...
, as well as primitive-recursive definitions.


Expansion of IF-THEN-ELSE to the CASE operator

In his 1952 ''Introduction of Meta-Mathematics'' Stephen Kleene provides a definition of what it means to be a primitive recursive function: :"A function is ''primitive recursive in'' (briefly Ψ), if there is a finite sequence of (occurrences of) functions ... such that each function of the sequence is either one of the functions Ψ (the assumed functions), or an initial function, or an immediate dependent of preceding functions, and the last function is ." (Kleene 1952:224) In other words, given a "basis" function (it can be a constant such as 0), primitive recursion uses either the base or the previous value of the function to produce the value of the function; primitive recursion is sometimes called
mathematical induction Mathematical induction is a method for mathematical proof, proving that a statement P(n) is true for every natural number n, that is, that the infinitely many cases P(0), P(1), P(2), P(3), \dots  all hold. This is done by first proving a ...
Minsky (above) is describing a two-CASE operator. A demonstration that the ''nested'' IF-THEN-ELSE—the " case statement" (or "switch statement")--is primitive recursive can be found in Kleene 1952:229Kleene's 5 primitive recursion "schema" include the following: at "#F ('mutually-exclusive predicates')". The CASE operator behaves like a logical
multiplexer In electronics, a multiplexer (or mux; spelled sometimes as multiplexor), also known as a data selector, is a device that selects between several Analog signal, analog or Digital signal (electronics), digital input signals and forwards the sel ...
and is simply an extension of the simpler two-case logical operator sometimes called AND-OR-SELECT (see more at Propositional formula). The CASE operator for three cases would be verbally described as: "If X is CASE 1 then DO "p" else if X is CASE 2 then do "q" else if X is CASE "3" then do "r" else do "default". Boolos-Burgess-Jeffrey 2002 observe that in a particular instance the CASE operator, or a sequence of nested IF-THEN-ELSE statements, must be both
mutually exclusive In logic and probability theory, two events (or propositions) are mutually exclusive or disjoint if they cannot both occur at the same time. A clear example is the set of outcomes of a single coin toss, which can result in either heads or tails ...
, meaning that only one "case" holds (is true), and collectively exhaustive, meaning ''every'' possible situation or "case" is "covered". These requirements are a consequence of the determinacy of
Propositional logic The propositional calculus is a branch of logic. It is also called propositional logic, statement logic, sentential calculus, sentential logic, or sometimes zeroth-order logic. Sometimes, it is called ''first-order'' propositional logic to contra ...
; the correct implementation requires the use of
truth table A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, Boolean functions, and propositional calculus—which sets out the functional values of logical expressions on each of their functional arg ...
s and
Karnaugh map A Karnaugh map (KM or K-map) is a diagram that can be used to simplify a Boolean algebra expression. Maurice Karnaugh introduced the technique in 1953 as a refinement of Edward W. Veitch's 1952 Veitch chart, which itself was a rediscovery of ...
s to specify and simplify the cases; see more at Propositional formula. The authors point out the power of "definition by cases": :"...in more complicated examples, definition by cases makes it far easier to establish the (primitive) recursiveness of important functions. This is mainly because there are a variety of processes for defining new relations from old that can be shown to produce new (primitive) recursive relations when applied to (primitive) recursive relations." (Boolos-Burgess-Jeffrey 2002:74) They prove, in particular, that the processes of substitution, graph relation (similar to the
identity relation In mathematics, a homogeneous relation (also called endorelation) on a set ''X'' is a binary relation between ''X'' and itself, i.e. it is a subset of the Cartesian product . This is commonly phrased as "a relation on ''X''" or "a (binary) relation ...
that plucks out (the value of) a particular variable from a list of variables),
negation In logic, negation, also called the logical not or logical complement, is an operation (mathematics), operation that takes a Proposition (mathematics), proposition P to another proposition "not P", written \neg P, \mathord P, P^\prime or \over ...
(logical NOT), conjunction (logical AND),
disjunction In logic, disjunction (also known as logical disjunction, logical or, logical addition, or inclusive disjunction) is a logical connective typically notated as \lor and read aloud as "or". For instance, the English language sentence "it is ...
(logical OR), bounded
universal quantification In mathematical logic, a universal quantification is a type of quantifier, a logical constant which is interpreted as "given any", "for all", "for every", or "given an arbitrary element". It expresses that a predicate can be satisfied by e ...
, or bounded
existential quantification Existentialism is a family of philosophy, philosophical views and inquiry that explore the human individual's struggle to lead an Authenticity (philosophy), authentic life despite the apparent Absurdity#The Absurd, absurdity or incomprehensibili ...
can be used together with definition by cases to create new primitive recursive functions (cf Boolos-Burgess-Jeffrey 2002:74-77).


See also

*
Association list In computer programming and particularly in Lisp, an association list, often referred to as an alist, is a linked list in which each list element (or node) comprises a key and a value. The association list is said to ''associate'' the value wit ...
*
De Bruijn index In mathematical logic, the de Bruijn index is a tool invented by the Dutch mathematician Nicolaas Govert de Bruijn for representing terms of lambda calculus without naming the bound variables. Terms written using these indices are invariant with ...


Notes


References

* * George S. Boolos, John P. Burgess, and Richard C. Jeffrey, 2002, ''Computability and Logic: Fourth Edition'', Cambridge University Press, Cambridge UK, {{isbn, 0-521-00758-5 paperback. * John McCarthy (1963),
A Basis for a Mathematical Theory of Computation
', Computer Programming and Formal Systems, pp. 33-70. *
Marvin Minsky Marvin Lee Minsky (August 9, 1927 – January 24, 2016) was an American cognitive scientist, cognitive and computer scientist concerned largely with research in artificial intelligence (AI). He co-founded the Massachusetts Institute of Technology ...
(1967), ''Computation: Finite and Infinite Machines'', Prentice-Hall Inc, Englewood Cliffs, NJ. Computability theory