Propositional Calculus

Similar documents
Mathematical Logic Prof. Arindama Singh Department of Mathematics Indian Institute of Technology, Madras. Lecture - 9 Normal Forms

Boolean Algebra A B A AND B = A*B A B A OR B = A+B

Propositional Calculus: Boolean Algebra and Simplification. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Propositional Calculus. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

Math 55 - Spring 04 - Lecture notes # 1 - Jan 20 (Tuesday)

2.2 Set Operations. Introduction DEFINITION 1. EXAMPLE 1 The union of the sets {1, 3, 5} and {1, 2, 3} is the set {1, 2, 3, 5}; that is, EXAMPLE 2

TA: Jade Cheng ICS 241 Recitation Lecture Notes #12 November 13, 2009

CSC Discrete Math I, Spring Sets

CS February 17

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

Propositional Logic Formal Syntax and Semantics. Computability and Logic

2. BOOLEAN ALGEBRA 2.1 INTRODUCTION

Program Verification & Testing; Review of Propositional Logic

Propositional Calculus. Math Foundations of Computer Science

Summary of Course Coverage

To prove something about all Boolean expressions, we will need the following induction principle: Axiom 7.1 (Induction over Boolean expressions):

STABILITY AND PARADOX IN ALGORITHMIC LOGIC

Formal Methods of Software Design, Eric Hehner, segment 1 page 1 out of 5

Information Science 1

CSE 20 DISCRETE MATH. Fall

Logic and Proof course Solutions to exercises from chapter 6

Lecture 5. Logic I. Statement Logic

COMP Intro to Logic for Computer Scientists. Lecture 2

Mathematical Logic Part One

Introduction to Computer Architecture

1 Introduction to Logic

BOOLEAN ALGEBRA AND CIRCUITS

Software Engineering Lecture Notes

Section 1.1 Logic LOGIC

CS Bootcamp Boolean Logic Autumn 2015 A B A B T T T T F F F T F F F F T T T T F T F T T F F F

CSE 20 DISCRETE MATH. Winter

Propositional Calculus. Math Foundations of Computer Science

Propositional Logic:

Computer Organization and Levels of Abstraction

Solutions to In-Class Problems Week 1, Fri

Mathematical Logic Part One

Relational & Logical Operators

Answer Key #1 Phil 414 JL Shaheen Fall 2010

LOGIC AND DISCRETE MATHEMATICS

Foundations of Computation

LECTURE 2 An Introduction to Boolean Algebra

III SEMESTER B. A. PHILOSOPHY PHL3B04 - SYMBOLIC LOGIC AND INFORMATICS QUESTION BANK FOR INTERNAL ASSESSMENT. Multiple Choice Questions

Computer Organization and Levels of Abstraction

== is a decent equivalence

Foundations of AI. 9. Predicate Logic. Syntax and Semantics, Normal Forms, Herbrand Expansion, Resolution

Logic Haskell Exercises

Mixed Integer Linear Programming

c) the set of students at your school who either are sophomores or are taking discrete mathematics

Chapter 3: Operators, Expressions and Type Conversion

Scheme Tutorial. Introduction. The Structure of Scheme Programs. Syntax

Henry Lin, Department of Electrical and Computer Engineering, California State University, Bakersfield Lecture 7 (Digital Logic) July 24 th, 2012

2.1 Sets 2.2 Set Operations

3. According to universal addressing, what is the address of vertex d? 4. According to universal addressing, what is the address of vertex f?

Evaluation of Predicate Calculus By Arve Meisingset, retired research scientist from Telenor Research Oslo Norway

Lecture Notes 15 Number systems and logic CSS Data Structures and Object-Oriented Programming Professor Clark F. Olson

CS40-S13: Functional Completeness

Review. EECS Components and Design Techniques for Digital Systems. Lec 05 Boolean Logic 9/4-04. Seq. Circuit Behavior. Outline.

COMP combinational logic 1 Jan. 18, 2016

Workbook Unit 13: Natural Deduction Proofs (IV)

Combinational Logic & Circuits

Geometry Note-Sheet Overview

Fondamenti della Programmazione: Metodi Evoluti. Lezione 5: Invariants and Logic

Notes. Notes. Introduction. Notes. Propositional Functions. Slides by Christopher M. Bourke Instructor: Berthe Y. Choueiry.

1.1 - Introduction to Sets

EE292: Fundamentals of ECE

Propositional Logic. Andreas Klappenecker

Mathematical Logic Part Two

MTH001 short notes. Interest is the cost of borrowing money.

(More) Propositional Logic and an Intro to Predicate Logic. CSCI 3202, Fall 2010

Homework 1. Due Date: Wednesday 11/26/07 - at the beginning of the lecture

Evaluation Trees for Proposition Algebra

Standard Boolean Forms

An Evolution of Mathematical Tools

2 Introduction to operational semantics

Chapter 1.3 Quantifiers, Predicates, and Validity. Reading: 1.3 Next Class: 1.4. Motivation

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

GC03 Boolean Algebra

Programming Languages Third Edition

LECTURE 17. Expressions and Assignment

Chapter 3. Set Theory. 3.1 What is a Set?

Introduction to Boolean Algebra

boolean.py Documentation

(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1

Cambridge International AS & A Level Computer Science

Introduction to Boolean Algebra

Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee

CS 380/480 Foundations of Artificial Intelligence Winter 2007 Assignment 2 Solutions to Selected Problems

BOOLEAN ALGEBRA. Logic circuit: 1. From logic circuit to Boolean expression. Derive the Boolean expression for the following circuits.

First-Order Predicate Logic. CSCI 5582, Fall 2007

Math Week in Review #5. A proposition, or statement, is a declarative sentence that can be classified as either true or false, but not both.

2. Sets. 2.1&2.2: Sets and Subsets. Combining Sets. c Dr Oksana Shatalov, Fall

CSC 501 Semantics of Programming Languages

CSE-6490B Assignment #1

Chapter 9 Deductive Arguments II Truth-Functional Logic. Tutorial: Truth Tables

Logic and its Applications

Interpretations and Models. Chapter Axiomatic Systems and Incidence Geometry

Computer Science. Unit-4: Introduction to Boolean Algebra

Propositional Calculus: Boolean Functions and Expressions. CS 270: Mathematical Foundations of Computer Science Jeremy Johnson

Sets. {1, 2, 3, Calvin}.

Transcription:

Propositional Calculus Proposition is a statement that is either or. Example 1 Propositions: It rains. Sun is shining and my coat is wet. If Ann plays with me, I give her a candy. x > 10 x = 1 and y < 10 Propositional variables are propositions, that is, they can only be assigned either the truth value or the truth value. Propositional constants and are denoted by symbols 1 (or T, standing for ) and 0 (or F, standing for ). Propositions can be denoted by propositional variables, e.g., A: Sun is shining. B: My coat is wet. C: x > 10 Assigning A = 1 (A is ) means that the proposition "Sun is shining" is (the case is that the sun is shining), assigning A = 0 (A is ) means that the proposition "Sun is shining" is (the case is that the sun is not shining). Assigning C = 1 means the case that x is greater than 10, assigning C = 0 means the case that x is not greater than ten, that is, x is less than or equal to 10. We can now state the proposition "Sun is shining and my coat is wet" in a more compact form: "A and B" (in fact, even in a more compact form: A B, using the logical "and" connective ). An atomic proposition is a proposition consisting of only a single propositional variable or a single propositional constant. Nonatomic propositions are called compound propositions, and they contain at least one logical connective. In a truth table we can list the truth values of a proposition under all possible assignments. Example 2 Truth table for the proposition A B: A B A B 0 0 0 0 1 0 1 0 0 1

With logical connectives propositions can be combined to form new propositions (cf., A B, where propositions A and B are combined with the connective ). Logical connectives ~ (negation), (conjunction), (disjunction), fi (conditional), «(biconditional) can be defined by means of truth tables. Notice, that the negation connective operates one proposition, all the other connectives operate with two propositions. Negation ~P can be pronounced "not P" P ~P 0 1 1 0 Conjunction P Q can be pronounced "P and Q" P Q P Q 0 0 0 0 1 0 1 0 0 Disjunction P Q can be pronounced "P or Q" P Q P Q 0 0 0 0 1 1 1 0 1 Conditional P Q can be pronounced "If P, then Q" P Q P Q 0 0 1 0 1 1 1 0 0 Biconditional P Q can be pronounced "P if and only if Q" P Q P Q 0 0 1 0 1 0 1 0 0 Example 3 Calculate (i.e., evaluate the truth values of the following logical expressions): ~1 solution: 0 1 0 solution: 0 2

0 1 solution: 1 1 1 solution: 1 1 0 solution: 0 Logical arguments, like "Sun is shining and my coat is wet.", can be written with propositional calculus notation with the help of the above pronounciation rules (and common sense). Example 4 Let's analyse the statement "If Ann plays with me, I give her a candy." as a logical argument. We can find two atomic propositions A: Ann plays with me. B: I give her (Ann) a candy. These two propositions can be combined with the "if.. then" connective ( ): A B. To check if this straightforward conversion is correct, we can find the truth table for the original argument and compare it to the truth table of proposition A B: Ann plays with me. (Ann doesn't play with me) (Ann doesn't play with me) (Ann plays with me) (Ann plays with me) I give her a candy. (I don't give her a candy) (I give her a candy) (I don't give her a candy) (I give her a candy) If Ann plays with me, I give her a candy. ( meaning that there is no conflict between the described situation and this argument) (to be strict, there is no conflict, because the argument doesn't say anything about the situation when Ann doesn't play) ( meaning that there is conflict between the described situation and this argument) Compare this to the truth table of A B and see that they are identical. Convert the following logical arguments to propositional calculus notation: 1. I give Ann a candy if and only if Ann plays with me. 2. I don't go to London or I go to London and send Bill a postcard. 3. I'll give you a candy or a doll. 4. I'll give you a candy but not my doll. In programming languages logical expressions may look different, because of the use of other notation than ours. However, the same logic works. For example, the expression True And False in Visual Basic evaluates False and the expression =AND(TRUE; FALSE) in Excel's spreadsheet evaluates FALSE. 3

The following table shows corresponding expressions. We suppose that A and B are valid logical expressions (logical or propotional variables, constants, or compound expressions) in the shown context: Propositional calculus notation Visual Basic notation Excel spreadsheet function notation ~A Not A =NOT(A) A B A And B =AND(A;B) A B A Or B =OR(A;B) A B A Imp B A B A Eqv B In many programming languages there is also an "exclusive or" operator (Xor), which is like Or, but "True Xor True" evaluates False. Parentheses are used to show the order of calculation. Example 5 3 * (2 + 5) = 3 * 7 = 21 1 (1 0) = 1 0 = 1 Example 6 Find the truth table for proposition A (A B). A B A B A (A B) 0 0 0 0 = 0 0 0 = 0 0 1 0 1 = 0 0 0 = 0 1 0 1 0 = 0 1 0 = 1 1 = 1 1 1 = 1 Normally, this is done more simply just by showing the results of each stage: A B A B A (A B) 0 0 0 0 0 1 0 0 1 0 0 1 1 Example 7 Find the truth table for proposition A (B C). A B C B C A (B C) 0 0 0 0 0 = 0 0 0 = 0 0 0 1 0 1 = 0 0 0 = 0 0 1 0 1 0 = 0 0 0 = 0 0 1 = 1 0 1 = 1 1 0 0 0 0 = 0 1 0 = 1 1 0 1 0 1 = 0 1 0 = 1 1 1 0 1 0 = 0 1 0 = 1 1 1 = 1 1 1 = 1 4

Find the truth tables for the following propositions: 5. ~A (A B) 6. A ~(A B) 7. A (A ~A) 8. A (B C) 9. ~(A (B C)) 10. ~A (B C) 11. A (B C) 12. (~A B) ((B A) B) 13. (A B) B 14. Write the above propositions with the Visual Basic notation. 15. Write the above propositions with no conditional or biconditional connectives with the Excel spreadsheet function notation. What is the order of calculation, if parentheses are missing? Precedence order of connectives: ~, ( and ), fi, «Example 8 There is precedence order between arithmetic operators + and *, namely * takes precedence over +. That is, 1 + 2 * 3 = 1 + (2 * 3) rather than (1 + 2) * 3. In the same way we use the precedence order of logical connectives: A B C is to be understood as (A B) C, not as A (B C), because takes precedence over. Notice, that there is no precedence order between and. Therefore, for example, expression A B C cannot be understood at all. It is not a proposition! However, in some programming languages there is a fixed order for the "and" and "or" operators, but make sure what it is, or, preferably, use parentheses to avoid errors. We can make use of the following rules, too: P Q R is understood as (P Q) R. P Q R is understood as (P Q) R. ~~P is understood as ~(~P). Example 9 (A C) B C is understood as ((A C) B) C. Show the order of calculation explicitly by inserting all the needed parentheses: 16. A B C 17. ~A B C 18. ~A B A B C 19. A B B 20. B A B 5

Remove all the parentheses that are not necessarily needed (the order of calculation should not be changed!): 21. (A (B C)) 22. (~A (B (A B))) C 23. (~A (B (A B))) C 24. ~(A (B (A B))) C 25. ~(A (B (A B))) C 26. (~A (A B)) (A (A B)) 27. (~A (A B)) (A ~(A B)) Equivalent propositions are such that evaluate the same truth values in all cases, whatever the truth values of the propotional variables are. Equivalence is denoted by the symbol. Example 10 Let's prove that ~A (A B) A (A B). A B ~A A B ~A (A B) A (A B) 0 0 1 0 1 1 0 1 1 0 1 1 1 0 0 0 0 0 1 1 0 Proposition that is in all cases, is called a tautology. Proposition that is in all cases, is called a contradiction. Example 11 (~A (A B)) (A (A B)) is a tautology. A set of equivalences should be learned by heart, in order to be able to manipulate logical expressions. Useful laws for manipulating expressions: Law P ~P 1 P ~P 0 P 0 P P 1 P P 1 1 P 0 0 P P P P P P ~(~P) P P Q Q P P Q Q P P Q Q P (P Q) R P (Q R) (P Q) R P (Q R) (P Q) R P (Q R) Name Tautology law Contradiction law Identity laws Domination laws Idempotent laws Double-negation law Commutative laws Associative laws 6

P (Q R) (P Q) (P R) P (Q R) (P Q) (P R) P (P Q) P P (P Q) P ~(P Q) ~P ~Q ~(P Q) ~P ~Q P Q ~P Q P Q (P Q) (Q P) Distributive laws Absorption laws De Morgan's laws removing conditionals and biconditionals Example 12 Let's simplify the expression ~A (A B) using the above equivalences (laws): ~A (A B) (~A A) B Associative law 1 B Tautology law B 1 Commutative law 1 Domination law It appears that ~A (A B) is a tautology. Let's take another: ~A (A B) (~A A) (~A B) Distributive law 1 (~A B) Tautology law (~A B) 1 Commutative law ~A B Identity law Example 13 A B C ~(A B) C Don't do the following: A B C A ~B C Example 14 A B C ~A (B C) Don't do the following: A B C ~A B C removing conditional Why is this incorrect? removing conditional Why is this incorrect? First, remove all conditionals and biconditionals, then simplify (so that equivalence holds at each stage): 28. ~B A B 29. A ~B B 30. (A ~B B) ((A ~B B) (A C ~B)) 31. ~(~A ~B C) 32. ~(A ~B) A 33. A ~B C 34. A ~B C ~A 35. A B ~A B C 36. A B C ~A ~B 7

Simplifying conditional expressions in programming languages is analogous with simplifying propositions. However, sometimes the simplification can be carried out even further, because the following equivalences hold: Not (a < b) a >= b Not (a > b) a <= b Not (a <= b) a > b Not (a >= b) a < b Not (a = b) a <> b Not (a <> b) a = b In many programming languages comparison operators take precedence over logical operators, e.g., Not (a < b) can be written as Not a < b, (x < 10) and (y = 1) can be written as x < 10 and y = 1. Example 15 x > 18 Or Not (x <= 18 Or y = 'John') x > 18 Or (x > 18 And y <> 'John') De Morgan's law x > 18 Absorption law Simplify: 37. Not (x <= 5 Or Not (x > 5 Or y < 3)) 38. Not (x < 5 And y = 1) Or x < 5 39. Not (x = 1 Or y = 2 Or z = 3) Or (x <> 1 And z <>3) 40. i < 1 Or Not (i < 1 Or y = 1) And i >= 1 And y <> 1 41. i >= 1 Or Not (i < 1 And x = 2) Or x <> 2 Or (i >= 1 And z = 3) How to construct a logical expression that behaves in a desired way? For example, you wish to construct an expression with three propositional variables A, B, and C, which behaves as shown in the following truth table: A B C? 0 0 0 0 0 0 1 0 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 1 0 0 0 The problem can also be formulated as follows: Find an expression for a truth function f, such that f(0,1,0) = f(1,0,1) = 1 (0 otherwise). One way to do this is by first writing expressions generating one desired -value, and then combining these expressions with the disjunction connective: f(a,b,c) = (~A B ~C) (A ~B C). This technique leads to an expression which is in the disjunctive normal form. 8

Another way to do this is by first writing expressions generating one desired value, and then combining these expressions with the conjuction connective: f(a,b,c) = (A B C) (A B ~C) (A ~B ~C) (~A B C) (~A ~B C) (~A ~B ~C). This technique leads to an expression which is in the conjunctive normal form. True or : 42. For any proposition, it is always possible to construct an equivalent proposition which does not contain conditional or biconditional connectives. 43. For any proposition, it is always possible to construct an equivalent proposition which contains only negation and conjunction connectives. 44. For any proposition, it is always possible to construct an equivalent proposition which contains only negation and disjunction connectives. Find an expression for a truth function f, such that 45. f(1,0) = 1 (0 otherwise) 46. f(1,0) = f(0,1) = 1 (0 otherwise) 47. f(0,0) = f(1,1) = f(1,0) = 1 (0 otherwise) 48. f(0,0,1) = f(1,1,0) = f(0,1,1) = 1 (0 otherwise) 49. f(1,1,1) = f(1,1,0) = f(1,0,0) = 0 (1 otherwise) 50. f(0,1,0,1,1,0,1) = f(1,1,0,1,1,1,0) = 1 (0 otherwise) 51. f(0,1,0,1,1,0,1) = f(1,1,0,1,1,1,0) = 0 (1 otherwise) Logical operations can be performed with microchips. Truth values are implemented as electrical currency levels (no currency:, currency: ). In microchip design the following symbols (or correspondents) are used: a b a b a b a b a ~ a AND OR NOT Construct microchip layouts for the following truth functions: 52. f(a,b) = (A B) ~B 53. f(a,b,c) = ((~A B) (~A ~B)) C 54. f(a,b,c) = (A B) ~((A B) C) 55. f(a,b,c,d) = (~A B) (~B C) ~(A B D) 56. f(0,0,1) = f(1,1,0) = f(0,1,1) = 1 (0 otherwise) 9