# Chapter 2 Mathematical Background

Save this PDF as:

Size: px
Start display at page:

## Transcription

1 Chapter 2 Mathematical Background We start this chapter with a summary of basic concepts and notations for sets and first-order logic formulas, which will be used in the rest of the book. Our aim is to try to make the book self contained; readers who are familiar with set theory and firstorder logic can skip the first two sections of this chapter and go directly to Sect. 2.3, where we define transition systems. Section 2.4 introduces induction as a technique to define sets and to prove their properties. 2.1 Sets and Relations We will denote the empty set, that is, a set with no elements, by or {}. Non-empty sets will be given extensionally when possible, by enumerating their elements between curly brackets. For instance, the set of Boolean values can be given extensionally as follows. Booleans ={True, False} To indicate that an element is in a set we use the symbol,asintrue Booleans. The symbol denotes membership; its negation is written, asin0 Booleans. When sets are infinite, it is not possible to enumerate all the elements so we will define them intensionally, by characterising their elements. We do this by giving a property that all the elements in the set satisfy. For example, even natural numbers are characterised by the fact that the remainder of the division by 2 is 0, that is, a natural number n is even if nmod2 = 0. Thus, if N is the set of natural numbers we can define the set of even natural numbers intensionally as follows. Even ={n N nmod2 = 0} This kind of definition is called definition by comprehension. Another way of defining sets intensionally is by using induction; we will discuss induction in Sect Two essential notions in set theory are inclusion and equality of sets. M. Fernández, Programming Languages and Operational Semantics, 21 Undergraduate Topics in Computer Science, DOI: / _2, Springer-Verlag London 2014

2 22 2 Mathematical Backround Definition 2.1 (Set inclusion, equality) AsetA is included in the set B, written A B, if all the elements in A are also in B. In this case, we say that A is a subset of B. Using inclusion, we can define equality of sets: Two sets are equal if they have exactly the same elements, that is, A = B if and only if A B and B A. Therefore, to check that two sets are equal we need to check that they contain the same elements. For example, the sets {True, False} and {False, True, True} are equal. This is an instance of a more general property: the order in which we write the elements of a set is irrelevant, and repeating elements is not very elegant but does not change the set either. The standard operations on sets are: Union, written, which, given two sets A and B builds a new set containing all the elements in A and all the elements in B: A B ={e e Aore B} Thus, the set A B is empty only if A and B are both empty. Union is an associative and commutative operator, that is: (A B) C = A (B C) A B = B A Since union is associative, we can write A B C without brackets (there is no confusion since any choice of brackets produces the same result). Intersection, written, which, given two sets A and B builds a new set containing the elements that are in both sets: A B ={e e Aande B} Intersection is also an associative and commutative operator: (A B) C = A (B C) A B = B A The intersection of two sets is empty when they have no elements in common; in particular, it is empty if either of the sets is empty. Since intersection is associative, we can write A B C without brackets. Set difference (or just difference), written, which, given two sets A and B builds a new set as follows: A B ={e A e B} Thus, the difference set A B contains all the elements that are in A but not in B. Another way of defining this set is as a relative complement: it is the complement

3 2.1 Sets and Relations 23 of B with respect to A. This is sometimes written as B (read complement of the set B), when the set A is obvious from the context. Set difference is neither commutative nor associative. Cartesian product (or just product), written, which, given two sets A and B builds the set containing all the pairs where the first component is in A and the second in B: A B ={(a, b) a Aandb B} Since we are dealing with ordered pairs here, product is neither commutative nor associative on sets. This operation can be generalised to products of a finite number of sets. Thus, A 1 A n is a set of tuples (a 1,...,a n ) where each of the elements a i (1 i n)isintheseta i. Note that we have defined the sets resulting from an operation of union, intersection, difference or product by comprehension: we have specified the properties that characterise the elements of the resulting sets. We have relied on an intuitive understanding of the connectives or, and and not ; we will define them precisely in the next section. Now, we will use products of sets to define relations. Definition 2.2 (Relation) A binary relation R between sets A and B is a subset of the Cartesian product A B: R A B In other words, a binary relation R is a subset of the pairs where the first element is in A and the second in B. We will use the notation R(a, b) to indicate that the pair (a, b) is in the relation R. If the sets A and B coincide, we will simply say that R is a relation on A. Binary relations will be used in the next section to define transition systems associated to programs, where a transition will relate two states in the system. In this context, we will consider two properties of relations: Definition 2.3 A binary relation R A A is reflexive if it includes all the pairs (a, a) such that a A. Itistransitive if each time we have R(a, b) and R(b, c) we also have R(a, c). If a relation on A is not reflexive, we can make it reflexive by adding the missing pairs (a, a), and similarly, if it is not transitive, we can make it transitive by adding the pair (a, c) whenever there exists b in A such that R(a, b) and R(b, c). Definition 2.4 The reflexive-transitive closure of the relation R A A is the least reflexive and transitive relation on A that contains R. It is denoted by R. The reflexive-transitive closure of the relation R is obtained simply by extending R with all the pairs needed to satisfy reflexivity and transitivity. If we represent R as a graph (i.e., as a set of nodes and edges, where the nodes are the elements of A and there is an edge from a to b if and only if (a, b) is in R),

4 24 2 Mathematical Backround then the reflexive-transitive closure of R is the relation representing reachability: if (a, b) is in R then there is a path from a to b in the graph. This idea will be useful later: we will use transition relations to specify the behaviour of programs, and the reflexive-transitive closure will represent sequences of computations. Another useful notion is the closure of a set under an operator. In general, a set is said to be closed under an operation if the result of the operation on elements of the set is also a member of the set. The notion of closure can be stated using relations. Definition 2.5 Let R be a binary relation on A. We will say that a subset A of A is closed under the relation R if R relates elements of A with elements of A. Again, this notion will be useful later, in particular to provide an inductive definition of the transition relation associated to a set of programs. Some relations are functions. We can characterise functions from A to B as relations that associate at most one element in B with each element in A: for each a A, there is at most one b B such that a and b are related. Definition 2.6 A relation R A B is a function if R(a, b) and R(a, c) implies b = c, for every a A. To emphasise the fact that a relation R is a function from A to B, we will write R : A B, and denote by R(a) the unique element in B related with a A. For example, the relation that associates each natural number n with the number n + 1 is a function, usually called the successor function S: S : N N ={(n, n + 1) n N } Another way of defining S is by writing S(n) = n + 1. The notions of domain and image of a function can be formally defined: If R is a function from A to B, its domain is the subset of A consisting of all the elements for which there exists an element b in B such that (a, b) R. In other words, the domain of the function R consists of all the elements a in A such that R(a) is defined. If R is a function from A to B, its image is the subset of B consisting of all the elements for which there exists an element a in A such that (a, b) R. In other words, the image of the function R consists of all the elements b in B for which there is some a in A such that b = R(a). The element R(a) is the image of a under R. So far, we have considered only binary relations, however, the ideas can be extended to n-ary relations. An n-ary relation R on the sets A 1,,A n is a set of tuples (a 1,...,a n ) where each of the elements a i is in the set A i. Thus, R A 1 A n. We will use the notation R(a 1,...,a n ) to indicate that the tuple (a 1,...,a n ) is in the relation R. Thus, we can use a relation to characterise a set of tuples with a relevant property. In other words, we can see a relation as a predicate (indeed, relations are used to give a meaning to predicates in first-order logic).

5 2.2 Logic Formulas Logic Formulas In this section, we define the syntax of formulas in first-order logic and recall briefly their semantics. First we need to define terms. Definition 2.7 (Terms) Given an infinite but denumerable set X of symbols x, y, z, x 1, x 2, etc., which we call variables, and an infinite but denumerable set F of symbols f, g, h, f 1, f 2, etc., which we call function symbols, each with an associated arity (a natural number), the set of terms built out of X and F is generated by the grammar: T x f (T,...,T ) where x is an element of X, f is in F and if the arity of f is n then any occurrence of f in a term must be applied to exactly n terms t 1,...,t n. The grammar given above describes the abstract syntax of terms. In other words, terms are either variables or are built using a function symbol and a number of previously built terms corresponding to the arity of the function symbol. We say that t 1,...,t n are the arguments of f in the term f (t 1,...,t n ).Thus,ann-ary function symbol must always have exactly n arguments. Note that n could be zero, in this case the function symbol is called a constant. For example, we can define a language of terms representing natural numbers using just two function symbols: zero, of arity 0, and sucof arity 1. In this case, we do not need variables. The number 0 will be represented by the term zero(). To improve readability, when function symbols have arity 0 we will omit the brackets. Thus, to represent the number 0 we write simply zero; similarly, the term suc(suc(zero)) represents the number 2. We will sometimes write suc(n) as n + 1. Formulas in first-order logic are built using a set of terms, a set of predicate symbols, each with a given arity, and additionally a set of connectives and quantifiers (see below). Terms and predicate symbols are used to build atomic formulas, also called atoms, of the form P(t 1,...,t n ), where P is a predicate of arity n and t 1,...,t n are terms. We will distinguish two 0-ary predicates, T and F, which will denote true and false values, respectively. For example, using the binary predicate >, we can write the atomic formula >(suc(zero), zero). We will usually write this predicate using an infix notation, that is, we write suc(zero) >zero. Atomic formulas may also have variables, for example, we could write suc(x) > zero. In this case, we will say that the variable x is free in the formula. To build more complex formulas, in this book we will use the binary connectives (read and ), (read or ), (read implies ), and the unary connective (read not ). So, if φ and ψ are logic formulas, then φ ψ, φ ψ, φ ψ and φ, are also formulas. In addition, first-order logic formulas may have quantifiers and (read for all and there exists ), denoting universal and existential quantification, respectively: If φ is a formula and x is a variable, then x.φ and x.φ are formulas.

6 26 2 Mathematical Backround In a formula of the form x.φ or x.φ, the variable x is said to be quantified or bound. Formally, the language of first-order formulas can be defined using a grammar; see the Exercises at the end of this chapter. A precise definition of the sets of free and bound variables in a formula is also left as an exercise. A formula without free variables is said to be closed. Once we have defined the syntax of the formulas, we can try to associate a meaning (a truth value) to each formula. However, if the formula has free variables, its truth value depends on the values of the variables, so the meaning of the formula can only be given in relation to a valuation that assigns values to the variables. In addition, to establish the truth value of the formula we need to know how to interpret the function symbols and predicates. We describe now how to map formulas to truth values. We start by fixing a domain U of interpretation for the variables; this is sometimes called a universe. Now, assume each function symbol of arity n is interpreted by an n-ary function on U (in the particular case of n = 0, constants are interpreted by elements of U) and each predicate of arity n is interpreted by an n-ary relation on U. We will denote by [ f ] the function associated to the function symbol f, and by [P] the relation associated to the predicate symbol P. If the formula is closed, we do not need a valuation: the truth value of the formula depends only on the chosen universe, the meaning of the function symbols and the meaning of predicate symbols. Otherwise, assume we are also given a valuation σ mapping variables to elements of U. Using the valuation σ and the interpretations of function symbols we can give a meaning to terms. Then, using the interpretations of terms and predicate symbols, we can give denotations for formulas. Definition 2.8 (Denotation of terms) The interpretation, or denotation, ofatermt in U with respect to a valuation σ and interpretations for function symbols, written [t], is defined as follows. The denotation of a variable x is σ(x): [x] =σ(x) The denotation of f (t 1,...,t n ) is the image of ([t 1 ],...,[t n ]) under [ f ]: [ f (t 1,...,t n )]=[f]([t 1 ],...,[t n ]) Once we know the meaning of terms, we can specify the truth values of formulas. Definition 2.9 (Denotation of formulas) AformulaP(t 1,...,t n ) is true if ([t 1 ],...,[t n ]) [P], that is, if [P]([t 1 ],...,[t n ]); otherwise it is false. For the distinguished symbols T and F, we define [T ] to be true and [F] to be false. Finally, the connectives have the following meanings: denotes conjuction, that is, φ ψ is true if both φ and ψ are true; denotes disjunction, that is, φ ψ is true if at least one of φ or ψ are true;

7 2.2 Logic Formulas 27 denotes implication, φ ψ is true if each time φ is true, ψ is also true; denotes negation: φ is true if φ is false, and it is false if φ is true. In addition, quantified formulas are interpreted as follows: the formula x.φ is true if φ is true for every possible value of x, and the formula x.φ is true if there is at least one value of x that satisfies φ (that is, it makes it true). According to the previous definitions, under an interpretation each term has a value in U, and each formula is either true or false. Example 2.10 Let us assume we interpret the variable x on the natural numbers, so our universe is N. To assign a meaning to the formula suc(x) >zero we need a valuation, which will give us a value for x, let us say 0, and we need interpretations for the function symbols zero and suc and predicate symbol >. Let us assume we interpret zero as the number 0, suc as the successor function and > as the relation containing all the pairs of natural numbers where the first element is greater than the second. Then the formula suc(x) >zero with the valuation that assigns 0 to x is true under this interpretation. Actually, this formula is true for any valuation, if we interpret the variable x on the natural numbers. Therefore, the formula x.suc(x) >zero is true if we interpret the variable x on the natural numbers, assuming [suc] is the successor function, [zero] is the number 0, and [>] is the relation containing all the pairs of natural numbers where the first element is greater than the second. The formula zero > suc(x) is false for all valuations in N, but some formulas are true for certain valuations and false for others. For example suc(zero) >x is only true for the valuation that assigns to x the value 0. We will denote the equality predicate by = as usual, and write it in infix notation. Then, we can write a formula x.suc(x) = zero, but this formula is not true if we interpret x on the natural numbers and interpret suc as the successor function, zero as the number 0, and = as the relation containing all the pairs of natural numbers where the first element is equal to the second. According to our definitions, the formulas φ ψ and ψ φ have the same meaning: they are both true if at least one of the formulas φ, ψ are true, and false if both are false. We conclude that is commutative. Similarly, is commutative, and both and are associative. Note that in the case of quantified formulas, the name of the bound variable is not important, since the formula s truth value (which we are taking as its meaning) does not change if we rename the variable. We will not define the renaming operation formally here, but the intuition is that we can consistently change the name of the variable everywhere in the formula. The meaning of a quantified formula may of course change if we change the domain of interpretation of the bound variables, that is, if we change the set of values that the quantified variables may take.

8 28 2 Mathematical Backround To make clear which is the domain of interpretation we have in mind, when we write first-order logic formulas with quantifiers we will write explicitly the domain next to the quantified variable. For instance, we may write n N.(P(n) P(suc(n))). 2.3 Transition Systems A transition system is a mathematical device that can be used to model computation. Definition 2.11 (Transition System) A transition system is specified by a set Config of configurations or states; a binary relation Config Config, called the transition relation. We use the notation c c (infix) to indicate that c and c are related by. The expression c c denotes a transition from c to c. A transition can be understood simply as a change of state. It will represent a step of computation. To describe the computation performed by a program, we need to specify sequences of transitions. For this, we can use the reflexive-transitive closure of the relation, denoted by. By definition, is a binary relation that contains, contains all the pairs c c (reflexivity), and all the pairs c c such that c c and c c for some c (transitivity). Therefore, c c holds if and only if there is a sequence of transitions: c c 1 c n = c where n 0. We will distinguish initial and final (also called terminal) subsets of configurations, written I, T respectively. A final configuration c is characterised by the fact that there is no transition out of c, more precisely: for all c in T, there is no configuration c such that c c. This can be written in a more compact way as follows. c T, c. The intuitive idea is that a sequence of transitions from an initial state i I to a final state t T represents a run of the system. Definition 2.12 A transition system is deterministic if for every configuration c, whenever c c 1 and c c 2 we have c 1 = c 2. According to the definition, in a deterministic system, at each point of the computation there is at most one possible transition. In other words, the transition relation is a function. In the context of programming languages, this means that if a program is associated to a deterministic transition system, then at each point in the execution the next step of computation is uniquely defined.

9 2.3 Transition Systems 29 In this book, we will be concerned mostly with deterministic programming languages. We will consider non-deterministic systems when giving examples in concurrent languages. Indeed, non-determinism is one of the defining features of concurrent languages. Historically, transition systems were the first tool used to give the formal semantics of a programming language. In fact, the first formal description of the behaviour of a program was in terms of an abstract machine, which is a particular kind of transition system. Definition 2.13 (Abstract Machine) An abstract machine for a programming language is a transition system that simulates the execution of programs. An abstract machine specifies how each construct in the language is executed and for this reason can be seen as an interpreter for a programming language. In Chap. 4 we will give an abstract machine for a simple imperative language. Abstract machines are very useful for implementing a programming language since they describe the execution of each command, step by step. However, for users of the language they are not always easy to understand: abstract machines deal with implementation details that are not always useful to programmers. For the same reason, abstract machines are not an ideal tool for analysing programs, reasoning about programs or proving properties of programs. It is possible to specify the operational semantics of the language in a more structured way, abstracting some of the implementation details. The structural approach to operational semantics based on transition systems gives an inductive definition of the execution of a program, where the transition relation is defined by induction and each command is described in terms of its components. We will give examples of structural operational semantics for imperative and functional languages, in Chaps. 4 and 6. We end this chapter with an overview of induction principles. 2.4 Induction Induction is a powerful technique to define sets and prove their properties. An inductive set is usually defined as the closure of a given set under some operations, that is, the inductive set is the least subset of the given set that is closed under the operations. 1 The most well known instances of this technique are the inductive definition of the set of natural numbers, with its associated Principle of Mathematical Induction, and inductive definitions of data structures, with the associated Principle of Structural Induction. We will use structural induction to prove properties of abstract syntax. 1 More formally, an inductive set is defined as the least fixed point of an operator, which, under certain conditions, is guaranteed to exist.

10 30 2 Mathematical Backround Another useful version of induction is Rule Induction, which we will use to define transition systems. Its associated Principle of Rule Induction will be used to prove properties of the transition relation. Mathematical Induction. The set N of natural numbers is defined inductively, as the smallest set that contains the number 0 and is closed under the successor operation. The latter means that if n is a natural number then its successor n + 1 is also in the set of natural numbers. Also, since it is the smallest set satisfying this condition, the only elements in N are 0 and its successors. Instead of writing 0, 0 + 1, , etc., it is traditional to write the elements of the set N as 0, 1, 2,... The Principle of Mathematical Induction says that to prove that a certain property P holds for all the natural numbers, which we write as n N P(n) to mean P(n) is true for every natural number n, it is sufficient to prove the property P for 0 and to prove that if P holds for an arbitrary number n, then it holds for n + 1. Thus, each proof by mathematical induction has two parts: In the first part, called Basis, we need to prove P(0), that is, prove that the property holds for the number 0. In the second part, called Induction Step, we need to prove the property for the number n + 1 under the assumption that it is true of the number n. This is written: n N (P(n) P(n + 1)). The assumption P(n) in the induction step is called Induction Hypothesis. The reason this is sufficient to deduce that P holds for all natural numbers is that, according to its inductive definition, N is the least set containing 0 and closed under successor. All the natural numbers are generated from 0 using the successor operation, thus, if we can prove the property for 0 and we can prove it is closed under successor, then we have proved that all natural numbers have the property. The Principle of Mathematical Induction is used frequently in arithmetic, and is a useful technique to reason about programs that manipulate numbers, as the following example shows. Example 2.14 Suppose that we need to compute the value of an expression that depends on an index i (a natural number). We write exp i to highlight the fact that the expression exp depends on i. Moreover, suppose that we need to find the total value of expressions with indices in a given range, for example, we need the sum of all the expressions with indices between j and k. We use the notation k exp i i= j

11 2.4 Induction 31 to represent the sum of exp j, exp j+1,..., exp k, where we assume that j is less than or equal to k. If j is greater than k then we have an empty sum, which is 0 by definition. For instance, if the expression is just i and the range is 0 to n, then n i = n i=0 Writing a program to compute such a sum is not a difficult task, but if we need to compute a lengthy sum, instead of writing a program that adds the expressions one by one, we can simply compute n(n + 1)/2. If n is a large number, this is a much better way to obtain the required result. But how can we be sure that this program and the one that computes the lengthy addition produce the same result, for any natural number n? Program equivalence is in fact a difficult problem (it is undecidable in general). In this particular case, we can easily prove, by induction, that replacing the lengthy addition n by n(n + 1)/2 is indeed a correct optimisation. The property that we want to prove states that the sum n produces the same result as n(n + 1)/2, for any natural number n. In other words, we want to prove n n ( i = n(n + 1)/2) i=0 Similarly, if the expression is 2i 1 and we need to compute n (2i 1) = (2n 1) i=1 we can avoid the lengthy sum and simply output n 2. To show that this is indeed a valid optimisation, we can simply by prove by induction that for any natural number n this sum is equal to n 2. According to the Principle of Mathematical Induction, we need to prove the required property first for the base case and then the induction step. We leave the proof of the first property as an exercise (see the list of exercises at the end of the chapter), and show below the proof of the second property, which we can write as n n ( (2i 1) = n 2 ) i=1 Basis: Here we need to prove the property for n = 0, in other words, we need to show 0 (2i 1) = 0 2 i=1

12 32 2 Mathematical Backround The left-hand side is an empty sum, which is 0 by definition, and the right-hand side is also 0, so the basis is trivial in this case. n Induction Step: Assume (2i 1) = n 2 (induction hypothesis). We need to n+1 i=1 prove that (2i 1) = (n + 1) 2. First, notice that i=1 n+1 (2i 1) = i=1 n (2i 1) + (2(n + 1) 1) i=1 Using the induction hypothesis we obtain n (2i 1) + (2(n + 1) 1) = n 2 + 2n + 1 i=1 and the latter is equal to (n + 1) 2 as required. Structural Induction. Programs usually deal with various kinds of data structures, such as strings, lists and trees, in addition to numbers. To prove universal properties of data structures we can use induction on the size of the structure. For example, to show that a certain property P is true for all lists, we can prove that for every natural number n, P holds for all lists of length n. In this way, we translate a property of lists to a property of numbers. However, instead of translating our property, we can adapt the induction principle to work directly on the data structures of interest (specifically, recursively-defined structures such as strings, lists or trees). Let us consider first the case of lists. Assume we denote an empty list by nil, and a non-empty list by cons(h, l) where h is the head element and l is the tail of the list. For simplicity, let us assume that we are building lists of natural numbers, so h is a natural number. For example, the list containing just the element 0 is written cons(0, nil). The operator cons is a constructor for lists, hence its name. There are only two alternatives: either the list is empty (nil), or it is not empty and in this case it must have a head h and a tail l. Since these are the only possible ways of building lists, we can define the set of lists of numbers as an inductive set, as follows. Definition 2.15 (Lists of natural numbers) The set L of lists of natural numbers is the smallest set that contains the empty list nil and is closed under the operator that takes a list l of natural numbers and a natural number h and produces the list cons(h, l). The latter means that if the set L contains a list l, then it also contains cons(h, l) for any natural number h.

13 2.4 Induction 33 For example, the list containing the numbers 1, 3, 5 can be obtained starting with the empty list (nil) and building first cons(5, nil), then cons(3, cons(5, nil)), and finally cons(1, cons(3, cons(5, nil))). According to Definition 2.15: nil is a list, and if we know that l is a list and h is a natural number, then cons(h, l) is a list. Moreover, we can state that there are no other cases, since we defined the set L as the smallest set that contains nil and is closed under the cons operator. As a consequence of this observation, we can derive a mechanism to define functions on lists (recursion) and a principle of induction to prove properties on lists (induction on the structure of lists). To define a function f on lists, and ensure that every element in the inductive set of lists has an image, it is sufficient to define the image of the empty list (i.e., define f (nil)) and define the image f (cons(h, l)) of a non-empty list con(h, l), assuming we already know how to compute f (l). For example, we can define the length of a list by cases as follows. length(nil) = 0, length(cons(h, l)) = length(l) + 1. The principle of induction for lists mimics the definition of the set L. Definition 2.16 (Principle of induction for lists) To prove that a property P holds for every list of natural numbers, that is, for every element of the set L we have defined, it is sufficient to prove: Basis: P(nil). This means that we need to prove that the property holds for the empty list. Induction Step: P(l) implies P(cons(h, l)) for each element h and list l; thisis written: h N, l L.(P(l) P(cons(h, l))). It means that we need to prove the property for the list cons(h, l) under the assumption that it is true of the list l. Here the assumption P(l) is the Induction Hypothesis. Consider the following definition of the mirror image of a list, which we call its reverse. reverse(nil) = nil, reverse(cons(h, l)) = append(reverse(l), h), where the append operation simply adds the element h at the end of the list reverse(l). Equipped with the principle of induction for lists, we can now prove properties of lists by induction directly, without needing to reword the property as a property of numbers. For instance, we can prove by induction that the reverse of a list is a list of the same length, for any list.

14 34 2 Mathematical Backround Basis: The reverse of nil is also nil, so the property holds trivially in this case. Induction Step: Given a non-empty list cons(h, l), we remark that, by the induction hypothesis, l and its reverse have the same length n. Since both the original list cons(h, l) and its reverse have one additional element, we conclude that they both have length n + 1. The induction principle for lists is a particular case of the Structural Induction Principle, which applies to any set built out of a finite set of basic elements e 1,...,e n using a finite set of constructors c 1,...,c k to generate new elements from previously built elements. The set of terms defined in Sect. 2.2 is such a set. The basic elements correspond to variables and 0-ary function symbols, and each function symbol f of arity n greater than 0 can be seen as a term constructor that allows us to generate a new term f (t 1,...,t n ) using previously built terms t 1,...,t n. In general, we can use structural induction to define sets of finite labelled trees. The Structural Induction Principle that we used for lists can be easily adapted to deal with trees, as we will show below. This provides a useful tool to reason on the abstract syntax of programming languages. First, we define the set of finite labelled trees. Definition 2.17 (Finite Labelled Trees) Assume the basic elements are trees l 1,...,l m consisting of just one node (a leaf). To build more trees, we use constructors c 1,...,c k, each with an associated arity. Given trees t 1,...,t ni, the constructor c i of arity n i builds the tree c i (t 1,...,t ni ), which has a root labelled c i and subtrees t 1,...,t ni. The set of finite labelled trees is the smallest set that contains all the basic trees l 1,...,l m and is closed under the constructor operators. The constructors could also have other parameters, for instance, we could also include numbers or strings to be stored at each node of the tree (see the exercises at the end of this chapter). Before stating the induction principle for trees, let us give an example. Example 2.18 If we have just one kind of leaf l, and only one constructor, of arity 2, let us call it btree, we can build the following binary trees: l: a leaf is a tree; btree(l, l): this tree has just a root node and two leaves; btree(btree(l, l), l) and btree(l, btree(l, l)): these are the only trees with three leaves; btree(btree(l, l), btree(l, l)): this tree has a root, two internal nodes, and four leaves. The induction principle follows the inductive definition of tree (Definition 2.17).

15 2.4 Induction 35 Definition 2.19 (Principle of Induction for Trees) To prove a property P for all finite labelled trees, it is sufficient to show: Basis: P(l 1 ),,P(l m ). This means that we need to prove that the property holds for every basic tree. Induction Step: For each tree constructor c i (with n i 1 arguments), if the property holds for any trees t 1,...,t ni then it holds for c i (t 1,...,t ni ). More precisely: c, t 1,...,t n.(p(t 1 ) P(t n ) P(c(t 1,...,t n ))) It means that, for each tree constructor c of arity n, we need to prove the property for the tree c(t 1,...,t n ) under the assumption that the property holds for the trees t 1,...,t n. In the induction step, P(t 1 ),...,P(t n ) are the induction hypotheses. Similarly, to define a function on all the elements of a set defined by structural induction, it is sufficient to define it for the basic elements, and to give a recursive definition for the elements defined by constructors. More precisely, to define function f on a set defined by structural induction from the basic elements l 1,...,l m,using constructors c 1,...,c k, where c i has arity n i, we need to define: f (l i ) for each i such that 1 i m, and f (c i (t 1,...,t ni ), for each constructor c i (1 i k) and arbitrary elements t 1,...,t ni ; in the definition of f (c i (t 1,...,t ni ) we may use f (t j ) for any 1 j n i. For example, the function that computes the number of leaves in a binary tree (see Example 2.18), can be defined as follows. leaves(l) = 1 leaves(btree(t 1, t 2 )) = leaves(t 1 ) + leaves(t 2 ). Since programs are represented as abstract syntax trees, the principle of induction we have just given for finite labelled trees can be applied when we need to prove that all the programs written in a given programming language satisfy a certain property. For this, it is sufficient to specialise the induction principle to take into account the specific sets of basic elements and constructors in the abstract syntax under consideration. Example 2.20 Let us consider the particular case of arithmetic expressions (which are part of all general purpose programming languages). We have already given the abstract syntax of arithmetic expressions in Example 1.2: the grammar provided defines the set of trees representing arithmetic expressions. There are two cases, corresponding, respectively, to tokens representing numbers and expressions defined by applying a binary operator to two subtrees. Thus, the set of labelled trees corresponding to

16 36 2 Mathematical Backround arithmetic expressions can be built inductively: the basic trees are built using number tokens, and the inductive trees are built using four constructors, one for each of the four binary operators +,,, div in our language. To prove that a property P holds for all the abstract syntax trees corresponding to arithmetic expressions in the language, we proceed as follows: 1. Basis: Prove P(n) for all number tokens n. 2. Induction Step: For each operator Op {+,,, div}, and each pair E, E of abstract syntax trees of arithmetic expressions, prove that P(E) and P(E ) implies P(Op(E, E )). Rule Induction. All the induction principles we discussed so far are in fact particular cases of a more general mechanism. We will now give a definition of an inductive set as a subset of a universal set characterised by its generators, that is, a subset defined by a finite set of basic elements and a finite set of rules that specify how to generate elements of the subset. Any set of objects can be used as a universal set. Once we have fixed our universal set T, we can define the basic elements of the inductive subset by enumerating them, and define the generators by showing how new elements are constructed in terms of previously defined objects. Formally, we will write inductive definitions using axioms to represent the basic elements (the basis of the inductive definition) and rules to define the way constructors work. We will then give an induction principle associated with the definition of the inductive subset. The axioms will provide the basis for the induction, and the rules will represent the induction step. We will give examples below, but first let us define more precisely the notions of axiom and rule. Definition 2.21 (Axioms and Rules) Let T be a set of objects (i.e. our universal set). An axiom is simply an element of T. The standard notation for axioms is: t A rule is a pair (H, c) where H is a non-empty subset {h 1,...,h n } of T, called the hypotheses or premises of the rule; c is an element of T, called the conclusion of the rule. The standard notation for rules is: h 1... h n c Rules may have conditions, which we write on the side (we give examples below).

17 2.4 Induction 37 We now define precisely the inductive set specified by a collection of axioms and rules. Definition 2.22 (Inductive Set Specified by Axioms and Rules) The subset I of T inductively defined by a collection A of axioms and R of rules is the smallest subset of T that includes the set A of axioms and is closed under all the rules in R. According to this definition, the inductive set I consists of those elements t in T such that t A (that is, t is an axiom), or there are t 1,...,t n I and a rule (H, c) R such that H ={t 1,...,t n } and t = c. We can apply this technique to define the inductive sets we have already studied. Example 2.23 We can define the set of natural numbers using one axiom: 0 and one rule: n n + 1 The set of lists of natural numbers can be defined by the axiom: nil and the rule: l cons(h, l) if h N Note the condition on the rule, which specifies that h is a natural number. Another example is the definition of the set of strings that have an even number of characters from an alphabet Σ. In this case the universal set is the set of all the sequences of characters in Σ. Let us denote the empty string by ɛ. We can define the subset of strings whose length is an even number using just the axiom ɛ and a set of rules of the form s if a, b Σ asb

18 38 2 Mathematical Backround According to this rule, we can build a string with an even number of characters using a previously built string s, which has an even number of characters, and two arbitrary characters a and b in Σ; asbdenotes the string obtained by adding a at the beginning of s and b at the end. We will often omit ɛ when there is no confusion, so we will write abinstead of a ɛ b. We can think of this as a rule scheme: there is one rule for each pair of characters. To show that an element t of T is in the inductive set I it is sufficient to show that t is an axiom, or that there is a way of generating t starting from the axioms and using the rules. The latter can be shown by building a proof tree for t. Definition 2.24 (Proof tree) Given an inductive definition of I using axioms A and rules R, a proof tree for t has root, also called conclusion, t. Its leaves correspond to axioms in A, and for each non-leaf node t i there is a rule ({t i1,...,t imi }, t i ) in R relating t i and its children t i1,...,t imi in the proof tree. This kind of proof tree is usually written:. t t 1m1 t 1... t. t n1... t n. t nmn For example, the proof tree for the number 2, using the inductive definition of the set of natural numbers given in Example 2.23, is: Similarly, we can build a proof tree for the string abab: ɛ ba abab In the following example, we use axioms and rules to give an inductive definition of an evaluation relation for arithmetic expressions. Here, the universal set is the set of pairs where the first element is an abstract syntax tree representing an arithmetic expression, and the second a value (an integer number in this case).

19 2.4 Induction 39 Example 2.25 (Inductive Definition of Evaluation) Consider the abstract syntax of arithmetic expressions given in Example 1.2. We define now, using axioms and rules, a binary relation that associates the (abstract syntax tree of an) arithmetic expression E with a number n. We will write E n to indicate that the expression E evaluates to the number n. Axioms. A number is already a value. Therefore for each number we need an axiom: 0 0, 1 1, 2 2, etc. Instead of writing these explicitly, we will use an axiom scheme: n n which represents the infinite set of axioms obtained by replacing n with a number. From now on, we will not distinguish between axioms and axiom schemes. We will simply write n n, with the assumption that n is any number. Rules. Similarly, we will need rules for each operator Op {+,,, div}, which we represent as rule schemes: E 1 n 1 E 2 n 2 if n = (n1 Op n 2 ) Op(E 1, E 2 ) n The condition if n = (n 1 Op n 2 ) on the rule simply states that the number n in the conclusion of the rule is the result of the operation denoted by Op on the values n 1 and n 2. From now on, rule schemes will simply be called rules. Associated to inductive definitions using axioms and rules, there is a principle of induction, called the Principle of Rule Induction. Let I be a set defined by induction with axioms and rules (A, R). To show that a property P holds for each element of the set I, that is, to prove it is sufficient to prove: i I.P(i) Basis: a A.P(a) Induction Step: ({h 1,...h n }, c) R. P(h 1 ) P(h n ) P(c). Thus, every proof by rule induction has two parts. In the first part, the property is proved for the axioms. In the second part, for each rule, assuming that the property is true for the premises of the rule (this is the induction hypothesis), the property is proved for the conclusion of the rule. Example 2.26 We can prove using rule induction that each arithmetic expression has a unique value under the evaluation relation given in Example In other words, the relation is

20 40 2 Mathematical Backround a function, and it is defined for every expression (we assume the arithmetic operators are total). Basis: The basis of the induction holds trivially, since numbers have unique values (according to the axioms, the value of an expression n is the number n itself). Induction Step: For non-atomic expressions, we remark that the value of an arithmetic expression of the form Op(E 1, E 2 ) is uniquely determined by the values of its arguments E 1 and E 2, which are unique by the induction hypotheses. 2.5 Further Reading Makinson s book [1] provides a gentle introduction to logic, set theory and induction. Harper s book [2] and Winskel s book [3] include chapters on induction with a variety of examples, and Dowek s book [4] provides a formal definition of an inductive set as a least fixed point, including concise explanations of the notions underlying the definition. 2.6 Exercises 1. Show the following properties of the intersection and union operators on sets: A B = B A (A B) C = A (B C) A A = A A B = B A (A B) C = A (B C) A A = A 2. Show that for every formula φ in first-order logic, and every choice of universe U, valuation σ and interpretations for function and predicate symbols, the interpretations of φ and ( φ) coincide, that is, double negation does not change the truth value of a formula. 3. Prove, by mathematical induction, that for any natural number n: n i=1 i = n(n + 1)/2 n i=1 2 i 1 = 2 n 1 4. Describe the set of trees generated by the following inductive definition: Nil is a tree; If n is a number and t 1 and t 2 are trees, then Tree(n, t 1, t 2 ) is a tree. 5. Prove that the principle of structural induction corresponds to a particular application of the principle of mathematical induction. 6. Define the abstract syntax of first-order logic formulas using a grammar. Using structural induction, define for each formula its set of free variables and bound variables.

21 2.6 Exercises Define by rule induction the set E of even natural numbers, using n+2 to generate the even number after n. Prove by rule induction that 2n is in the set E, for every natural number n. 8. Let R A A be a binary relation on A. Define by rule induction the relation R, that is, the reflexive-transitive closure of R. 9. ( ) Let I be a set defined by rule induction using axioms A and rules R. An alternative way of defining I is by taking the intersection of all the subsets of T that include A and are closed under R: I = {J T A JandJR-closed} Prove that both definitions are equivalent. References 1. D. Makinson, Sets, Logic and Maths for Computing, 2nd edn., Undergraduate topics in computer science (Springer, Berlin, 2012) 2. R. Harper, Practical Foundations for Programming Languages (Cambridge University Press, Cambridge, 2013) 3. G. Winskel, The Formal Semantics of Programming Languages, Foundations of computing (MIT Press, Cambridge, 1993) 4. G. Dowek, Proofs and Algorithms An Introduction to Logic and Computability, Undergraduate topics in computer science (Springer, Berlin, 2011)

22

### 3. Mathematical Induction

3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

### Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

### Formal Languages and Automata Theory - Regular Expressions and Finite Automata -

Formal Languages and Automata Theory - Regular Expressions and Finite Automata - Samarjit Chakraborty Computer Engineering and Networks Laboratory Swiss Federal Institute of Technology (ETH) Zürich March

### Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

### Full and Complete Binary Trees

Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

### CS 3719 (Theory of Computation and Algorithms) Lecture 4

CS 3719 (Theory of Computation and Algorithms) Lecture 4 Antonina Kolokolova January 18, 2012 1 Undecidable languages 1.1 Church-Turing thesis Let s recap how it all started. In 1990, Hilbert stated a

### Mathematical Induction

Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

### This asserts two sets are equal iff they have the same elements, that is, a set is determined by its elements.

3. Axioms of Set theory Before presenting the axioms of set theory, we first make a few basic comments about the relevant first order logic. We will give a somewhat more detailed discussion later, but

### Lecture 17 : Equivalence and Order Relations DRAFT

CS/Math 240: Introduction to Discrete Mathematics 3/31/2011 Lecture 17 : Equivalence and Order Relations Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT Last lecture we introduced the notion

### Cartesian Products and Relations

Cartesian Products and Relations Definition (Cartesian product) If A and B are sets, the Cartesian product of A and B is the set A B = {(a, b) :(a A) and (b B)}. The following points are worth special

### Mathematical Induction

Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

### Testing LTL Formula Translation into Büchi Automata

Testing LTL Formula Translation into Büchi Automata Heikki Tauriainen and Keijo Heljanko Helsinki University of Technology, Laboratory for Theoretical Computer Science, P. O. Box 5400, FIN-02015 HUT, Finland

### MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

### Handout #1: Mathematical Reasoning

Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or

### CHAPTER 7 GENERAL PROOF SYSTEMS

CHAPTER 7 GENERAL PROOF SYSTEMS 1 Introduction Proof systems are built to prove statements. They can be thought as an inference machine with special statements, called provable statements, or sometimes

### Lecture 16 : Relations and Functions DRAFT

CS/Math 240: Introduction to Discrete Mathematics 3/29/2011 Lecture 16 : Relations and Functions Instructor: Dieter van Melkebeek Scribe: Dalibor Zelený DRAFT In Lecture 3, we described a correspondence

### Reading 13 : Finite State Automata and Regular Expressions

CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

### ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS

PROCEEDINGS OF THE YEREVAN STATE UNIVERSITY Physical and Mathematical Sciences 2012 1 p. 43 48 ON FUNCTIONAL SYMBOL-FREE LOGIC PROGRAMS I nf or m at i cs L. A. HAYKAZYAN * Chair of Programming and Information

### A Propositional Dynamic Logic for CCS Programs

A Propositional Dynamic Logic for CCS Programs Mario R. F. Benevides and L. Menasché Schechter {mario,luis}@cos.ufrj.br Abstract This work presents a Propositional Dynamic Logic in which the programs are

### CHAPTER 3 Numbers and Numeral Systems

CHAPTER 3 Numbers and Numeral Systems Numbers play an important role in almost all areas of mathematics, not least in calculus. Virtually all calculus books contain a thorough description of the natural,

### Fixed-Point Logics and Computation

1 Fixed-Point Logics and Computation Symposium on the Unusual Effectiveness of Logic in Computer Science University of Cambridge 2 Mathematical Logic Mathematical logic seeks to formalise the process of

### C H A P T E R Regular Expressions regular expression

7 CHAPTER Regular Expressions Most programmers and other power-users of computer systems have used tools that match text patterns. You may have used a Web search engine with a pattern like travel cancun

### University of Ostrava. Reasoning in Description Logic with Semantic Tableau Binary Trees

University of Ostrava Institute for Research and Applications of Fuzzy Modeling Reasoning in Description Logic with Semantic Tableau Binary Trees Alena Lukasová Research report No. 63 2005 Submitted/to

### Relational Databases

Relational Databases Jan Chomicki University at Buffalo Jan Chomicki () Relational databases 1 / 18 Relational data model Domain domain: predefined set of atomic values: integers, strings,... every attribute

### MODULAR ARITHMETIC. a smallest member. It is equivalent to the Principle of Mathematical Induction.

MODULAR ARITHMETIC 1 Working With Integers The usual arithmetic operations of addition, subtraction and multiplication can be performed on integers, and the result is always another integer Division, on

### 6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010. Class 4 Nancy Lynch

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, 2010 Class 4 Nancy Lynch Today Two more models of computation: Nondeterministic Finite Automata (NFAs)

### k, then n = p2α 1 1 pα k

Powers of Integers An integer n is a perfect square if n = m for some integer m. Taking into account the prime factorization, if m = p α 1 1 pα k k, then n = pα 1 1 p α k k. That is, n is a perfect square

### Applications of Methods of Proof

CHAPTER 4 Applications of Methods of Proof 1. Set Operations 1.1. Set Operations. The set-theoretic operations, intersection, union, and complementation, defined in Chapter 1.1 Introduction to Sets are

### (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems.

3130CIT: Theory of Computation Turing machines and undecidability (IALC, Chapters 8 and 9) Introduction to Turing s life, Turing machines, universal machines, unsolvable problems. An undecidable problem

### Induction. Margaret M. Fleck. 10 October These notes cover mathematical induction and recursive definition

Induction Margaret M. Fleck 10 October 011 These notes cover mathematical induction and recursive definition 1 Introduction to induction At the start of the term, we saw the following formula for computing

### Announcements. CompSci 230 Discrete Math for Computer Science Sets. Introduction to Sets. Sets

CompSci 230 Discrete Math for Computer Science Sets September 12, 2013 Prof. Rodger Slides modified from Rosen 1 nnouncements Read for next time Chap. 2.3-2.6 Homework 2 due Tuesday Recitation 3 on Friday

### Elementary Number Theory We begin with a bit of elementary number theory, which is concerned

CONSTRUCTION OF THE FINITE FIELDS Z p S. R. DOTY Elementary Number Theory We begin with a bit of elementary number theory, which is concerned solely with questions about the set of integers Z = {0, ±1,

### The Language of Mathematics

CHPTER 2 The Language of Mathematics 2.1. Set Theory 2.1.1. Sets. set is a collection of objects, called elements of the set. set can be represented by listing its elements between braces: = {1, 2, 3,

### Mathematical Induction. Lecture 10-11

Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

### The Foundations: Logic and Proofs. Chapter 1, Part III: Proofs

The Foundations: Logic and Proofs Chapter 1, Part III: Proofs Rules of Inference Section 1.6 Section Summary Valid Arguments Inference Rules for Propositional Logic Using Rules of Inference to Build Arguments

### A Little Set Theory (Never Hurt Anybody)

A Little Set Theory (Never Hurt Anybody) Matthew Saltzman Department of Mathematical Sciences Clemson University Draft: August 21, 2013 1 Introduction The fundamental ideas of set theory and the algebra

### Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras

Theory of Computation Prof. Kamala Krithivasan Department of Computer Science and Engineering Indian Institute of Technology, Madras Lecture No. # 31 Recursive Sets, Recursively Innumerable Sets, Encoding

### Automata and Formal Languages

Automata and Formal Languages Winter 2009-2010 Yacov Hel-Or 1 What this course is all about This course is about mathematical models of computation We ll study different machine models (finite automata,

### 2. The Language of First-order Logic

2. The Language of First-order Logic KR & R Brachman & Levesque 2005 17 Declarative language Before building system before there can be learning, reasoning, planning, explanation... need to be able to

### Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics An Introductory Single Variable Real Analysis: A Learning Approach through Problem Solving Marcel B. Finan c All Rights

### Math 223 Abstract Algebra Lecture Notes

Math 223 Abstract Algebra Lecture Notes Steven Tschantz Spring 2001 (Apr. 23 version) Preamble These notes are intended to supplement the lectures and make up for the lack of a textbook for the course

### Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing

### Theory of Computation

Theory of Computation For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Theory of Computation Regular Expressions and Finite Automata, Context-Free Grammar s

### Aikaterini Marazopoulou

Imperial College London Department of Computing Tableau Compiled Labelled Deductive Systems with an application to Description Logics by Aikaterini Marazopoulou Submitted in partial fulfilment of the requirements

### 2. Compressing data to reduce the amount of transmitted data (e.g., to save money).

Presentation Layer The presentation layer is concerned with preserving the meaning of information sent across a network. The presentation layer may represent (encode) the data in various ways (e.g., data

### PART I. THE REAL NUMBERS

PART I. THE REAL NUMBERS This material assumes that you are already familiar with the real number system and the representation of the real numbers as points on the real line. I.1. THE NATURAL NUMBERS

### We give a basic overview of the mathematical background required for this course.

1 Background We give a basic overview of the mathematical background required for this course. 1.1 Set Theory We introduce some concepts from naive set theory (as opposed to axiomatic set theory). The

### Semantics for the Predicate Calculus: Part I

Semantics for the Predicate Calculus: Part I (Version 0.3, revised 6:15pm, April 14, 2005. Please report typos to hhalvors@princeton.edu.) The study of formal logic is based on the fact that the validity

### Theory of Computation Lecture Notes

Theory of Computation Lecture Notes Abhijat Vichare August 2005 Contents 1 Introduction 2 What is Computation? 3 The λ Calculus 3.1 Conversions: 3.2 The calculus in use 3.3 Few Important Theorems 3.4 Worked

### 2. Methods of Proof Types of Proofs. Suppose we wish to prove an implication p q. Here are some strategies we have available to try.

2. METHODS OF PROOF 69 2. Methods of Proof 2.1. Types of Proofs. Suppose we wish to prove an implication p q. Here are some strategies we have available to try. Trivial Proof: If we know q is true then

### Predicate Calculus. There are certain arguments that seem to be perfectly logical, yet they cannot be expressed by using propositional calculus.

Predicate Calculus (Alternative names: predicate logic, first order logic, elementary logic, restricted predicate calculus, restricted functional calculus, relational calculus, theory of quantification,

### So let us begin our quest to find the holy grail of real analysis.

1 Section 5.2 The Complete Ordered Field: Purpose of Section We present an axiomatic description of the real numbers as a complete ordered field. The axioms which describe the arithmetic of the real numbers

### 1. Prove that the empty set is a subset of every set.

1. Prove that the empty set is a subset of every set. Basic Topology Written by Men-Gen Tsai email: b89902089@ntu.edu.tw Proof: For any element x of the empty set, x is also an element of every set since

### ML for the Working Programmer

ML for the Working Programmer 2nd edition Lawrence C. Paulson University of Cambridge CAMBRIDGE UNIVERSITY PRESS CONTENTS Preface to the Second Edition Preface xiii xv 1 Standard ML 1 Functional Programming

### Generating models of a matched formula with a polynomial delay

Generating models of a matched formula with a polynomial delay Petr Savicky Institute of Computer Science, Academy of Sciences of Czech Republic, Pod Vodárenskou Věží 2, 182 07 Praha 8, Czech Republic

### 6.3 Conditional Probability and Independence

222 CHAPTER 6. PROBABILITY 6.3 Conditional Probability and Independence Conditional Probability Two cubical dice each have a triangle painted on one side, a circle painted on two sides and a square painted

### 4.1. Definitions. A set may be viewed as any well defined collection of objects, called elements or members of the set.

Section 4. Set Theory 4.1. Definitions A set may be viewed as any well defined collection of objects, called elements or members of the set. Sets are usually denoted with upper case letters, A, B, X, Y,

### Regular Languages and Finite Automata

Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

### Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

### Foundations of mathematics

Foundations of mathematics 1. First foundations of mathematics 1.1. Introduction to the foundations of mathematics Mathematics, theories and foundations Sylvain Poirier http://settheory.net/ Mathematics

### CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce

### Computability Theory

CSC 438F/2404F Notes (S. Cook and T. Pitassi) Fall, 2014 Computability Theory This section is partly inspired by the material in A Course in Mathematical Logic by Bell and Machover, Chap 6, sections 1-10.

### Software Modeling and Verification

Software Modeling and Verification Alessandro Aldini DiSBeF - Sezione STI University of Urbino Carlo Bo Italy 3-4 February 2015 Algorithmic verification Correctness problem Is the software/hardware system

### Math212a1010 Lebesgue measure.

Math212a1010 Lebesgue measure. October 19, 2010 Today s lecture will be devoted to Lebesgue measure, a creation of Henri Lebesgue, in his thesis, one of the most famous theses in the history of mathematics.

### Correspondence analysis for strong three-valued logic

Correspondence analysis for strong three-valued logic A. Tamminga abstract. I apply Kooi and Tamminga s (2012) idea of correspondence analysis for many-valued logics to strong three-valued logic (K 3 ).

### Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

### Sample Induction Proofs

Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given

### A Note on Context Logic

A Note on Context Logic Philippa Gardner Imperial College London This note describes joint work with Cristiano Calcagno and Uri Zarfaty. It introduces the general theory of Context Logic, and has been

### MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

MATHEMATICAL INDUCTION MIGUEL A LERMA (Last updated: February 8, 003) Mathematical Induction This is a powerful method to prove properties of positive integers Principle of Mathematical Induction Let P

### Midterm Practice Problems

6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator

### Finite Automata and Regular Languages

CHAPTER 3 Finite Automata and Regular Languages 3. Introduction 3.. States and Automata A finite-state machine or finite automaton (the noun comes from the Greek; the singular is automaton, the Greek-derived

### Inf1A: Deterministic Finite State Machines

Lecture 2 InfA: Deterministic Finite State Machines 2. Introduction In this lecture we will focus a little more on deterministic Finite State Machines. Also, we will be mostly concerned with Finite State

### 2. Abstract State Machines

2. Abstract State Machines The notion of Abstract State Machines (ASMs), defined in [20], captures in mathematically rigorous yet transparent form some fundamental operational intuitions of computing,

### 8 Divisibility and prime numbers

8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

### 4 Domain Relational Calculus

4 Domain Relational Calculus We now present two relational calculi that we will compare to RA. First, what is the difference between an algebra and a calculus? The usual story is that the algebra RA is

### A first step towards modeling semistructured data in hybrid multimodal logic

A first step towards modeling semistructured data in hybrid multimodal logic Nicole Bidoit * Serenella Cerrito ** Virginie Thion * * LRI UMR CNRS 8623, Université Paris 11, Centre d Orsay. ** LaMI UMR

### Sets and set operations

CS 441 Discrete Mathematics for CS Lecture 7 Sets and set operations Milos Hauskrecht milos@cs.pitt.edu 5329 Sennott Square asic discrete structures Discrete math = study of the discrete structures used

### Clicker Question. Theorems/Proofs and Computational Problems/Algorithms MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES

MC215: MATHEMATICAL REASONING AND DISCRETE STRUCTURES Tuesday, 1/21/14 General course Information Sets Reading: [J] 1.1 Optional: [H] 1.1-1.7 Exercises: Do before next class; not to hand in [J] pp. 12-14:

### Repetition and Loops. Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed.

New Topic Repetition and Loops Additional Python constructs that allow us to effect the (1) order and (2) number of times that program statements are executed. These constructs are the 1. while loop and

### ! " # The Logic of Descriptions. Logics for Data and Knowledge Representation. Terminology. Overview. Three Basic Features. Some History on DLs

,!0((,.+#\$),%\$(-&.& *,2(-\$)%&2.'3&%!&, Logics for Data and Knowledge Representation Alessandro Agostini agostini@dit.unitn.it University of Trento Fausto Giunchiglia fausto@dit.unitn.it The Logic of Descriptions!\$%&'()*\$#)

### Examination paper for MA0301 Elementær diskret matematikk

Department of Mathematical Sciences Examination paper for MA0301 Elementær diskret matematikk Academic contact during examination: Iris Marjan Smit a, Sverre Olaf Smalø b Phone: a 9285 0781, b 7359 1750

### Likewise, we have contradictions: formulas that can only be false, e.g. (p p).

CHAPTER 4. STATEMENT LOGIC 59 The rightmost column of this truth table contains instances of T and instances of F. Notice that there are no degrees of contingency. If both values are possible, the formula

### Software Engineering

Software Engineering Lecture 04: The B Specification Method Peter Thiemann University of Freiburg, Germany SS 2013 Peter Thiemann (Univ. Freiburg) Software Engineering SWT 1 / 50 The B specification method

### 1 if 1 x 0 1 if 0 x 1

Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

### Lecture 1: Course overview, circuits, and formulas

Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik

### A Beginner s Guide to Modern Set Theory

A Beginner s Guide to Modern Set Theory Martin Dowd Product of Hyperon Software PO Box 4161 Costa Mesa, CA 92628 www.hyperonsoft.com Copyright c 2010 by Martin Dowd 1. Introduction..... 1 2. Formal logic......

### 1 Definition of a Turing machine

Introduction to Algorithms Notes on Turing Machines CS 4820, Spring 2012 April 2-16, 2012 1 Definition of a Turing machine Turing machines are an abstract model of computation. They provide a precise,

### WRITING PROOFS. Christopher Heil Georgia Institute of Technology

WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this

### Automata on Infinite Words and Trees

Automata on Infinite Words and Trees Course notes for the course Automata on Infinite Words and Trees given by Dr. Meghyn Bienvenu at Universität Bremen in the 2009-2010 winter semester Last modified:

### Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note 11

CS 70 Discrete Mathematics and Probability Theory Fall 2009 Satish Rao,David Tse Note Conditional Probability A pharmaceutical company is marketing a new test for a certain medical condition. According

### INTRODUCTORY SET THEORY

M.Sc. program in mathematics INTRODUCTORY SET THEORY Katalin Károlyi Department of Applied Analysis, Eötvös Loránd University H-1088 Budapest, Múzeum krt. 6-8. CONTENTS 1. SETS Set, equal sets, subset,

### INCIDENCE-BETWEENNESS GEOMETRY

INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

### Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

### Lecture 2: Regular Languages [Fa 14]

Caveat lector: This is the first edition of this lecture note. Please send bug reports and suggestions to jeffe@illinois.edu. But the Lord came down to see the city and the tower the people were building.

### EQUATIONAL LOGIC AND ABSTRACT ALGEBRA * ABSTRACT

EQUATIONAL LOGIC AND ABSTRACT ALGEBRA * Taje I. Ramsamujh Florida International University Mathematics Department ABSTRACT Equational logic is a formalization of the deductive methods encountered in studying

### COMPUTER SCIENCE TRIPOS

CST.98.5.1 COMPUTER SCIENCE TRIPOS Part IB Wednesday 3 June 1998 1.30 to 4.30 Paper 5 Answer five questions. No more than two questions from any one section are to be answered. Submit the answers in five

### Problems on Discrete Mathematics 1

Problems on Discrete Mathematics 1 Chung-Chih Li 2 Kishan Mehrotra 3 Syracuse University, New York L A TEX at January 11, 2007 (Part I) 1 No part of this book can be reproduced without permission from

### CODING TRUE ARITHMETIC IN THE MEDVEDEV AND MUCHNIK DEGREES

CODING TRUE ARITHMETIC IN THE MEDVEDEV AND MUCHNIK DEGREES PAUL SHAFER Abstract. We prove that the first-order theory of the Medvedev degrees, the first-order theory of the Muchnik degrees, and the third-order