Propositional Logic-Software Engineering-Lecture 10 Slides-Computer Science, Slides of Software Engineering

The course is intended to develop an understanding of the problems associated with the development of significant computing systems (that is, systems that are too large to be designed and developed by a single person, and are designed to be used by many users) and to appreciate the techniques and tools necessary to develop such systems efficiently, in a cost-effective manner. Propositional Logic, First-order Logic, Syntax, Terms, Predicates, Quantifiers, Comments, Decidability

Typology: Slides

2011/2012

Uploaded on 02/03/2012

gustavott
gustavott 🇬🇧

3.9

(14)

253 documents

1 / 21

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
LECTURE 10: FIRST-ORDER LOGIC
Software Engineering
Mike Wooldridge
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15

Partial preview of the text

Download Propositional Logic-Software Engineering-Lecture 10 Slides-Computer Science and more Slides Software Engineering in PDF only on Docsity!

LECTURE 10: FIRST-ORDER LOGIC

Software Engineering

1 Why not Propositional Logic?

  • Consider the following statements: - all monitors are ready; - X12 is a monitor.
  • We saw in an earlier lecture that these statements are propositions: their meaning is either true or false.
  • Propositional logic is the most abstract level at which we can study logic.
  • As we shall say, it is too coarse grained to allow us to represent and reason about the kind of statement we need to write in formal specification.

2 First-Order Logic: Syntax

  • We shall now introduce a generalisation of propositional logic called first-order logic (FOL). This new logic affords us much greater expressive power.
  • First, we shall look at how the language of first-order logic is put together.

2.1 Terms

  • The basic components of FOL are called terms.
  • Essentially, a term is an object that denotes some object other than true or false.
  • The simplest kind of term is a constant.
  • A value such as 8 is a constant; the denotation of this term is the number 8 — a value that is contained in the sets IN and Z.
  • We often use constants in maths; we introduce them by writing things like

Let S be the set { 1 , 2 , 3 }.

In this case, we have introduced a constant and made its denotation clear; we have given it an interpretation.

  • We can have constants that stand for any kind of object; for example, we could have a constant that stood for (denoted) the individual ‘Michael Wooldridge’.
  • We can now introduce a more complex class of terms — functions.
  • The idea of functional terms in logic is similar to the idea of a function in programming: recall that in programming, a function is a procedure that takes some arguments, and returns a value. In Modula-2:

PROCEDURE f(a1:T1; ... an:Tn) : T;

this function takes n arguments; the first is of type T1, the second is of type T2, and so on. The function returns a value of type T.

  • In FOL, we have a set of function symbols; each symbol corresponds to a particular function. (It denotes some function.)
  • Each function symbol is associated with a natural number called its arity. This is just the number of arguments it takes.
  • Each function symbol has a return-type associated with it... -... and each function symbol has an argument type associated with it.
  • A functional term is then built up by applying a function symbol to the appropriate number of terms, of the appropriate type.
  • Formally...

Definition: Let f be an arbitrary function symbol of type T, with arity n ∈ IN, taking arguments of type T 1 ,... , Tn respectively. Also, let τ 1 ,... , τn be terms of type T 1 ,... , Tn respectively. Then f (τ 1 ,... , τn) is a functional term.

  • In maths, we have many functions; the obvious ones are + − / ∗ √^ sin cos...
  • The fact that we write

2 + 3 instead of something like plus(2, 3) is merely a matter of convention, and is not relevant from the point of view of logic; all these are functions in exactly the way we have defined.

  • Using functions, constants, and variables, we can build up expressions, e.g.: (x + 3) ∗ sin 90 (which might just as well be written times(plus(x, 3), sin(90)) for all it matters.)

2.2 Predicates

  • In addition to having terms, FOL has relational operators, which capture relationships between objects.
  • The language of FOL contains a stock of predicate symbols.
  • These symbols stand for relationships between objects.
  • Again, each predicate symbol has an associated arity... -... and each argument has a type.
  • Definition: Let P be a predicate symbol of arity n ∈ IN, which takes arguments of types T 1 ,... , Tn. Then if τ 1 ,... , τn are terms of type T 1 ,... , Tn respectively, then P(τ 1 ,... , τn) is a predicate, which will either be true or false under some interpretation.
  • So a predicate just expresses a relationship between some values.
  • What happens if a predicate contains variables: can we tell if it is true or false? Not usually; we need to know an interpretation for the variables.
  • A predicate that contains no variables is a proposition.
  • Predicates of arity 1 are called properties.
  • EXAMPLE. The follolwing are properties:

Man(x) Mortal(x) Malfunctioning(x).

  • Predicate that have arity 0 (i.e., take no arguments) are called primitive propositions.

3 Quantifiers

  • We now come to the central part of first order logic: quantification.
  • Consider trying to represent the following statements: - all men have a mother; - every natural number has a prime factor.
  • We can’t represent these using the apparatus we’ve got so far; we need quantifiers.
  • The simplest form of quantified formula in Z is as follows: quantifier signature • predicate where - quantifier is one of ∀, ∃, ∃ 1 ; - signature is of the form variable : type - and predicate is a predicate.

• EXAMPLES.

- ∀x : Man • Mortal(x) ‘For all x of type Man, x is mortal.’ (i.e. all men are mortal) - ∀x : Man • ∃ 1 y : Woman • MotherOf (x, y) ‘For all x of type Man, there exists a unique y of type Woman, such that y is the mother of x.’ - ∃m : Monitor • MonitorState(m, ready) ‘There exists a monitor that is in a ready state.’ - ∀r : Reactor • ∃ 1 t : 100.. 1000 • Temp(r) = t ‘Every reactor will have a temperature in the range 100 to 1000.’

4 Comments

  • Note that universal quantification is similar to conjunction: ∀n : { 2 , 4 , 6 } • Even(n) is the same as Even(2) ∧ Even(4) ∧ Even(6).
  • In the same way, existential quantification is the same as disjunction: ∃n : { 7 , 8 , 9 } • Prime(n) is the same as Prime(7) ∨ Prime(8) ∨ Prime(9).
  • The universal and existential quantifiers are in fact duals of each other: ∀x : T • P(x) ⇔ ¬∃x : T • ¬P(x) Saying that everything has some property is the same as saying that there is nothing that does not have the property. ∃x : T • P(x) ⇔ ¬∀x : T • ¬P(x) Saying that there is something that has the property is the same as saying that its not the case that everything doesn’t have the property.