CSS 342 Data Structures, Algorithms, and Discrete Mathematics I

Slides:



Advertisements
Similar presentations
Discrete Mathematics Lecture 1 Logic of Compound Statements
Advertisements

CSE 311: Foundations of Computing Fall 2013 Lecture 3: Logic and Boolean algebra.
Basic Structures: Sets, Functions, Sequences, Sums, and Matrices
Discrete Mathematics Lecture 1 Logic of Compound Statements Harper Langston New York University.
Syllabus Every Week: 2 Hourly Exams +Final - as noted on Syllabus
From Chapter 4 Formal Specification using Z David Lightfoot
Adapted from Discrete Math
CSCI2110 – Discrete Mathematics Tutorial 8 Propositional Logic Wong Chung Hoi (Hollis)
Mathematical Structures A collection of objects with operations defined on them and the accompanying properties form a mathematical structure or system.
Review I Rosen , 3.1 Know your definitions!
Boolean Algebra and Computer Logic Mathematical Structures for Computer Science Chapter 7.1 – 7.2 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Boolean.
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Lecture 4. CONDITIONAL STATEMENTS: Consider the statement: "If you earn an A in Math, then I'll buy you a computer." This statement is made up of two.
1 CMSC 250 Discrete Structures CMSC 250 Lecture 1.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CUSACK CHAPT 4.
September1999 CMSC 203 / 0201 Fall 2002 Week #1 – 28/30 August 2002 Prof. Marie desJardins.
Discrete Mathematics CS 2610 February 12, Agenda Previously Finished functions Began Boolean algebras And now Continue with Boolean algebras.
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.
Chapter 1: The Foundations: Logic and Proofs
Chapter 1: The Foundations: Logic and Proofs
Laws of Boolean Algebra Commutative Law Associative Law Distributive Law Identity Law De Morgan's Theorem.
رياضيات متقطعة لعلوم الحاسب MATH 226. Text books: (Discrete Mathematics and its applications) Kenneth H. Rosen, seventh Edition, 2012, McGraw- Hill.
CSS342: Propositions1 Professor: Munehiro Fukuda.
Discrete Mathematics Lecture # 4. Conditional Statements or Implication  If p and q are statement variables, the conditional of q by p is “If p then.
1 Georgia Tech, IIC, GVU, 2006 MAGIC Lab Rossignac Lecture 01: Boolean Logic Sections 1.1 and 1.2 Jarek Rossignac.
Discrete Math by R.S. Chang, Dept. CSIE, NDHU1 Fundamentals of Logic 1. What is a valid argument or proof? 2. Study system of logic 3. In proving theorems.
Chapter 2 1. Chapter Summary Sets (This Slide) The Language of Sets - Sec 2.1 – Lecture 8 Set Operations and Set Identities - Sec 2.2 – Lecture 9 Functions.
Discrete Structures for Computer Science Presented By: Andrew F. Conn Slides adapted from: Adam J. Lee Lecture #1: Introduction, Propositional Logic August.
Chapter 1 Propositional Logic
Discrete Mathematical
2. The Logic of Compound Statements Summary
Computer Science 210 Computer Organization
The Foundations: Logic and Proofs
Advanced Algorithms Analysis and Design
Propositional Equivalence
DISCRETE MATHEMATICS CHAPTER I.
Discrete Mathematics Lecture 1 Logic of Compound Statements
CSNB 143 Discrete Mathematical Structures
Lecture 1 – Formal Logic.
Discrete Mathematics Logic.
Discrete Mathematics Logic of Compound Statements
COMP 1380 Discrete Structures I Thompson Rivers University
6/20/2018 Arab Open University Faculty of Computer Studies M131 - Discrete Mathematics 6/20/2018.
MATH 245 Spring 2009 This is mathematics for computer science
CSE 311 Foundations of Computing I
COT 3100, Spr Applications of Discrete Structures
(CSC 102) Discrete Structures Lecture 2.
CPCS222 Discrete Structures I
Mathematics for Computing
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Chapter 8 Logic Topics
CSCI 3310 Mathematical Foundation of Computer Science
Administrivia Course Web:
Propositional Equivalences
Information Technology Department
CS 220: Discrete Structures and their Applications
CSE 311 Foundations of Computing I
Fundamentals of Computer Systems
Propositional Equivalences
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Discrete Mathematics and Its Applications Kenneth H
Discrete Mathematics Logic.
Cs Discrete Mathematics
COMP 1380 Discrete Structures I Thompson Rivers University
Logic Logic is a discipline that studies the principles and methods used to construct valid arguments. An argument is a related sequence of statements.
Discrete Structures Prepositional Logic 2
The Foundations: Logic and Proofs
Concepts of Computation
Presentation transcript:

CSS 342 Data Structures, Algorithms, and Discrete Mathematics I Lecture 18. 161206. CUSACK CHAPT 4.

Agenda Program 4 Graded Program 5 Design Graded Final Exam: 12/15 Program 5 Questions Example building on linux Propositional logic Course Evals

Lab 5: What to turn in Turn in: How will we grade this? All .cpp and .h files for your project (incl. stdafx.cpp, stdafx, …) Output file called BankTransOut.txt which is your program run against sample input on site Account.exe > BankTransOut.txt 2>&1 Your .exe or a.out file How will we grade this? Place all of your .cpp/.h in a directory and build using Cl *cpp g++ *cpp or g++ -std=c++11 *cpp Run the created .exe/a.out against a number of test BankTrans.txt files PLEASE PRACTICE THIS YOURSELF BEFORE TURNING IN

Propositional Logic

Text Book An Active Introduction to Discrete Mathematics and Algorithms (version 2.6), Charles Cusack, David Santos, GNU Free Software, 2016: http://www.cs.hope.edu/~cusack/Notes/Notes/Books/Active%20Introduction%20to%20Discrete%20M athematics%20and%20Algorithms/ActiveIntroToDiscreteMathAndAlgorithms.2.6.pdf Chapter 4: Logic.

Propositions Proposition: a statement that is either true or false, but not both Examples of propositions Proposition p: All mathematicians wear sandals. Proposition r: Discrete Math is fun. Proposition v: This is not a proposition. Proposition s: The sum of the first n odd integer is equal to n2 for n >1. These are not propositions: What is your name? Go to the store and get me a steak? Propositions have a truth value: True or False.

Propositions Math History Programming languages The only positive integers that divide 7 are 1 and 7 itself: (true) For every positive integer n, there is a prime number larger than n: (true) History Alejandro Inarritu won an Academy Award in 1999 for directing “Amores perros”: (false, he won in 2015 for Birdman) Seattle held the World’s Fair, Expo 62: (true ) Programming languages Boolean expressions in if-else, while, and for statements for ( index = 0; index < 100; index++ ) { …….; } A proposition Not a proposition

Compound propositions Conjunction (AND) of p and q notations: p ^ q, p && q True only if both p and q are true Truth table Disjunction (OR) of p or q Notations: p v q, p || q True if either p or q or both are true truth table p q p ^ q F T p q p v q F T

Compound Propositions The negation (NOT) of p Notations: not p, ¬p !p Examples P: 1 + 1 = 3 (false) !p: !(1 + 1 = 3) ≡ 1 + 1 ≠ 3 (true) Exclusive OR (XOR) Notations: p xor q, p !p F T p q p q F T

Binary Expressions in C++ How do you examine the behavior of if-else? if ( a > = 1 && a <= 100 ) true if 1 ≤ a ≤ 100 if ( a >= 1 || a <= 100 ) always true a < 1 1 <= a <= 100 100 < a a >= 1 a <= 100 false true condition proposition a < 1 1 <= a <= 100 100 < a a >= 1 a <= 100 false true condition proposition

Theorems for Boolean algebra Commutative Law p v q = q v p p ^ q = q ^ p Associative Law p v (q v r) = (p v q) v r p ^ (q ^ r) = (p ^ q) ^ r Distributive Law p ^ (q v r) = (p ^ q) v (p ^ r) p v (q ^ r) = (p v q) ^ (p v r) Identity p v F = p P ^ T = p Domination p v T = T p ^ F = F Complement Law (tautologies) p ^ ¬p = F p v ¬p = T Square Law p ^ p = p p v p = p Double Negation ¬(¬p) = p Absorption p ^ (p v q) = p p v (p ^ q) = p

Precedence of Operators NOT: ¬ AND: ^ XOR: OR: v Conditional: → iff: ↔

Prove the following Boolean equations ¬p ^ q v p ^ ¬q = (¬p v ¬q) ^ (p v q) p ^ q v p ^ q ^ r v p ^ ¬ q = p (p ^ q v r ) ^ q = p ^ q ^ ¬r v ¬p ^ q ^ r v p ^ q ^ r

Truth Tables Table iterating all possible combinations for a proposition Example: p ^ q v p ^ r p q r p ^ q p ^ r p ^ q v p ^ r 1

Conditional Propositions Given two propositions such as p and q, If p then q or p → q is called a conditional proposition. P: hypothesis, antecedent, or sufficient condition Q: conclusion, consequent, or necessary condition

Computer Scientist of the week George Boole English Mathematician, Philosopher and Logician Wrote: “An Investigation of the Laws of Thought (1854), on Which are Founded the Mathematical Theories of Logic and Probabilities” Found of Boolean Algebra, the Algebra of logic Logical propositions expressed as algebras bool keyword named after him Died by the fever started by walking to class in the rain to lecture

Truth Table of Conditional Propositions Chair Statement: if CSS gets an additional $80,000, it will hire one new faculty member. P: CSS gets an additional $80,000. Q: CSS will hire one new faculty member. If both p and q are true, the chair said a correct statement. If p is true but q is false, the chair said a wrong statement. If p is false, the chair is not responsible for his statement. We should regard it as true. p q p → q T F

Course Evaluation https://uwb.iasystem.org/survey/14944

Class Bell

If and only if Given two propositions such as p and q, p if and only if q or p <-> q Called a bi-conditional proposition. True when p and q have the same truth value False otherwise p iff q Show the truth table for: (p <-> q)<-> (q <-> p)

In-class problem Let p, q, and r be the propositions. p: Grizzly bears have been seen in the area. q: Hiking is safe on the trail. r: Berries are ripe along the trail. Write these propositions using p, q, and r and logical connectives. Berries are ripe along the trail and grizzly bears have not been seen in the area. Grizzly bears have not been seen in the area and hiking on the trail is safe and berries are ripe along the trail If berries are ripe along the trail, then hiking is safe if and only if grizzly bears have not been seen in the area. It is not safe to hike on the trail; grizzly bears have not been seen in the area and the berries along the trail are ripe. For hiking on the trail to be safe, it is necessary but not sufficient that berries not be ripe along the trail and for grizzly bears not to have been seen in the area. Hiking is not safe on the trail whenever grizzly bears have been seen in the area and berries are ripe along the trail.

De Morgan’s Laws Show De Morgan’s Law is true p q p ^ q ¬(p ^ q) ¬p ¬q ¬(p ^ q) ≡ ¬p v ¬q ¬(p v q) ≡ ¬p ^ ¬q p q p ^ q ¬(p ^ q) ¬p ¬q ¬p v ¬q T F CSS342: Propositions

Logical Equivalence If two different compound propositions have the same truth values they are called logically equivalent Show: ¬(p v q) ≡ ¬p ^ ¬q p q p v q ¬(p v q) ¬p ¬q ¬p ^ ¬q T F CSS342: Propositions

Logical Equivalence Let p and q be propositions Some definitions: P is a tautology if it is always true P is a contradiction if it is always false P is a contingency if it can be either true or false depending on input p and q are logically equivalent iff p = q p and q have the same truth tables Also written, q ≡ p Show: ¬p v q ≡ p -> q

¬p v q ≡ p -> q p q ¬p ¬p v q p -> q T F

Logical Equivalence if p then q ≡ p only if q ≡ not p or q all called logically equivalent. If John takes CSS342, he advances to CSS343 John may take CSS342 only if he advances to CSS343. John does not take CSS342 or he advances to CSS343.

Logical Equivalence For each pair of propositions P and Q, show whether or not P ≡ Q. P: p, Q: p v q P: p → q, Q: ¬p v q P: p → q, Q: ¬ q → ¬ p P: (p → q) ^ (q → r), Q: p → r P: (p → q) → r, Q: p → (q → r)