Logic: The foundation of reasoning

Slides:



Advertisements
Similar presentations
TRUTH TABLES Section 1.3.
Advertisements

TRUTH TABLES The general truth tables for each of the connectives tell you the value of any possible statement for each of the connectives. Negation.
CS128 – Discrete Mathematics for Computer Science
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
Today’s Topics n Review Logical Implication & Truth Table Tests for Validity n Truth Value Analysis n Short Form Validity Tests n Consistency and validity.
Logic: Connectives AND OR NOT P Q (P ^ Q) T F P Q (P v Q) T F P ~P T F
1 Section 1.2 Propositional Equivalences. 2 Equivalent Propositions Have the same truth table Can be used interchangeably For example, exclusive or and.
1 Math 306 Foundations of Mathematics I Math 306 Foundations of Mathematics I Goals of this class Introduction to important mathematical concepts Development.
Chapter 3 Introduction to Logic © 2008 Pearson Addison-Wesley. All rights reserved.
Copyright © Cengage Learning. All rights reserved.
Mathematical Induction Assume that we are given an infinite supply of stamps of two different denominations, 3 cents and and 5 cents. Prove using mathematical.
Adapted from Discrete Math
3.2 – Truth Tables and Equivalent Statements
Chapter 3 – Introduction to Logic The initial motivation for the study of logic was to learn to distinguish good arguments from bad arguments. Logic is.
Intro to Discrete Structures
Chapter 1 Section 1.4 More on Conditionals. There are three statements that are related to a conditional statement. They are called the converse, inverse.
Chapter 2 – Fundamentals of Logic. Outline Basic Connectives and Truth Tables Logical Equivalence: The Laws of Logic Ligical Implication: Rules of Inference.
Section 1-4 Logic Katelyn Donovan MAT 202 Dr. Marinas January 19, 2006.
Course Outline Book: Discrete Mathematics by K. P. Bogart Topics:
Discrete Maths 2. Propositional Logic Objective
Discrete Mathematics and Its Applications
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Chapter 1 The Logic of Compound Statements. Section 1.1 Logical Form and Logical Equivalence.
BY: MISS FARAH ADIBAH ADNAN IMK. CHAPTER OUTLINE: PART III 1.3 ELEMENTARY LOGIC INTRODUCTION PROPOSITION COMPOUND STATEMENTS LOGICAL.
1 Propositional Logic Proposition 2 Propositions can be divided into simple propositions and compound propositions. A simple (or basic) proposition is.
Chapter 5 – Logic CSNB 143 Discrete Mathematical Structures.
Math 240: Transition to Advanced Math Deductive reasoning: logic is used to draw conclusions based on statements accepted as true. Thus conclusions are.
Fall 2002CMSC Discrete Structures1 Let’s get started with... Logic !
Logical Form and Logical Equivalence Lecture 2 Section 1.1 Fri, Jan 19, 2007.
HAWKES LEARNING Students Count. Success Matters. Copyright © 2015 by Hawkes Learning/Quant Systems, Inc. All rights reserved. Section 3.2 Truth Tables.
CSNB143 – Discrete Structure LOGIC. Learning Outcomes Student should be able to know what is it means by statement. Students should be able to identify.
LOGIC Lesson 2.1. What is an on-the-spot Quiz  This quiz is defined by me.  While I’m having my lectures, you have to be alert.  Because there are.
Chapter 7 Logic, Sets, and Counting
Chapter 3: Introduction to Logic. Logic Main goal: use logic to analyze arguments (claims) to see if they are valid or invalid. This is useful for math.
Chapter 8 – Symbolic Logic Professor D’Ascoli. Symbolic Logic Because the appraisal of arguments is made difficult by the peculiarities of natural language,
Propositional Logic. Propositions Any statement that is either True (T) or False (F) is a proposition Propositional variables: a variable that can assume.
1 Introduction to Abstract Mathematics Expressions (Propositional formulas or forms) Instructor: Hayk Melikya
Lecture 9 Conditional Statements CSCI – 1900 Mathematics for Computer Science Fall 2014 Bill Pine.
Chapter 7 Logic, Sets, and Counting Section 1 Logic.
Section 1.2: Propositional Equivalences In the process of reasoning, we often replace a known statement with an equivalent statement that more closely.
Logic. Statements, Connectives, and Quantifiers In symbolic logic, we only care whether statements are true or false – not their content. In logic, a.
Propositional Logic ITCS 2175 (Rosen Section 1.1, 1.2)
Extra slides for Chapter 3: Propositional Calculus & Normal Forms Based on Prof. Lila Kari’s slides For CS2209A, 2009 By Dr. Charles Ling;
Logical Form and Logical Equivalence Lecture 1 Section 1.1 Wed, Jan 12, 2005.
Logical Form and Logical Equivalence M Logical Form Example 1 If the syntax is faulty or execution results in division by zero, then the program.
Chapter 2 Logic 2.1 Statements 2.2 The Negation of a Statement 2.3 The Disjunction and Conjunction of Statements 2.4 The Implication 2.5 More on Implications.
1 Propositional Logic Introduction. 2 What is propositional logic? Propositional Logic is concerned with propositions and their interrelationships. 
Chapter 1: The Foundations: Logic and Proofs
Section 1.1. Section Summary Propositions Connectives Negation Conjunction Disjunction Implication; contrapositive, inverse, converse Biconditional Truth.
CSNB143 – Discrete Structure Topic 4 – Logic. Learning Outcomes Students should be able to define statement. Students should be able to identify connectives.
TRUTH TABLES. Introduction The truth value of a statement is the classification as true or false which denoted by T or F. A truth table is a listing of.
Outline Logic Propositional Logic Well formed formula Truth table
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
 2012 Pearson Education, Inc. Slide Chapter 3 Introduction to Logic.
Foundations of Discrete Mathematics Chapter 1 By Dr. Dalia M. Gil, Ph.D.
Discrete Mathematical Structures: Theory and Applications 1 Logic: Learning Objectives  Learn about statements (propositions)  Learn how to use logical.
Chapter 1. Chapter Summary  Propositional Logic  The Language of Propositions (1.1)  Logical Equivalences (1.3)  Predicate Logic  The Language of.
Chapter 1 Logic and proofs
Logic.
2. The Logic of Compound Statements Summary
DISCRETE MATHEMATICS CHAPTER I.
CSNB 143 Discrete Mathematical Structures
Lecture 1 – Formal Logic.
Truth Tables and Equivalent Statements
Information Technology Department
CS201: Data Structures and Discrete Mathematics I
Foundations of Discrete Mathematics
CS201: Data Structures and Discrete Mathematics I
Concepts of Computation
LOGICAL EQUIVALENCES - DISCRETE MATHEMATICS.
Presentation transcript:

Mathematical Structures for Computer Science Chapter 1 Formal Logic Mathematical Structures for Computer Science Chapter 1 Copyright © 2006 W.H. Freeman & Co. MSCS Slides Formal Logic

Logic: The foundation of reasoning What is formal logic? Multiple definitions Foundation for organized and careful method of thinking that characterizes reasoned activity The study of reasoning : specifically concerned with whether something is true or false Formal logic focuses on the relationship between statements as opposed to the content of any particular statement. Applications of formal logic in computer science: Prolog: programming languages based on logic. Circuit Logic: logic governing computer circuitry. Section 1.1 Statements, Symbolic Representations and Tautologies

Statements, Symbolic Representations and Tautologies Definition of a statement: A statement, also called a proposition, is a sentence that is either true or false, but not both. Hence the truth value of a statement is T (1) or F (0) Examples: Which ones are statements? All mathematicians wear sandals. 5 is greater than –2. Where do you live? You are a cool person. Anyone who wears sandals is an algebraist. Section 1.1 Statements, Symbolic Representations and Tautologies

Statements, Symbolic Representations and Tautologies Statements and Logic An example to illustrate how logic really helps us (3 statements written below): All mathematicians wear sandals. Anyone who wears sandals is an algebraist. Therefore, all mathematicians are algebraists. Logic is of no help in determining the individual truth of these statements. However, if the first two statements are true, logic assures the truth of the third statement. Logical methods are used in mathematics to prove theorems and in computer science to prove that programs do what they are supposed to do. Section 1.1 Statements, Symbolic Representations and Tautologies

Statements and Logical Connectives Usually, letters like A, B, C, D, etc. are used to represent statements. Logical connectives are symbols such as Λ, V, ,  Λ represents and  represents implication A statement form or propositional form is an expression made up of statement variables (such as A and B) and logical connectives (such as Λ, V, , ) that becomes a statement when actual statements are substituted for the component statement variables. Example: (A V A)  (B Λ B) Section 1.1 Statements, Symbolic Representations and Tautologies

Definitions for Logical Connectives Connective # 1: Conjunction (symbol Λ) If A and B are statement variables, the conjunction of A and B is A Λ B, which is read “A and B”. A Λ B is true when both A and B are true. A Λ B is false when at least one of A or B is false. A and B are called the conjuncts of A Λ B. Connective # 2: Disjunction (symbol V) If A and B are statement variables, the disjunction of A and B is A V B, which is read “A or B”. A V B is true when at least one of A or B is true. A V B is false when both A and B are false. A and B are called the disjuncts of A V B. Section 1.1 Statements, Symbolic Representations and Tautologies

Definitions for Logical Connectives Connective # 3: Implication (symbol ) If A and B are statement variables, the symbolic form of “if A then B” is A  B. This may also be read “A implies B” or “A only if B.”Here A is called the hypothesis/antecedent statement and B is called the conclusion/consequent statement. “If A then B” is false when A is true and B is false, and it is true otherwise. Note: A  B is true if A is false, regardless of the truth of B Example: If Ms. X passes the exam, then she will get the job Here B is She will get the job and A is Ms. X passes the exam. The statement states that Ms. X will get the job if a certain condition (passing the exam) is met; it says nothing about what will happen if the condition is not met. If the condition is not met, the truth of the conclusion cannot be determined; the conditional statement is therefore considered to be vacuously true, or true by default. Section 1.1 Statements, Symbolic Representations and Tautologies

Another form of implication Representation of If-Then as Or Let A be “You do your homework” and B be “You will flunk.” The given statement is “Either you do your homework or you will flunk,” which is A V B. In if-then form, A  B means that “If you do not do your homework, then you will flunk,” where A (which is equivalent to A) is “You do not do your homework.” Hence, A  B  A V B A B AB T F A A B A V B T F Section 1.1 Statements, Symbolic Representations and Tautologies

Definitions for Logical Connectives Connective # 4: Equivalence (symbol ) If A and B are statement variables, the symbolic form of “A if, and only if, B” and is denoted A  B. It is true if both A and B have the same truth values. It is false if A and B have opposite truth values. The truth table is as follows: Note: A  B is a short form for (A  B) Λ (B  A) A B AB BA (A  B) Λ (B  A) T F Section 1.1 Statements, Symbolic Representations and Tautologies

Definitions for Logical Connectives Connective #5: Negation (symbol ) If A is a statement variable, the negation of A is “not A” and is denoted A. It has the opposite truth value from A: if A is true, then A is false; if A is false, then A is true. Example of a negation: A: 5 is greater than –2 A : 5 is less than –2 B: She likes butter B : She dislikes butter / She hates butter A: She hates butter but likes cream / She hates butter and likes cream A : She likes butter or hates cream Hence, in a negation, and becomes or and vice versa Section 1.1 Statements, Symbolic Representations and Tautologies

Statements, Symbolic Representations and Tautologies Truth Tables A truth table is a table that displays the truth values of a statement form which correspond to the different combinations of truth values for the variables. A B A Λ B T F A B A V B T F A A T F A B AB T F A B AB T F Section 1.1 Statements, Symbolic Representations and Tautologies

Well Formed Formula (wff) Combining letters, connectives, and parentheses can generate an expression which is meaningful, called a wff. e.g. (A  B) V (B  A) is a wff but A )) V B ( C) is not To reduce the number of parentheses, an order is stipulated in which the connectives can be applied, called the order of precedence, which is as follows: Connectives within innermost parentheses first and then progress outwards Negation () Conjunction (Λ), Disjunction (V) Implication () Equivalence () Hence, A V B  C is the same as (A V B)  C Section 1.1 Statements, Symbolic Representations and Tautologies

Truth Tables for some wffs The truth table for the wff A V B  (A V B) shown below. The main connective, according to the rules of precedence, is implication. A B B A V B A V B (A V B) A V B  (A V B) T F Section 1.1 Statements, Symbolic Representations and Tautologies

Wff with n statement letters The total number of rows in a truth table for n statement letters is 2n. Section 1.1 Statements, Symbolic Representations and Tautologies

Tautology and Contradiction Letters like P, Q, R, S etc. are used for representing wffs [(A V B) Λ C]  A V C can be represented by P  Q where P is the wff [(A V B) Λ C] and Q represents A V C Definition of tautology: A wff that is intrinsically true, i.e. no matter what the truth value of the statements that comprise the wff. e.g. It will rain today or it will not rain today ( A V A ) P  Q where P is A  B and Q is A V B Definition of a contradiction: A wff that is intrinsically false, i.e. no matter what the truth value of the statements that comprise the wff. e.g. It will rain today and it will not rain today ( A Λ A ) (A Λ B) Λ A Usually, tautology is represented by 1 and contradiction by 0 Section 1.1 Statements, Symbolic Representations and Tautologies

Tautological Equivalences Two statement forms are called logically equivalent if, and only if, they have identical truth values for each possible substitution of statements for their statement variables. The logical equivalence of statement forms P and Q is denoted by writing P  Q or P  Q. Truth table for (A V B) V C  A V (B V C) A B C A V B B V C (A V B) V C A V (B V C) T F Section 1.1 Statements, Symbolic Representations and Tautologies

Some Common Equivalences The equivalences are listed in pairs, hence they are called duals of each other. One equivalence can be obtained from another by replacing V with Λ and 0 with 1 or vice versa. Prove the distributive property using truth tables. Commutative A V B  B V A A Λ B  B Λ A Associative (A V B) V C  A V (B V C) (A Λ B) Λ C  A Λ (B Λ C) Distributive A V (B Λ C)  (A V B) Λ (A V C) A Λ (B V C)  (A Λ B) V (A Λ C) Identity A V 0  A A Λ 1  A Complement A V A  1 A Λ A  0 Section 1.1 Statements, Symbolic Representations and Tautologies

Statements, Symbolic Representations and Tautologies De Morgan’s Laws (A V B)  A Λ B (A Λ B)  A V B Conditional Statements in programming use logical connectives with statements. Example if((outflow inflow) and not(pressure 1000)) do something; else do something else; A B A B A V B (A V B) A Λ B T F Section 1.1 Statements, Symbolic Representations and Tautologies

Statements, Symbolic Representations and Tautologies Algorithm Definition of an algorithm: A set of instructions that can be mechanically executed in a finite amount of time in order to solve a problem unambiguously. Algorithms are the stage in between the verbal form of a problem and the computer program. Algorithms are usually represented by pseudocode. Pseudocode should be easy to understand even if you have no idea of programming. Section 1.1 Statements, Symbolic Representations and Tautologies

Statements, Symbolic Representations and Tautologies Pseudocode example j = 1 // initial value Repeat read a value for k if ((j < 5) AND (2*j < 10) OR ((3*j)1/2 > 4)) then write the value of j otherwise write the value of 4*j end if statement increase j by 1 Until j > 6 Section 1.1 Statements, Symbolic Representations and Tautologies

Tautology Test Algorithm This algorithm applies only when the main connective is Implication () TautologyTest(wff P; wff Q) //Given wffs P and Q, decides whether the wff P  Q is a tautology. //Assume P  Q is not a tautology P = true // assign T to P Q = false // assign F to Q repeat for each compound wff already assigned a truth value, assign the truth values determined for its components until all occurrences of statements letters have truth values if some letter has two truth values then //contradiction, assumption false write (“P  Q is a tautology.”) else //found a way to make P  Q false write (“P  Q is not a tautology.”) end if end TautologyTest Section 1.1 Statements, Symbolic Representations and Tautologies