LOGIC
Introduction:
Logic is the discipline that deals with the methods of reasoning. On an elementary level, logic provides rules and techniques for determining whether a given argument is valid. Logical reasoning is used in Computer Science to verify (menentusahkan) the correctness (kesahihan) of programs and to prove (membuktikan) theorems.
2.1 Proposition and Logical Operations
• Statement or proposition → declarative sentence that is either true or false, but not both
Example 1: Which of the following are statements? (a) The earth is round (b) 3 + 7 = 8 (c) Do you speak English? (d) 3 – x = 5 (e) Take two aspirins (f) The temperature is 35oC (g) The sun will come out tomorrow
2.1.1 Logical connectives and compound statements
• In logic, the letters p, q, r… denote propositional variables; that is, variables that can be replaced by statements
Example 2: p: The sun is shining today q: It is cold r: 3 x 4 = 16
• Statements or propositional variables can be combined by logical connectives (pengait logik) to obtained compound statements (pernyataan majmuk)
Example 3: Statements p and q in example 2 can be combined by the connective and to form the compound statement
p and q: The sun is shining today and it is cold
• The truth value of a compound statement depends only on the truth values of the statements being combined and on the types of connectives being used
ϖ If p is a statement, the negation (peniadaan) of p is the statement not p, denoted by ~p
Example 4: p: today is raining ~p: today is not raining
• If p is true, then ~p is false, and if p is false, then ~p is true
• Truth table → a table that gives the truth values of a compound statement in