Term (logic)

Last updated

In mathematical logic, a term denotes a mathematical object while a formula denotes a mathematical fact. In particular, terms appear as components of a formula. This is analogous to natural language, where a noun phrase refers to an object and a whole sentence refers to a fact.

Contents

A first-order term is recursively constructed from constant symbols, variables and function symbols. An expression formed by applying a predicate symbol to an appropriate number of terms is called an atomic formula, which evaluates to true or false in bivalent logics, given an interpretation. For example, is a term built from the constant 1, the variable x, and the binary function symbols and ; it is part of the atomic formula which evaluates to true for each real-numbered value of x.

Besides in logic, terms play important roles in universal algebra, and rewriting systems.

Formal definition

Left to right: tree structure of the term (n[?](n+1))/2 and n[?]((n+1)/2) Tree structure of mathematical first-order terms svg.svg
Left to right: tree structure of the term (n⋅(n+1))/2 and n⋅((n+1)/2)

Given a set V of variable symbols, a set C of constant symbols and sets Fn of n-ary function symbols, also called operator symbols, for each natural number n ≥ 1, the set of (unsorted first-order) terms T is recursively defined to be the smallest set with the following properties: [1]

Using an intuitive, pseudo-grammatical notation, this is sometimes written as:

t ::= x | c | f(t1, ..., tn).

The signature of the term language describes which function symbol sets Fn are inhabited. Well-known examples are the unary function symbols sin, cosF1, and the binary function symbols +, −, ⋅, / ∈ F2. Ternary operations and higher-arity functions are possible but uncommon in practice. Many authors consider constant symbols as 0-ary function symbols F0, thus needing no special syntactic class for them.

A term denotes a mathematical object from the domain of discourse. A constant c denotes a named object from that domain, a variable x ranges over the objects in that domain, and an n-ary function f maps n-tuples of objects to objects. For example, if nV is a variable symbol, 1 ∈ C is a constant symbol, and addF2 is a binary function symbol, then nT, 1 ∈ T, and (hence) add(n, 1) ∈ T by the first, second, and third term building rule, respectively. The latter term is usually written as n+1, using infix notation and the more common operator symbol + for convenience.

Term structure vs. representation

Originally, logicians defined a term to be a character string adhering to certain building rules. [2] However, since the concept of tree became popular in computer science, it turned out to be more convenient to think of a term as a tree. For example, several distinct character strings, like "(n⋅(n+1))/2", "((n⋅(n+1)))/2", and "", denote the same term and correspond to the same tree, viz. the left tree in the above picture. Separating the tree structure of a term from its graphical representation on paper, it is also easy to account for parentheses (being only representation, not structure) and invisible multiplication operators (existing only in structure, not in representation).

Structural equality

Two terms are said to be structurally, literally, or syntactically equal if they correspond to the same tree. For example, the left and the right tree in the above picture are structurally unequal terms, although they might be considered "semantically equal" as they always evaluate to the same value in rational arithmetic. While structural equality can be checked without any knowledge about the meaning of the symbols, semantic equality cannot. If the function / is e.g. interpreted not as rational but as truncating integer division, then at n=2 the left and right term evaluates to 3 and 2, respectively. Structural equal terms need to agree in their variable names.

In contrast, a term t is called a renaming, or a variant, of a term u if the latter resulted from consistently renaming all variables of the former, i.e. if u = for some renaming substitution σ. In that case, u is a renaming of t, too, since a renaming substitution σ has an inverse σ−1, and t = uσ−1. Both terms are then also said to be equal modulo renaming. In many contexts, the particular variable names in a term don't matter, e.g. the commutativity axiom for addition can be stated as x+y=y+x or as a+b=b+a; in such cases the whole formula may be renamed, while an arbitrary subterm usually may not, e.g. x+y=b+a is not a valid version of the commutativity axiom. [note 1] [note 2]

Ground and linear terms

The set of variables of a term t is denoted by vars(t). A term that doesn't contain any variables is called a ground term ; a term that doesn't contain multiple occurrences of a variable is called a linear term. For example, 2+2 is a ground term and hence also a linear term, x⋅(n+1) is a linear term, n⋅(n+1) is a non-linear term. These properties are important in, for example, term rewriting.

Given a signature for the function symbols, the set of all terms forms the free term algebra . The set of all ground terms forms the initial term algebra.

Abbreviating the number of constants as f0, and the number of i-ary function symbols as fi, the number θh of distinct ground terms of a height up to h can be computed by the following recursion formula:

Building formulas from terms

Given a set Rn of n-ary relation symbols for each natural number n ≥ 1, an (unsorted first-order) atomic formula is obtained by applying an n-ary relation symbol to n terms. As for function symbols, a relation symbol set Rn is usually non-empty only for small n. In mathematical logic, more complex formulas are built from atomic formulas using logical connectives and quantifiers. For example, letting denote the set of real numbers, ∀x: x ⇒ (x+1)⋅(x+1) ≥ 0 is a mathematical formula evaluating to true in the algebra of complex numbers. An atomic formula is called ground if it is built entirely from ground terms; all ground atomic formulas composable from a given set of function and predicate symbols make up the Herbrand base for these symbol sets.

Operations with terms

Tree structure of black example term
a
*
(
(
a
+
1
)
*
(
a
+
2
)
)
1
*
(
2
*
3
)
{\displaystyle {\frac {a*((a+1)*(a+2))}{1*(2*3)}}}
, with blue redex
x
*
(
y
*
z
)
{\displaystyle x*(y*z)} Example term for position, path, depth, match svg.svg
Tree structure of black example term , with blue redex

Sorted terms

When the domain of discourse contains elements of basically different kinds, it is useful to split the set of all terms accordingly. To this end, a sort (sometimes also called type) is assigned to each variable and each constant symbol, and a declaration [note 3] of domain sorts and range sort to each function symbol. A sorted termf(t1,...,tn) may be composed from sorted subterms t1,...,tn only if the ith subterm's sort matches the declared ith domain sort of f. Such a term is also called well-sorted; any other term (i.e. obeying the unsorted rules only) is called ill-sorted.

For example, a vector space comes with an associated field of scalar numbers. Let W and N denote the sort of vectors and numbers, respectively, let VW and VN be the set of vector and number variables, respectively, and CW and CN the set of vector and number constants, respectively. Then e.g. and 0 ∈ CN, and the vector addition, the scalar multiplication, and the inner product is declared as , and , respectively. Assuming variable symbols and a,bVN, the term is well-sorted, while is not (since + doesn't accept a term of sort N as 2nd argument). In order to make a well-sorted term, an additional declaration is required. Function symbols having several declarations are called overloaded.

See many-sorted logic for more information, including extensions of the many-sorted framework described here.

Lambda terms

Terms with bound variables
Notation
example
Bound
variables
Free
variables
Written as
lambda-term
limn→∞x/nnxlimitn. div(x,n))
insum(1,ni. power(i,2))
ta, b, kintegral(a,bt. sin(kt))

Motivation

Mathematical notations as shown in the table do not fit into the scheme of a first-order term as defined above, as they all introduce an own local, or bound, variable that may not appear outside the notation's scope, e.g. doesn't make sense. In contrast, the other variables, referred to as free, behave like ordinary first-order term variables, e.g. does make sense.

All these operators can be viewed as taking a function rather than a value term as one of their arguments. For example, the lim operator is applied to a sequence, i.e. to a mapping from positive integer to e.g. real numbers. As another example, a C function to implement the second example from the table, Σ, would have a function pointer argument (see box below).

Lambda terms can be used to denote anonymous functions to be supplied as arguments to lim, Σ, ∫, etc.

For example, the function square from the C program below can be written anonymously as a lambda term λi. i2. The general sum operator Σ can then be considered as a ternary function symbol taking a lower bound value, an upper bound value and a function to be summed-up. Due to its latter argument, the Σ operator is called a second-order function symbol. As another example, the lambda term λn. x/n denotes a function that maps 1, 2, 3, ... to x/1, x/2, x/3, ..., respectively, that is, it denotes the sequence (x/1, x/2, x/3, ...). The lim operator takes such a sequence and returns its limit (if defined).

The rightmost column of the table indicates how each mathematical notation example can be represented by a lambda term, also converting common infix operators into prefix form.

intsum(intlwb,intupb,intfct(int)){// implements general sum operatorintres=0;for(inti=lwb;i<=upb;++i)res+=fct(i);returnres;}intsquare(inti){returni*i;}// implements anonymous function (lambda i. i*i); however, C requires a name for it#include<stdio.h>intmain(void){intn;scanf(" %d",&n);printf("%d\n",sum(1,n,square));// applies sum operator to sum up squaresreturn0;}

Definition

Given a set V of variable symbols, the set of lambda terms is defined recursively as follows:

  • every variable symbol xV is a lambda term;
  • if xV is a variable symbol and t is a lambda term, then λx.t is also a lambda term (abstraction);
  • if t1 and t2 are lambda terms, then ( t1t2 ) is also a lambda term (application).

The above motivating examples also used some constants like div, power, etc. which are, however, not admitted in pure lambda calculus.

Intuitively, the abstraction λx.t denotes a unary function that returns t when given x, while the application ( t1t2 ) denotes the result of calling the function t1 with the input t2. For example, the abstraction λx.x denotes the identity function, while λx.y denotes the constant function always returning y. The lambda term λx.(xx) takes a function x and returns the result of applying x to itself.

See also

Notes

  1. Since atomic formulas can be viewed as trees, too, and renaming is essentially a concept on trees, atomic (and, more generally, quantifier-free) formulas can be renamed in a similar way as terms. In fact, some authors consider a quantifier-free formula as a term (of type bool rather than e.g. int, cf. #Sorted terms below).
  2. Renaming of the commutativity axiom can be viewed as alpha-conversion on the universal closure of the axiom: "x+y=y+x" actually means "∀x,y: x+y=y+x", which is synonymous to "∀a,b: a+b=b+a"; see also #Lambda terms below.
  3. I.e., "symbol type" in the Many-sorted signatures section of the Signature (logic) article.

Related Research Articles

First-order logic—also known as predicate logic, quantificational logic, and first-order predicate calculus—is a collection of formal systems used in mathematics, philosophy, linguistics, and computer science. First-order logic uses quantified variables over non-logical objects, and allows the use of sentences that contain variables, so that rather than propositions such as "Socrates is a man", one can have expressions in the form "there exists x such that x is Socrates and x is a man", where "there exists" is a quantifier, while x is a variable. This distinguishes it from propositional logic, which does not use quantifiers or relations; in this sense, propositional logic is the foundation of first-order logic.

Lambda calculus is a formal system in mathematical logic for expressing computation based on function abstraction and application using variable binding and substitution. It is a universal model of computation that can be used to simulate any Turing machine. It was introduced by the mathematician Alonzo Church in the 1930s as part of his research into the foundations of mathematics.

In logic and computer science, unification is an algorithmic process of solving equations between symbolic expressions. For example, using x,y,z as variables, the singleton equation set { cons(x,cons(x,nil)) = cons(2,y) } is a syntactic first-order unification problem that has the substitution { x ↦ 2, ycons(2,nil) } as its only solution.

A mathematical symbol is a figure or a combination of figures that is used to represent a mathematical object, an action on mathematical objects, a relation between mathematical objects, or for structuring the other symbols that occur in a formula. As formulas are entirely constituted with symbols of various types, many symbols are needed for expressing all mathematics.

In mathematics, and in other disciplines involving formal languages, including mathematical logic and computer science, a variable may be said to be either free or bound. The terms are opposites. A free variable is a notation (symbol) that specifies places in an expression where substitution may take place and is not a parameter of this or any container expression. Some older books use the terms real variable and apparent variable for free variable and bound variable, respectively. The idea is related to a placeholder, or a wildcard character that stands for an unspecified symbol.

In logic and mathematics, second-order logic is an extension of first-order logic, which itself is an extension of propositional logic. Second-order logic is in turn extended by higher-order logic and type theory.

In mathematics, an expression or mathematical expression is a finite combination of symbols that is well-formed according to rules that depend on the context. Mathematical symbols can designate numbers (constants), variables, operations, functions, brackets, punctuation, and grouping to help determine order of operations and other aspects of logical syntax.

The simply typed lambda calculus, a form of type theory, is a typed interpretation of the lambda calculus with only one type constructor that builds function types. It is the canonical and simplest example of a typed lambda calculus. The simply typed lambda calculus was originally introduced by Alonzo Church in 1940 as an attempt to avoid paradoxical use of the untyped lambda calculus.

In mathematical logic, a ground term of a formal system is a term that does not contain any variables. Similarly, a ground formula is a formula that does not contain any variables.

In universal algebra and mathematical logic, a term algebra is a freely generated algebraic structure over a given signature. For example, in a signature consisting of a single binary operation, the term algebra over a set X of variables is exactly the free magma generated by X. Other synonyms for the notion include absolutely free algebra and anarchic algebra.

In mathematics, a variable is a symbol that represents a mathematical object. A variable may represent a number, a vector, a matrix, a function, the argument of a function, a set, or an element of a set.

In mathematical logic, an atomic formula is a formula with no deeper propositional structure, that is, a formula that contains no logical connectives or equivalently a formula that has no strict subformulas. Atoms are thus the simplest well-formed formulas of the logic. Compound formulas are formed by combining the atomic formulas using the logical connectives.

A substitution is a syntactic transformation on formal expressions. To apply a substitution to an expression means to consistently replace its variable, or placeholder, symbols with other expressions.

In logic, especially mathematical logic, a signature lists and describes the non-logical symbols of a formal language. In universal algebra, a signature lists the operations that characterize an algebraic structure. In model theory, signatures are used for both purposes. They are rarely made explicit in more philosophical treatments of logic.

In first-order logic, a Herbrand structureS is a structure over a vocabulary σ that is defined solely by the syntactical properties of σ. The idea is to take the symbol strings of terms as their values, e.g. the denotation of a constant symbol c is just "c". It is named after Jacques Herbrand.

An interpretation is an assignment of meaning to the symbols of a formal language. Many formal languages used in mathematics, logic, and theoretical computer science are defined in solely syntactic terms, and as such do not have any meaning until they are given some interpretation. The general study of interpretations of formal languages is called formal semantics.

In mathematics, the word constant conveys multiple meanings. As an adjective, it refers to non-variance ; as a noun, it has two different meanings:

In computer science, algebraic semantics is a form of axiomatic semantics based on algebraic laws for describing and reasoning about program specifications in a formal manner.

Computable topology is a discipline in mathematics that studies the topological and algebraic structure of computation. Computable topology is not to be confused with algorithmic or computational topology, which studies the application of computation to topology.

Anti-unification is the process of constructing a generalization common to two given symbolic expressions. As in unification, several frameworks are distinguished depending on which expressions are allowed, and which expressions are considered equal. If variables representing functions are allowed in an expression, the process is called "higher-order anti-unification", otherwise "first-order anti-unification". If the generalization is required to have an instance literally equal to each input expression, the process is called "syntactical anti-unification", otherwise "E-anti-unification", or "anti-unification modulo theory".

References

  1. C.C. Chang; H. Jerome Keisler (1977). Model Theory. Studies in Logic and the Foundation of Mathematics. Vol. 73. North Holland.; here: Sect.1.3
  2. Hermes, Hans (1973). Introduction to Mathematical Logic. Springer London. ISBN   3540058192. ISSN   1431-4657.; here: Sect.II.1.3