19
CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Embed Size (px)

Citation preview

Page 1: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

CMPF144FUNDAMENTALS OF COMPUTING THEORY

Module 5: Classical Logic

Page 2: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 2

Objectives

To understand what is the meaning of Logic and Classical Logic.To understand what is informal and formal languageTo understand principles of developing a formal language

Page 3: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 3

Introduction

Logic : - is a study of valid reasoningLogic tries to establish criteria to decide some piece of reasoning is valid (TRUE) or invalid (FALSE)Reasoning consist of statements some of which are

claimed to follow from previous ones. For example:“If I win the lottery, then I’m happy. However, I did not win

the lottery. Therefore, I am not happy.”

claimed to be inferred from others. For example:

“Either the housemaid or the butler killed Mr X. However, if the housemaid would have done it, the alarm would have gone off, and the alarm did not go off. Therefore, the butler did it.”

Page 4: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 4

Definitions

A logic consists of a formal or informal language together with a deductive system and/or a model-theoretic semanticsLanguage is, or corresponds to, a part of a natural languageDeductive System is to capture, codify, or simply record, which inferences are correct for the given languageSemantics is to capture, codify, or record the meanings, or truth-conditions, or possible truth conditions, for at least part of the language

Page 5: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 5

Formal & Informal Languages

The formal language is a recursively defined collection of strings on a fixed alphabet.is a set of finite-length words (i.e. character strings) drawn from some finite alphabets

Example:{a,b} :- possible strings ababab, ab, ba, baba{a,m,n,t} :- possible strings man, ant, tan, amn,empty word is possible (zero-length string) and is often denoted by e, ε or Λ

Page 6: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 6

Examples (more)

the set of all words over a,b the set {an}, n is a prime number and an means a repeated n times the set of syntactically correct programs in a given programming language; or the set of inputs upon which a certain Turing machine halts

Page 7: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 7

Formal & Informal Languages

Without some information on this language, it may look like it doesn’t have a meaningSometimes, it has no meaning (refer to examples)Sometimes, is has better meaning where the meaning of the formulas is given by the deductive system and the semantics

Page 8: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 8

Formal vs Informal (Natural) Languages

Formal languages accurately exhibit actual features of certain fragments of a natural language

Natural languages are vague and ambiguous, they should be replaced by formal languages

Example:John is married, and Mary is single, or Joe is crazy It can mean that John is married and either Mary is single or Joe is crazy, or else it can mean that either both John is married and Mary is single, or else Joe is crazy

Page 9: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 9

Formal vs Informal (Natural) Languages

The formula for the above sentence in Formal Language could be A & B V CIs this supposed to be ((A & B) V C), or is it (A & (B V C)) ?Parentheses solves this ambiguity

Page 10: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 10

Developing Formal Language

Building block of Formal Language Singular Terms - linguistic items whose

function is to denote a person or object or subject

individual constants - These are lower-case letters, near the beginning of the Roman alphabet, with or without numerical subscripts: a, a1, b23, c, d22, etc

individual variables - These are lower-case letters, near the end of the alphabet, with or without numerical subscripts: w, x, y12, z, z4, etc

Page 11: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 11

Developing Formal Language (cont.)

Variables serve a dual functionused as a singular term to denote a

specific, but unspecified (or arbitrary) object. For example, a mathematician might start a derivation: "Let x be a natural number".

used to express generality, as in the mathematical assertion that for any natural number x, there is a natural number y, such that y>x and y is prime. Some logicians employ different symbols for unspecified objects (sometimes called "individual parameters") and variables used to express generality

Page 12: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 12

Developing Formal Language (cont.)

For each natural number n, n-place predicate letters - These are upper-case letters at the beginning or middle of the alphabet. A superscript indicates the number of places, and there may or may not be a subscript. For example : A3, B3

2, P3, etc

Page 13: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 13

Developing Formal Language (cont.)

Compound FormulaThe symbols (operator) used in Formal Language are:

¬, &, Ѵ, , ∀, ∃,(, )

That is, all formulas are constructed in accordance with these rules

Page 14: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 14

Developing Formal Language (cont.)

Negation (¬ θ) ¬ is equivalent to denying the sentence corresponding to θ

AND (&) "and" is used to connect sentences. So (Φ &Ψ ) can be read " and ". The formula (Φ &Ψ ) is called the "conjunction" of Φ and Ψ .

Page 15: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 15

Developing Formal Language (cont.)

OR (Ѵ)

corresponds to "either . . . or . . . or both", so (Φ Ѵ Ψ ) can be read " or ". The formula (Φ Ѵ Ψ ) is called the "disjunction" of Φ and Ψ

If .. Then ( )The arrow “" corresponds to "if . . . then . . . ", so (Φ Ψ ) can be read "if Φ then Ψ " or " Ψ only if Φ ".

The symbols "&", " Ѵ ", and “" are called "binary connectives", since they serve to "connect" two sentences into one. Some authors introduce ( ) as an abbreviation of ((Φ Ψ ) & (Ψ Φ )). The symbol “ " is an analogue of the locution "if and only if".

Page 16: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 16

Developing Formal Language (cont.)

For All (∀ )

The symbol "∀" is called a universal quantifier, and is an analogue of "for all"; so ∀v θ can be read "for all v, θ ".

There is (∃ )

The symbol "∃" is called an existential quantifier, and is an analogue of "there exists" or "there is"; so ∃v θ can be read "there is a v such that θ ".

Page 17: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 17

Conclusion

Logic is a study of a valid reasoning – how we determined or conclude whether a statement is valid or invalidTo study logic, we need to study the language used to describe a statement, the deductive system and as well as the semantic aspect of a formal language.Formal language is used to avoid ambiguity in natural language.There are guidelines to write formal language such as a formula.

Page 18: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 18

Example (RAISE Language)

∀x: Nat ● (x = 0) V (x >0)Reads: for all numbers x, either x is equal to 0 or x is greater than

0

∀p: Person, db: Database ● check (p,db) p Є dbReads: for all people p and for all database db, if the

predicate check (p,db) holds, then p Є db(A person is registered if that person belongs to the set

representing the database)

∀ x, y : Nat ● ∃!z: Nat ● x + y = z (note: ∃! = ‘there exists exactly one’)

∃ x, y: Nat, b: Bool ● b = (x = y)

Page 19: CMPF144 FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic

Module 8 CMPF144 Fundamentals of Computing Theory

Slide 19

Example of Formal Language

Z LanguageB LanguageRAISE (Rigorous Approach to Industrial Software Engineering ) LanguageCOLD (Common Object-oriented Language for Design )LanguageMany more…(search the Internet for more informations)