190 likes | 339 Views
CMPF144 FUNDAMENTALS OF COMPUTING THEORY. Module 5: Classical Logic. Objectives. To understand what is the meaning of Logic and Classical Logic. To understand what is informal and formal language To understand principles of developing a formal language. Introduction.
E N D
CMPF144FUNDAMENTALS OF COMPUTING THEORY Module 5: Classical Logic
Objectives To understand what is the meaning of Logic and Classical Logic. To understand what is informal and formal language To understand principles of developing a formal language CMPF144 Fundamentals of Computing Theory
Introduction • Logic : - is a study of valid reasoning • Logic 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.” CMPF144 Fundamentals of Computing Theory
Definitions A logic consists of a formal or informal language together with a deductive system and/or a model-theoretic semantics Language is, or corresponds to, a part of a natural language Deductive System is to capture, codify, or simply record, which inferences are correct for the given language Semantics is to capture, codify, or record the meanings, or truth-conditions, or possible truth conditions, for at least part of the language CMPF144 Fundamentals of Computing Theory
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 Λ CMPF144 Fundamentals of Computing Theory
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 CMPF144 Fundamentals of Computing Theory
Formal & Informal Languages • Without some information on this language, it may look like it doesn’t have a meaning • Sometimes, 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 CMPF144 Fundamentals of Computing Theory
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 CMPF144 Fundamentals of Computing Theory
Formal vs Informal (Natural) Languages • The formula for the above sentence in Formal Language could be A & B V C • Is this supposed to be ((A & B) V C), or is it (A & (B V C)) ? • Parentheses solves this ambiguity CMPF144 Fundamentals of Computing Theory
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 CMPF144 Fundamentals of Computing Theory
Developing Formal Language (cont.) • Variables serve a dual function • used 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 CMPF144 Fundamentals of Computing Theory
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, B32, P3, etc CMPF144 Fundamentals of Computing Theory
Developing Formal Language (cont.) • Compound Formula • The symbols (operator) used in Formal Language are: • ¬, &, Ѵ, , ∀, ∃,(, ) • That is, all formulas are constructed in accordance with these rules CMPF144 Fundamentals of Computing Theory
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 Ψ . CMPF144 Fundamentals of Computing Theory
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". CMPF144 Fundamentals of Computing Theory
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 θ ". CMPF144 Fundamentals of Computing Theory
Conclusion • Logic is a study of a valid reasoning – how we determined or conclude whether a statement is valid or invalid • To 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. CMPF144 Fundamentals of Computing Theory
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 Є db Reads: 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) CMPF144 Fundamentals of Computing Theory
Example of Formal Language • Z Language • B Language • RAISE (Rigorous Approach to Industrial Software Engineering ) Language • COLD (Common Object-oriented Language for Design )Language • Many more… (search the Internet for more informations) CMPF144 Fundamentals of Computing Theory