Bits and Bit Operations. Today s topics

Similar documents
Topic #3 Predicate Logic. Predicate Logic

The Fundamentals of Logic. Foundations of Logic. Foundations of Logic. CMSC 302 Propositional Logic. In Rosen, ~98 slides, ~3 lectures

ICS141: Discrete Mathematics for Computer Science I

ICS141: Discrete Mathematics for Computer Science I

Propositional logic ( ): Review from Mat 1348

Discrete Mathematics and Applications COT3100

2/2/2018. CS 103 Discrete Structures. Chapter 1. Propositional Logic. Chapter 1.1. Propositional Logic

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter

Logical Operators. Conjunction Disjunction Negation Exclusive Or Implication Biconditional

CS100: DISCRETE STRUCTURES. Lecture 5: Logic (Ch1)

Part I: Propositional Calculus

ICS141: Discrete Mathematics for Computer Science I

Discrete Mathematical Structures. Chapter 1 The Foundation: Logic

Review. Propositional Logic. Propositions atomic and compound. Operators: negation, and, or, xor, implies, biconditional.

Introduction to Sets and Logic (MATH 1190)

Logic. Logic is a discipline that studies the principles and methods used in correct reasoning. It includes:

Definition 2. Conjunction of p and q

Logic and Proof. Aiichiro Nakano

3/29/2017. Logic. Propositions and logical operations. Main concepts: propositions truth values propositional variables logical operations

Mat 243 Exam 1 Review

First order Logic ( Predicate Logic) and Methods of Proof

Before you get started, make sure you ve read Chapter 1, which sets the tone for the work we will begin doing here.

Propositional Logic. Spring Propositional Logic Spring / 32

A Little Deductive Logic

A Little Deductive Logic

Discrete Mathematics and Its Applications

Propositional and First-Order Logic

Propositional Logic Not Enough

Section Summary. Section 1.5 9/9/2014

Discrete Structures for Computer Science

Lecture 2. Logic Compound Statements Conditional Statements Valid & Invalid Arguments Digital Logic Circuits. Reading (Epp s textbook)

Section Summary. Predicates Variables Quantifiers. Negating Quantifiers. Translating English to Logic Logic Programming (optional)

Predicates, Quantifiers and Nested Quantifiers

Logic and Propositional Calculus

Propositional Logic: Syntax

Artificial Intelligence Knowledge Representation I

Why Learning Logic? Logic. Propositional Logic. Compound Propositions

Section Summary. Predicate logic Quantifiers. Negating Quantifiers. Translating English to Logic. Universal Quantifier Existential Quantifier

Intelligent Agents. First Order Logic. Ute Schmid. Cognitive Systems, Applied Computer Science, Bamberg University. last change: 19.

CHAPTER 1. MATHEMATICAL LOGIC 1.1 Fundamentals of Mathematical Logic

Tools for reasoning: Logic. Ch. 1: Introduction to Propositional Logic Truth values, truth tables Boolean logic: Implications:

1 Propositional Logic

Conjunction: p q is true if both p, q are true, and false if at least one of p, q is false. The truth table for conjunction is as follows.

Predicate Calculus. Lila Kari. University of Waterloo. Predicate Calculus CS245, Logic and Computation 1 / 59

1 Propositional Logic

Logic and Proofs. (A brief summary)

Logic and Propositional Calculus

MAT2345 Discrete Math

CS1021. Why logic? Logic about inference or argument. Start from assumptions or axioms. Make deductions according to rules of reasoning.

Logic - recap. So far, we have seen that: Logic is a language which can be used to describe:

First Order Logic (1A) Young W. Lim 11/18/13

Announcements CompSci 102 Discrete Math for Computer Science

1 The Foundation: Logic and Proofs

Logic Background (1A) Young W. Lim 12/14/15

1 The Foundation: Logic and Proofs

Predicate Calculus lecture 1

Predicate in English. Predicates and Quantifiers. Predicate in Logic. Propositional Functions: Prelude. Propositional Function

Proving logical equivalencies (1.3)

Logic. Propositional Logic: Syntax. Wffs

Formal Logic: Quantifiers, Predicates, and Validity. CS 130 Discrete Structures

Overview. Knowledge-Based Agents. Introduction. COMP219: Artificial Intelligence. Lecture 19: Logic for KR

Exercise Set 1 Solutions Math 2020 Due: January 30, Find the truth tables of each of the following compound statements.

Packet #2: Set Theory & Predicate Calculus. Applied Discrete Mathematics

Formal (Natural) Deduction for Predicate Calculus

! Predicates! Variables! Quantifiers. ! Universal Quantifier! Existential Quantifier. ! Negating Quantifiers. ! De Morgan s Laws for Quantifiers

Chapter 2: The Logic of Quantified Statements

Logic. Propositional Logic: Syntax

THE LOGIC OF COMPOUND STATEMENTS

Predicate Logic Thursday, January 17, 2013 Chittu Tripathy Lecture 04

MAI0203 Lecture 7: Inference and Predicate Calculus

Discrete Mathematics & Mathematical Reasoning Predicates, Quantifiers and Proof Techniques

LIN1032 Formal Foundations for Linguistics

Section 3.1: Direct Proof and Counterexample 1

software design & management Gachon University Chulyun Kim

1 Predicates and Quantifiers

CSI30. Chapter 1. The Foundations: Logic and Proofs Nested Quantifiers

MATH 22 INFERENCE & QUANTIFICATION. Lecture F: 9/18/2003

Example. Logic. Logical Statements. Outline of logic topics. Logical Connectives. Logical Connectives

THE LOGIC OF COMPOUND STATEMENTS

COMP 2600: Formal Methods for Software Engineeing

INTRODUCTION TO LOGIC. Propositional Logic. Examples of syntactic claims

Propositional logic (revision) & semantic entailment. p. 1/34

Logic and Proofs. (A brief summary)

ECOM Discrete Mathematics

3 The Semantics of the Propositional Calculus

A statement is a sentence that is definitely either true or false but not both.

Proposition/Statement. Boolean Logic. Boolean variables. Logical operators: And. Logical operators: Not 9/3/13. Introduction to Logical Operators

Logic. Quantifiers. (real numbers understood). x [x is rotten in Denmark]. x<x+x 2 +1

Predicates and Quantifiers. Nested Quantifiers Discrete Mathematic. Chapter 1: Logic and Proof

2/18/14. What is logic? Proposi0onal Logic. Logic? Propositional Logic, Truth Tables, and Predicate Logic (Rosen, Sections 1.1, 1.2, 1.

Chapter 1 Elementary Logic

Logic: The Big Picture

Introducing Proof 1. hsn.uk.net. Contents

Thinking of Nested Quantification

The Logic of Compound Statements cont.

Truth-Functional Logic

Examples: P: it is not the case that P. P Q: P or Q P Q: P implies Q (if P then Q) Typical formula:

cse 311: foundations of computing Fall 2015 Lecture 6: Predicate Logic, Logical Inference

Chapter 4, Logic using Propositional Calculus Handout

CSC Discrete Math I, Spring Propositional Logic

Transcription:

oday s topics Bits and Bit Operations opic #2 Bits Boolean algebra preview Propositional equivalences Predicate logic Reading: Sections 1.2-1.4 Slides taken from Prof. Michael rank A bit is a binary nary (base 2) digit it: : 0 or 1. Bits may be used to represent truth values. By convention: 0 represents false ;; 1 represents true. Boolean algebra is like ordinary algebra except that variables stand for bits, + means or,, and multiplication means and. See module 23 (chapter 10) for more details. John ukey (1915-2000) 1.1 1.2 Bit Strings opic #2 Bits Counting in Binary opic #2 Bits A Bit string of length n is an ordered sequence (series, tuple) ) of n0 bits. More on sequences in 3.2. By convention, bit strings are (sometimes) written left to right: e.g. the first bit of the bit string 1001101010 is 1. Watch out! Another common convention is that the rightmost bit is bit #0, the 2 nd -rightmost is bit #1, etc. When a bit string represents a base-2 number, by convention, the first (leftmost) bit is the most significant bit. Ex. 1101 2 =8+4+1=13. Did you know that you can count to 1,023 just using two hands? How? Count in binary! Each finger (up/down) represents 1 bit. o increment: lip the rightmost (low-order) bit. If it changes 101 0,, then also flip the next bit to the left, If that bit changes 101 0,, then flip the next one, etc. 0000000000, 0000000001, 0000000010,,, 1111111101, 1111111110, 1111111111 1.3 1.4

Bitwise Operations opic #2 Bits End of 1.1 Boolean operations can be extended to operate on bit strings as well as single bits. E.g.: 01 1011 0110 11 0001 1101 11 1011 1111 Bit-wise OR 01 0001 0100 Bit-wise AND 10 1010 1011 Bit-wise XOR You have learned about: Propositions: What they are. Propositional logic operators Symbolic notations. English equivalents. Logical meaning. ruth tables. Atomic vs. compound propositions. Alternative notations. Bits and bit-strings. Next section: 1.2 Propositional equivalences. How to prove them. 1.5 1.6 opic #1.1 Propositional Logic: Equivalences Propositional Equivalence ( 1.2) opic #1.1 Propositional Logic: Equivalences autologies and Contradictions wo syntactically (i.e., textually) different compound propositions may be the semantically identical (i.e.,( have the same meaning). We call them equivalent.. Learn: Various equivalence rules or laws. How to prove equivalences using symbolic derivations. A tautology is a compound proposition that is true no matter what the truth values of its atomic propositions are! Ex. p p [What is its truth table?] A contradiction is a compound proposition that is false no matter what! Ex. p p [ruth table?] Other compound props. are contingencies. 1.7 1.8

Logical Equivalence opic #1.1 Propositional Logic: Equivalences Proving Equivalence via ruth ables opic #1.1 Propositional Logic: Equivalences Compound proposition p is logically equivalent to compound proposition q, written pq, I the compound proposition pq is a tautology. Compound propositions p and q are logically equivalent to each other I p and q contain the same truth values as each other in all rows of their truth tables. Ex. Prove that pq ( p q). pqp q p q p q ( p q) 1.9 1.10 Equivalence Laws opic #1.1 Propositional Logic: Equivalences opic #1.1 Propositional Logic: Equivalences Equivalence Laws - Examples hese are similar to the arithmetic identities you may have learned in algebra, but for propositional equivalences instead. hey provide a pattern or template that can be used to match all or part of a much more complicated proposition and to find an equivalence for it. Identity: p p p p p Domination: p p Idempotent: pp p pp p p Double negation: p p Commutative: pq qp p pq p qp Associative: (pq)r p(qr) (pq)r p(qr) 1.11 1.12

More Equivalence Laws opic #1.1 Propositional Logic: Equivalences opic #1.1 Propositional Logic: Equivalences Defining Operators via Equivalences Distributive: p(qr) (pq)(pr) p(qr) (pq)(pr) De Morgan s: (pq) p q (pq) p q rivial tautology/contradiction: p p p p Augustus De Morgan (1806-1871) Using equivalences, we can define operators in terms of other operators. Exclusive or: pq (pq) (pq) pq (p q)(q p) Implies: pq p q Biconditional: pq (pq) (qp) pq (pq) 1.13 1.14 An Example Problem opic #1.1 Propositional Logic: Equivalences Example Continued... opic #1.1 Propositional Logic: Equivalences Check using a symbolic derivation whether (p q) (p r) p q r. (p q) (p r) [Expand definition of ] (p q) (p r) [Expand defn.. of ] (p q) ((p r) (p r)) [DeMorgan s Law] ( p q) ((p r) (p r)) cont. ( p q) ((p r) (p r)) [ commutes] (q p) ((p r) (p r)) [ associative] q ( p ((p r) (p r))) ) [distrib[ distrib. over ] q ((( p (p r)) ( p (p r))) [assoc.] q ((( p p) r) ( p (p r))) [trivail taut.] q (( r) ( p (p r))) [domination] q ( ( p (p r))) [identity] q ( p (p r)) cont. 1.15 1.16

End of Long Example opic #1.1 Propositional Logic: Equivalences Review: Propositional Logic ( 1.1-1.2) opic #1 Propositional Logic q ( p (p r)) [DeMorgan s] q ( p ( p r)) [Assoc.] q (( p p) r) [Idempotent] q ( p r) [Assoc.] (q p) r [Commut.] p q r Q.E.D. (quod( erat demonstrandum) ) or Atomic propositions: p, q, r, Boolean operators: Compound propositions: s : (p q) r Equivalences: p q (p q) Proving equivalences using: ruth tables. Symbolic derivations. p q r 1.17 1.18 Predicate Logic ( 1.3) Applications of Predicate Logic Predicate logic is an extension of propositional logic that permits concisely reasoning about whole classes of entities. Propositional logic (recall) treats simple propositions (sentences) as atomic entities. In contrast, predicate logic distinguishes the subject of a sentence from its predicate. Remember these English grammar terms? It is the formal notation for writing perfectly clear, concise, and unambiguous mathematical definitions, axioms,, and theorems (more on these in module 2) for any branch of mathematics. Predicate logic with function symbols, the = operator, and a few proof- building rules is sufficient for defining any conceivable mathematical system, and for proving anything that can be proved within that system! 1.19 1.20

Other Applications Practical Applications of Predicate Logic Predicate logic is the foundation of the field of mathematical logic,, which culminated in Gödel s s incompleteness theorem,, which revealed the ultimate limits of mathematical thought: Given any finitely describable, consistent proof procedure, there will always remain some true statements that will never be proven by that procedure. I.e.,, we can t t discover all mathematical truths, unless we sometimes resort to making guesses. Kurt Gödel 1906-1978 It is the basis for clearly expressed formal specifications for any complex system. It is basis for automatic theorem provers and many other Artificial Intelligence systems. E.g. automatic program verification systems. Predicate-logic like statements are supported by some of the more sophisticated database query engines and container class libraries these are types of programming tools. 1.21 1.22 Subjects and Predicates More About Predicates In the sentence he dog is sleeping : he phrase the dog denotes the subject - the object or entity that the sentence is about. he phrase is sleeping denotes the predicate- - a property that is true of the subject. In predicate logic, a predicate is modeled as a function P( ) from objects to propositions. P(x) ) = x is sleeping (where x is any object). Convention: Lowercase variables x, y, z... denote objects/entities; uppercase variables P, Q, R denote propositional functions (predicates). Keep in mind that the result of applying a predicate P to an object x is the proposition P(x). P But the predicate P itself (e.g. P= is P sleeping ) ) is not a proposition (not a complete sentence). E.g. if P(x) ) = x is a prime number, P(3) is the proposition 33 is a prime number. 1.23 1.24

Propositional unctions Universes of Discourse (U.D.s) Predicate logic generalizes the grammatical notion of a predicate to also include propositional functions of any number of arguments, each of which may take any grammatical role that a noun can take. E.g. let P(x,y,z) ) = x gave y the grade z,, then if x= Mike Mike, y= Mary, z= A,, then P(x,y,z) ) = Mike gave Mary the grade A. he power of distinguishing objects from predicates is that it lets you state things about many objects at once. E.g., let P(x)= )= x+1> +1>x.. We can then say, or any number x, P(x) ) is true instead of (0+1> +1>0) (1+1> +1>1) (2+1> +1>2)... he collection of values that a variable x can take is called x s universe of discourse. 1.25 1.26 Quantifier Expressions he Universal Quantifier Quantifiers provide a notation that allows us to quantify (count) how many objects in the univ.. of disc. satisfy a given predicate. is the ORLL or universal quantifier. x P(x) ) means for all x in the u.d., P holds. is the XISS or existential quantifier. x x P(x) P ) means there exists an x in the u.d. (that is, 1 or more) such that P(x) ) is true. Example: Let the u.d. of x be parking spaces at Duke. Let P(x) ) be the predicate x is full. hen the universal quantification of P(x), P x P(x), is the proposition: All parking spaces at Duke are full. i.e., Every parking space at Duke is full. i.e., or each parking space at Duke, that space is full. 1.27 1.28

he Existential Quantifier ree and Bound Variables Example: Let the u.d. of x be parking spaces at Duke. Let P(x) ) be the predicate x is full. hen the existential quantification of P(x), P x P(x), is the proposition: Some parking space at Duke is full. here is a parking space at Duke that is full. At least one parking space at Duke is full. An expression like P(x) ) is said to have a free variable x (meaning, x is undefined). A quantifier (either or ) operates on an expression having one or more free variables, and binds one or more of those variables, to produce an expression having one or more bound variables. 1.29 1.30 Example of Binding Nesting of Quantifiers P(x,y) ) has 2 free variables, x and y. x P(x,y) ) has 1 free variable, and one bound variable. [Which is which?] P(x), where x=3 is another way to bind x. An expression with zero free variables is a bona-fide (actual) proposition. An expression with one or more free variables is still only a predicate: e.g. let Q(y) ) = x P(x,y) Example: Let the u.d. of x & y be people. Let L(x,y)= )= x likes y (a predicate w. 2 f.v. s) hen y y L(x,yL x,y) ) = here is someone whom x likes. (A predicate w. 1 free variable, x) hen x (y y L(x,yL x,y)) = Everyone has someone whom they like. (A with free variables.) 1.31 1.32

Review: Predicate Logic ( 1.3) Quantifier Exercise Objects x, y, z, Predicates P, Q, R, are functions mapping objects x to propositions P(x). Multi-argument predicates P(x, y). Quantifiers: [x[ P(x)] :: or all x s, P(x). ). [x x P(x)] P :: here is an x such that P(x). ). Universes of discourse, bound & free vars. If R(x,y)= )= x relies upon y, express the following in unambiguous English: x(y y R(x,yR x,y))= y(x R(x,y))= x(y y R(x,yR x,y))= y(x x R(x,yR x,y))= x(y R(x,y))= 1.33 1.34 Natural language is ambiguous! Game heoretic Semantics Everybody likes somebody. or everybody, there is somebody they like, x y Likes(x,y) or, there is somebody (a popular person) whom everyone likes? y x Likes(x,y) Somebody likes everybody. Same problem: Depends on context, emphasis. hinking in terms of a competitive game can help you tell whether a proposition with nested quantifiers is true. he game has two players, both with the same knowledge: Verifier: Wants to demonstrate that the proposition is true. alsifier: Wants to demonstrate that the proposition is false. he Rules of the Game Verify or alsify : Read the quantifiers from left to right,, picking values of variables. When you see,, the falsifier gets to select the value. When you see,, the verifier gets to select the value. If the verifier can always win,, then the proposition is true. If the falsifier can always win,, then it is false. 1.35 1.36

Let s Play, Verify or alsify! Still More Conventions Let B(x,y) : x s birthday is followed within 7 days by y s birthday. Suppose I claim that among you: x y B(x,y) Your turn, as falsifier: You pick any x (so-and-so) y B(so-and-so,y) My turn, as verifier: I pick any y (such-and-such) B(so-and-so,such-and-such) Let s play it in class. Who wins this game? What if I switched the quantifiers, and I claimed that y x B(x,y)? Who wins in that case? Sometimes the universe of discourse is restricted within the quantification, e.g., x> x>0 P(x) ) is shorthand for or all x that are greater than zero, P(x). ). =x (x> x>0 P(x)) x> x>0 P(x) ) is shorthand for here is an x greater than zero such that P(x). ). =x (x> x>0 P(x)) 1.37 1.38 More to Know About Binding Quantifier Equivalence Laws x x x P(x) P - x is not a free variable in x x P(x), P therefore the x binding isn t t used. (x P(x)) Q(x) - he variable x is outside of the scope of the x quantifier, and is therefore free. Not a complete proposition! (x P(x)) (x Q(x)) his is legal, because there are 2 different x s! Definitions of quantifiers: If u.d.=a,b,c, x x P(x) P P(a) P(b) P(c) x x P(x) P P(a) P(b) P(c) rom those, we can prove the laws: x x P(x) P x P(x) x x P(x) P x P(x) Which propositional equivalence laws can be used to prove this? 1.39 1.40

More Equivalence Laws Review: Predicate Logic ( 1.3) x y y P(x,y) P y x x P(x,y) P x y y P(x,y) P y x x P(x,y) P x (P(x) Q(x)) (x x P(x)) P (x x Q(x)) Q x (P(x) Q(x)) (x x P(x)) P (x x Q(x)) Q Exercise: See if you can prove these yourself. What propositional equivalences did you use? Objects x, y, z, Predicates P, Q, R, are functions mapping objects x to propositions P(x). Multi-argument predicates P(x, y). Quantifiers: (x( P(x)) = or = all x s, P(x). ). (x x P(x))= P ))= here is an x such that P(x). ). 1.41 1.42 More Notational Conventions Defining New Quantifiers Quantifiers bind as loosely as needed: parenthesize x P(x) Q(x) ( ) Consecutive quantifiers of the same type can be combined: x y z z P(x,y,z) P x,y,z P(x,y,z) P ) or even xyz P(x,y,z) P All quantified expressions can be reduced to the canonical alternating form x 1 x 2 x 3 x 4 P(x 1, x 2, x 3, x 4, ) As per their name, quantifiers can be used to express that a predicate is true of any given quantity (number) of objects. Define!x P(x) ) to mean P(x)) is true of exactly one x in the universe of discourse.!x P(x) x (P(x) here is an x such that P(x), where there is no y such that P(y) ) and y is other than x. y (P(y) y x)) 1.43 1.44

Some Number heory Examples Goldbach s Conjecture (unproven) Let u.d. = the natural numbers 0, 1, 2, A A number x is even, E(x), if and only if it is equal to 2 times some other number. x (E(x) (y y x=2y)) A A number is prime, P(x), iff it s s greater than 1 and it isn t the product of any two non-unity numbers. x (P(x) (x>1 yz x=yz y1 z1)) Using E(x) ) and P(x) ) from previous slide, E(x>2): P(p), ),P(q):): p+q = x or, with more explicit notation: x [x>2 E(x)] p q q P(p) P P(q) p+q = x. Every even number greater than 2 is the sum of two primes. 1.45 1.46 Calculus Example Deduction Example One way of precisely defining the calculus concept of a limit,, using quantifiers: ( ) lim f ( x) = L xa > 0 : > 0 : x : ( x a < ) ( f ( x) L < ) Definitions: s :: Socrates (ancient Greek philosopher); H(x) ) :: x is human ; M(x) ) :: x is mortal. Premises: H(s) Socrates is human. x H(x)M(x) All humans h are mortal. 1.47 1.48

Deduction Example Continued Another Example Some valid conclusions you can draw: H(s) (s)m(s) [Instantiate universal.] If Socrates is human then he is mortal. H(s) M(s) Socrates is inhuman or mortal. H(s) ( H(s)(s) M(s)) Socrates is human, and also either inhuman or mortal. (H(s)(s) H(s)) (H(s)(s) M(s)) [Apply distributive law.] (H(s)(s) M(s)) [rivial contradiction.] H(s) M(s) [Use identity law.] M(s) Socrates is mortal. Definitions: H(x) ) :: x is human ; M(x) ) :: x is mortal ; G(x) ) :: x is a god Premises: x H(x) M(x) ( Humans are mortal ) ) and x G(x) M(x) ( Gods are immortal ). Show that x (H(x) G(x)) ( No human is a god. ) 1.49 1.50 he Derivation End of 1.3-1.4, Predicate Logic x H(x)M(x) and x G(x) M(x). x M(x) H(x) [Contrapositive.] x [G(x) M(x)] [ M(x) H(x)] x G(x) H(x) [ransitivity of.] x G(x) H(x) [Definition of.] x (G(x) H(x)) [DeMorgan s law.] x G(x) H(x) [An equivalence law.] rom these sections you should have learned: Predicate logic notation & conventions Conversions: predicate logic clear English Meaning of quantifiers, equivalences Simple reasoning with quantifiers Upcoming topics: Introduction to proof-writing. hen: Set theory a language for talking about collections of objects. 1.51 1.52