ArticleslgStudy

computer science

McCarthy Formalism

McCarthy Formalism is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand McCarthy Formalism rather than just read about it. In short: In computer science and recursion theory the McCarthy formalism (1963) of computer 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 functions: zero, successor, equality of numbers and composition. The conditional operator replaces both primitive recursion and the mu-operat…

Key takeaways

  • McCarthy Formalism belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect McCarthy Formalism to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of McCarthy Formalism from memory before moving on to harder problems.

Reference excerpt

In computer science and recursion theory the McCarthy formalism (1963) of computer 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 functions: 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 submitted a proposal for conditional expressions in IAL, which was published as a "Letter to the Editor" in 1959. McCarthy later 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 Minskys 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 [1963] we 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 p1 then e1 else e2) where the ei are expressions and p1 is a statement (or equation) that may be true or false. ¶ This expression means See if p1 is true; if so the value of f is given by e1. IF p1 is false, the value of f is given by e2. 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, 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 ψ1, ..., ψk (briefly Ψ), if there is a finite sequence φ1, ..., φk 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 φk 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 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:229 at "#F ('mutually-exclusive predicates')". The CASE operator behaves like a logical multiplexer 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, 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 correct implementation requires the use of truth tables and Karnaugh maps 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 that plucks out (the value of) a particular variable from a list of variables), negation (logical NOT), conjunction (logical AND), disjunction (logical OR), bounded universal quantification, or bounded existential quantification 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 De Bruijn index

Notes

References McCarthy, John (1959). "Letters to the Editor". Communications of the ACM. 2 (8): 2–5. doi:10.1145/368405.1773349. McCarthy, John (1960). "Recursive Functions of Symbolic Expressions and Their Computation by Machine, Part I". Communications of the ACM. 3 (4): 184–195. doi:10.1145/367177.367199. 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 (1967), Computation: Finite and Infinite Machines, Prentice-Hall Inc, Englewood Cliffs, NJ.

Worked examples

Example 1 — a first encounter with McCarthy Formalism

Start with the simplest possible case. Write down what McCarthy Formalism claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to McCarthy Formalism before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about McCarthy Formalism ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of McCarthy Formalism

In research
McCarthy Formalism appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses McCarthy Formalism in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
McCarthy Formalism is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computability theory, so understanding it makes those chapters shorter.
In everyday life
Look for McCarthy Formalism outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “McCarthy Formalism” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study McCarthy Formalism in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what McCarthy Formalism means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain McCarthy Formalism out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is McCarthy Formalism in simple terms?

In computer science and recursion theory the McCarthy formalism (1963) of computer 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 functions: zero, succ…

Why does McCarthy Formalism matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study McCarthy Formalism?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on McCarthy Formalism.

Tags

  • Computability theory

Keep exploring