### Create a StudySoup account

#### Be part of our community, it's free to join!

Already have a StudySoup account? Login here

# FoCS Week 1 CSCI 2200

RPI

### View Full Document

## About this Document

## 50

## 1

## Popular in Foundations of Computer Science

## Popular in ComputerScienence

This 66 page Class Notes was uploaded by thersh on Thursday February 11, 2016. The Class Notes belongs to CSCI 2200 at Rensselaer Polytechnic Institute taught by Petros Drineas in Spring 2016. Since its upload, it has received 50 views. For similar materials see Foundations of Computer Science in ComputerScienence at Rensselaer Polytechnic Institute.

## Reviews for FoCS Week 1

### What is Karma?

#### Karma is the currency of StudySoup.

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 02/11/16

The Foundations: Logic Propositions • A proposition is a declarative sentence that is either true or false. • Examples of propositions: a) Albany is the capital of NY State. b) 1 + 0 = 1 c) 0 + 0 = 2 • Examples that are not propositions. a) What time is it? b) x + 1 = 2 c) x + y = z Propositional Logic • Constructing Propositions • Propositional Variables: p, q, r, s, … • The proposition that is always true is denoted by T and the proposition that is always false is denoted by F. • Compound Propositions; constructed from logical connectives and other propositions • Negation ¬ • Conjunction ∧ • Disjunction ∨ • Implica→ion • Biconditi↔nal Compound Propositions: Negation • The negation of a proposition p is denoted by ¬p and has this truth table: p ¬p T F F T • Example: If p denotes “1+1=2”, then ¬p denotes “It is not the case that 1+1=2,” or more simply “1+1 is not equal to 2.” Conjunction • The conjunction of propositions p and q is denoted by p ∧ q and has this truth table: p q p ∧ q T T T T F F F T F F F F • Example: If p denotes “1+1=2” and q denotes “2+2=5” then p ∧q denotes “1+1=2 and 2+2=5.” Disjunction • The disjunction of propositions p and q is denoted by p ∨q and has this truth table: p q p ∨q T T T T F T F T T F F F • Example: If p denotes “1+1=2” and q denotes “2+2=5” then p ∨q denotes “1+1=2 or 2+2=5.” The Connective Or in English • In English “or” has two distinct meanings. • “Inclusive Or” - In the sentence “Students who have taken CS101 or Math101 may take this class,” we assume that students need to have taken one of the prerequisites, but may have taken both. This is the meaning of disjunction. For p ∨q to be true, either one or both of p and q must be true. • “Exclusive Or” - When reading the sentence “Soup or salad comes with this entrée,” we do not expect to be able to get both soup and salad. This is the meaning of Exclusive Or (Xor). In p ⊕ q , one of p and q must be true, but not both. The truth table for ⊕ is: p q p ⊕q T T F T F T F T T F F F Implication • If p and q are propositions, then p →q is a conditional statement or implication which is read as “if p, then q ” and has this truth table: p q p →q T T T T F F F T T F F T • Example: If p denotes “1+1=2” and q denotes “2+2=5” then p →q denotes “If 1+1=2 then 2+2=5.” q →p denotes “If 2+2=5 then 1+1=2.” • In p →q , p is the hypothesis (or premise) and q is the conclusion (or consequence). Understanding Implication (cont) • One way to view the logical conditional is to think of an obligation or contract. • “If I am elected, then I will lower taxes.” • “If you get 100% on the final, then you will get an A.” • If the politician is elected and does not lower taxes, then the voters can say that he or she has broken the campaign pledge. Something similar holds for the professor. This corresponds to the case where p is true and q is false. Converse, Contrapositive, and Inverse • From p →q we can form new conditional statements . • q →p is the converse of p →q • ¬q → ¬ p is the contrapositive of p →q • ¬ p → ¬ q is the inverse of p →q Example: Find the converse, inverse, and contrapositive of “If 1+1=2 then 2+2=5.” Solution: converse: If 2+2=5 then 1+1=2. inverse: If 2+2 is not equal to 5 then 1+1 is not equal to 2. contrapositive: If 1+1 is not equal to 2 then 2+2 is not equal to 5. Biconditional • If p and q are propositions, then we can form the biconditional proposition p ↔q , read as “p if and only if q .” The biconditional p ↔q denotes the proposition with this truth table: p q p ↔q T T T T F F F T F F F T • If p denotes “1+1=2” and q denotes “2+2=5” then p ↔q denotes “1+1=2 if and only if 2+2=5.” Expressing the Biconditional • Some alternative ways “p if and only if q” is expressed in English: • p is necessary and sufficient for q • if p then q , and conversely • p iff q Truth Tables For Compound Propositions • Construction of a truth table: • Rows • Need a row for every possible combination of values for the atomic propositions. • Columns • Need a column for the compound proposition (usually at far right) • Need a column for the truth value of each expression that occurs in the compound proposition as it is built up. • This includes the atomic propositions Example Truth Table • Construct a truth table for p q r r p q p q → r T T T F T F T T F T T T T F T F T F T F F T T T F T T F T F F T F T T T F F T F F T F F F T F T Equivalent Propositions • Two propositions are equivalent if they always have the same truth value. • Example: Show using a truth table that the implication is equivalent to the contrapositive. Solution: ¬p ¬q ¬q→¬ p p q p →q T T F F T T T F F T F F F T T F T T F F T T T T Using a Truth Table to Show Non-Equivalence Example: Show using truth tables that neither the converse nor inverse of an implication are equivalent to the implication. Solution: ¬p ¬q q → p p q p →q ¬p → ¬q T T F F T T T T F F T F T T F T T F T F F F F T T T T T Problem • How many rows are there in a truth table with n propositional variables? n Solution: 2 • Note that this means that with n propositional variables, we can construct 2 distinct (i.e., not equivalent) propositions. Precedence of Logical Operators Operator Precedence 1 2 3 4 5 p q r is equivalent to (p q) r If the intended meaning is p (q r ) then parentheses must be used. Logic Circuits • Electronic circuits; each input/output signal can be viewed as a 0 or 1. • 0 represents False • 1 represents True • Complicated circuits are constructed from three basic circuits called gates. • The inverter (NOT gate)takes an input bit and produces the negation of that bit. • The OR gate takes two input bits and produces the value equivalent to the disjunction of the two bits. • bits.ND gate takes two input bits and produces the value equivalent to the conjunction of the two • More complicated digital circuits can be constructed by combining these basic circuits to produce the desired output given the input signals by building a circuit for each piece of the output expression and then combining them. For example: Tautologies, Contradictions, and Contingencies • A tautology is a proposition which is always true. • Example: p ∨¬p • A contradiction is a proposition which is always false. • Example: p ∧¬p • A contingency is a proposition which is neither a tautology nor a contradiction, such as p p ¬p p ∨¬p p ∧¬p T F T F F T T F Logically Equivalent • Two propositions p and q are logically equivalent if p↔q is a tautology. • We write this as p⇔q or as p≡q where p and q are compound propositions. • Two propositions p and q are equivalent if and only if the columns in a truth table giving their truth values agree. • This truth table show ¬p ∨ q is equivalent to p → q. p q ¬ p ¬ p∨ q p→q T T F T T T F F F F F T T T T F F T T T De Morgan’s Laws Augustus De Morgan 1806-1871 This truth table shows that De Morgan’s Second Law holds. p q ¬p ¬q (p∨q) ¬(p∨q) ¬p∧¬q T T F F T F F T F F T T F F F T T F T F F F F T T F T T Key Logical Equivalences • Identity Laws: , • Domination Laws: , • Idempotent laws: , • Double Negation Law: • Negation Laws: , Key Logical Equivalences (cont) • Commutative Laws: , • Associative Laws: • Distributive Laws: • Absorption Laws: More Logical Equivalences Constructing New Logical Equivalences • We can show that two expressions are logically equivalent by developing a series of logically equivalent statements. • To prove that we produce a series of equivalences beginning with A and ending with B. • Keep in mind that whenever a proposition (represented by a propositional variable) occurs in the equivalences listed earlier, it may be replaced by an arbitrarily complex proposition. Equivalence Proofs Example: Show that is logically equivalent to Solution: Equivalence Proofs Example: Show that is a tautology. Solution: Disjunctive Normal Form • A propositional formula is in disjunctive normal form if it consists of a disjunction of (1, … ,n) disjuncts where each disjunct consists of a conjunction of (1, …, m) atomic formulas or the negation of an atomic formula. • Yes • No • Disjunctive Normal Form is important for circuit design. Disjunctive Normal Form Example: Show that every compound proposition can be put in disjunctive normal form. Solution: Construct the truth table for the proposition. Then an equivalent proposition is the disjunction with n disjuncts (where n is the number of rows for which the formula evaluates to T). Each disjunct has m conjuncts where m is the number of distinct propositional variables. Each conjunct includes the positive form of the propositional variable if the variable is assigned T in that row and the negated form if the variable is assigned F in that row. This proposition is in disjunctive normal from. Disjunctive Normal Form Example: Find the Disjunctive Normal Form (DNF) of (p∨q)→¬r Solution: This proposition is true when r is false or when both p and q are false. (¬ p∧ ¬ q) ∨ ¬r Conjunctive Normal Form • A compound proposition is in Conjunctive Normal Form (CNF) if it is a conjunction of disjunctions. • Every proposition can be put in an equivalent CNF. • Conjunctive Normal Form (CNF) can be obtained by eliminating implications, moving negation inwards and using the distributive and associative laws (this is beyond the scope of our class). • Important in resolution theorem proving used in artificial Intelligence (AI). • A compound proposition can be put in conjunctive normal form through repeated application of the logical equivalences covered earlier. Propositional Satisfiability • A compound proposition is satisfiable if there is an assignment of truth values to its variables that make it true. When no such assignments exist, the compound proposition is unsatisfiable. • A compound proposition is unsatisfiable if and only if its negation is a tautology. Questions on Propositional Satisfiability Example: Determine the satisfiability of the following compound propositions: Solution: Satisfiable. Assign T to p, q, and r. Solution: Satisfiable. Assign T to p and F to q. Solution: Not satisfiable. Check each possible assignment of truth values to the propositional variables and none will make the proposition true. Notation Solving Satisfiability Problems • A truth table can always be used to determine the satisfiability of a compound proposition. But this is too complex even for modern computers for large problems. • There has been much work on developing efficient methods for solving satisfiability problems as many practical problems can be translated into satisfiability problems. Propositional Logic Not Enough • If we have: “All men are mortal.” “Socrates is a man.” • Does it follow that “Socrates is mortal?” • Can’t be represented in propositional logic. Need a language that talks about objects, their properties, and their relations. • Later we’ll see how to draw inferences. Introducing Predicate Logic • Predicate logic uses the following new features: • Variables: x, y, z • Predicates: P(x), M(x) • Quantifiers (to be covered in a few slides): • Propositional functions are a generalization of propositions. • They contain variables and a predicate, e.g., P(x) • Variables can be replaced by elements from their domain. Propositional Functions • Propositional functions become propositions (and have truth values) when their variables are each replaced by a value from the domain (or bound by a quantifier, as we will see later). • The statement P(x) is said to be the value of the propositional function P at x. • For example, let P(x) denote “x > 0” and the domain be the integers. Then: P(-3) is false. P(0) is false. P(3) is true. • Often the domain is denoted by U. So in this example U is the integers. Examples of Propositional Functions • Let “x + y = z” be denoted by R(x, y, z) and U (for all three variables) be the integers. Find these truth values: R(2,-1,5) Solution: F R(3,4,7) Solution: T R(x, 3, z) Solution: Not a Proposition • Now let “x - y = z” be denoted by Q(x, y, z), with U as the integers. Find these truth values: Q(2,-1,3) Solution: T Q(3,4,7) Solution: F Q(x, 3, z) Solution: Not a Proposition Compound Expressions • Connectives from propositional logic carry over to predicate logic. • If P(x) denotes “x > 0,” find these truth values: P(3) ∨ P(-1) Solution: T P(3) ∧ P(-1) Solution: F P(3) → P(-1) Solution: F P(3) → P(1) Solution: T • Expressions with variables are not propositions and therefore do not have truth values. For example, P(3) ∧ P(y) P(x) → P(y) • When used with quantifiers (to be introduced next), these expressions (propositional functions) become propositions. Quantifiers • We need quantifiers to express the meaning of English words including all and some: • “All men are Mortal.” • “Some cats do not have fur.” • The two most important quantifiers are: • Universal Quantifier, “For all” symbol: • Existential Quantifier, “There exiss,” symbol: • We write as in x P(x) and x P(x). • x P(x) asserts P(x) is true for every x in the domain. • x P(x) asserts P(x) is true for some x in the domain. • The quantifiers are said to bind the variable x in these expressions. Universal Quantifier • x P(x) is read as “For all x, P(x)” or “For every x, P(x)” Examples: 1) If P(x) denotes “x > 0” and U is the integers, then x P(x) is false. 2) If P(x) denotes “x > 0” and U is the positive integers, thx P(x) is true. 3) If P(x) denotes “x is even” and U is the integers, then x P(x) is false. Existential Quantifier • x P(x) is read as “For some x, P(x)”, or as “There is an x such that P(x),” or “For at least one x, P(x).” Examples: 1. If P(x) denotes “x > 0” and U is the integers, then x P(x) is true. It is also true if U is the positive integers. 2. If P(x) denotes “x < 0” and U is the positive integers, thx P(x) is false. 3. If P(x) denotes “x is even” and U is the integers, thex P(x) is true. Uniqueness Quantifier (optional) • !x P(x) means that P(x) is true for one and only one x in the universe of discourse. • This is commonly expressed in English in the following equivalent ways: • “There is a unique x such that P(x).” • “There is one and only one x such that P(x)” • Examples: 1. If P(x) denotes “x + 1 = 0” and U is the integers, then !x P(x) is true. 2. But if P(x) denotes “x > 0,” then !x P(x) is false. • The uniqueness quantifier is not really needed as the restriction that there is a unique x such that P(x) can be expressed as: x (P(x) ∧y (P(y) → y =x)) Thinking about Quantifiers • When the domain of discourse is finite, we can think of quantification as looping through the elements of the domain. • To evaluate x P(x) loop through all x in the domain. • If at every step P(x) is true, then x P(x) is true. • If at a step P(x) is false, then x P(x) is false and the loop terminates. • To evaluate x P(x) loop through all x in the domain. • If at some step, P(x) is true, then x P(x) is true and the loop terminates. • false. loop ends without finding an x for which P(x) is true, then x P(x) is • Even if the domains are infinite, we can still think of the quantifiers this fashion, but the loops will not terminate in some cases. Properties of Quantifiers • The truth value of x P(x) and x P(x) depend on both the propositional function P(x) and on the domain U. • Examples: 1. If U is the positive integers and P(x) is the statement “x < 2”, then x P(x) is true, but x P(x) is false. 2. If U is the negative integers and P(x) is the statement “x < 2”, then both x P(x) and x P(x) are true. 3. If U consists of 3, 4, and 5, and P(x) is the statement “x > 2”, then both x P(x) and x P(x) are true. But if P(x) is the statement “x < 2”, then both x P(x) and x P(x) are false. Precedence of Quantifiers • The quantifiers and have higher precedence than all the logical operators. • For example, x P(x) ∨ Q(x) means (x P(x))∨ Q(x) • x (P(x) ∨ Q(x)) means something different. • Unfortunately, often people write x P(x) ∨ Q(x) when they mean x (P(x) ∨ Q(x)). Translating from English to Logic Example 1: Translate the following sentence into predicate logic: “Every student in this class has taken a course in Java.” Solution: First decide on the domain U. Solution 1: If U is all students in this class, define a propositional function J(x) denoting “x has taken a course in Java” and translate as x J(x). Solution 2: But if U is all people, also define a propositional function S(x) denoting “x is a student in this class” and translatex (S(x)→ J(x)). x (S(x) ∧ J(x)) is not correct. What does it mean? Translating from English to Logic Example 2: Translate the following sentence into predicate logic: “Some student in this class has taken a course in Java.” Solution: First decide on the domain U. Solution 1: If U is all students in this class, translate as x J(x) Solution 1: But if U is all people, then translate as x (S(x) ∧ J(x)) x (S(x)→ J(x)) is not correct. What does it mean? Returning to the Socrates Example • Introduce the propositional functions Man(x) denoting “x is a man” and Mortal(x) denoting “x is mortal.” Specify the domain as all people. • The two premises are: • The conclusion is: • Later we will show how to prove that the conclusion follows from the premises. Equivalences in Predicate Logic • Statements involving predicates and quantifiers are logically equivalent if and only if they have the same truth value • for every predicate substituted into these statements and • for every domain of discourse used for the variables in the expressions. • The notation S ≡T indicates that S and T are logically equivalent. • Example: x ¬¬S(x) ≡ x S(x) Thinking about Quantifiers as Conjunctions and Disjunctions • If the domain is finite, a universally quantified proposition is equivalent to a conjunction of propositions without quantifiers and of propositions without quantifiers.ion is equivalent to a disjunction • If U consists of the integers 1,2, and 3: • Even if the domains are infinite, you can still think of the quantifiers in this fashion, but the equivalent expressions without quantifiers will be infinitely long. Negating Quantified Expressions • Consider x J(x) “Every student in your class has taken a course in Java.” Here J(x) is “x has taken a course in Java” and the domain is students in your class. • Negating the original statement gives “It is not the case that every student in your class has taken Java.” This implies that “There is a student in your class who has not taken Java.” Symbolically ¬x J(x) and x ¬J(x) are equivalent Negating Quantified Expressions (continued) • Now consider x J(x) “There is a student in this class who has taken a course in Java.” Where J(x) is “x has taken a course in Java.” • Negating the original statement gives “It is not the case that there is a student in this class who has taken Java.” This implies that “Every student in this class has not taken Java” Symbolically ¬ x J(x) and x ¬J(x) are equivalent De Morgan’s Laws for Quantifiers • The rules for negating quantifiers are: • The reasoning in the table shows that: Translation from English to Logic Examples: 1. “Some student in this class has visited Mexico.” Solution: Let M(x) denote “x has visited Mexico” and S(x) denote “x is a student in this class,” and U be all people. x (S(x) ∧ M(x)) 2. “Every student in this class has visited Canada or Mexico.” Solution: Add C(x) denoting “x has visited Canada.” x (S(x)→ (M(x)∨C(x))) Logic Programming • Prolog (from Programming in Logic) is a programming language developed in the 1970s by researchers in artificial intelligence (AI). • Prolog programs include Prolog facts and Prolog rules. • As an example of a set of Prolog facts consider the following: instructor(chan, math273). instructor(patel, ee222). instructor(grossman, cs301). enrolled(kevin, math273). enrolled(juna, ee222). enrolled(juana, cs301). enrolled(kiko, math273). enrolled(kiko, cs301). • Here the predicates instructor(p,c) and enrolled(s,c) represent that professor p is the instructor of course c and that student s is enrolled in course c. Nested Quantifiers • Nested quantifiers are often necessary to express the meaning of sentences in English as well as important concepts in computer science and mathematics. Example: “Every real number has an inverse” is x y(x + y = 0) where the domains of x and y are the real numbers. • We can also think of nested propositional functions: xwhere P(x, y) is (x + y = 0) as x Q(x) where Q(x) is y P(x, y) Thinking of Nested Quantification • Nested Loops • To see if xyP (x,y) is true, loop through the values of x : • At each step, loop through the values for y. • If for some pair of x andy,P(x,y) is false, then x yP(x,y) is false and both the outer and inner loop terminate. x y P(x,y) is true if the outer loop ends after stepping through each x. • To see if x yP(x,y) is true, loop through the values of x: • At each step, loop through the values for y. • The inner loop ends when a pair x and y is found such that P(x, y) is true. • If no y is found such that P(x, y) is true the outer loop terminates as x yP(x,y) has been shown to be false. x y P(x,y) is true if the outer loop ends after stepping through each x. • If the domains of the variables are infinite, then this process can not actually be carried out. Order of Quantifiers Examples: 1. Let P(x,y) be the statement “x + y = y + x.” Assume that U is the real numbers. Then x yP(x,y) and y xP(x,y) have the same truth value. 2. Let Q(x,y) be the statement “x + y = 0.” Assume that U is the real numbers. Then x yP(x,y) is true, but y xP(x,y) is false. Questions on Order of Quantifiers Example 1: Let U be the real numbers, Define P(x,y) : x ∙ y = 0 What is the truth value of the following: 1. xyP(x,y) Answer: False 2. xyP(x,y) Answer: True 3. xy P(x,y) Answer: True 4. x y P(x,y) Answer: True Questions on Order of Quantifiers Example 2: Let U be the real numbers, Define P(x,y) : x / y = 1 What is the truth value of the following: 1. xyP(x,y) Answer: False 2. xyP(x,y) Answer: True 3. xy P(x,y) Answer: False 4. x y P(x,y) Answer: True Quantifications of Two Variables Statement When True? When False P(x,y) is true for every pair x,y. There is a pair x, y for which P(x,y) is false. For every x there is a y for which There is an x such that P(x,y) is false P(x,y) is true. for every y. There is an x for which P(x,y) is true For every x there is a y for which for every y. P(x,y) is false. There is a pair x, y for which P(x,y) iP(x,y) is false for every pair x,y true. Translating Mathematical Statements into Predicate Logic Example : Translate “The sum of two positive integers is always positive” into a logical expression. Solution: 1. Rewrite the statement to make the implied quantifiers and domains explicit: “For every two integers, if these integers are both positive, then the sum of these integers is positive.” 2. Introduce the variables x and y, and specify the domain, to obtain: “For all positive integers x and y, x + y is positive.” 3. The result is: x y ((x > 0)∧ (y > 0)→ (x + y > 0)) where the domain of both variables consists of all integers Some Questions about Quantifiers • Can you switch the order of quantifiers? • Is this a valid equivalence? Solution: Yes! The left and the right side will always have the same truth value. The order in which x and y are picked does not matter. • Is this a valid equivalence? Solution: No! The left and the right side may have different truth values for some propositionalfunctions for P. Try “x + y = 0” for P(x,y) with U being the integers. The order in which the values of x and y are picked does matter. • Can you distribute quantifiers over logical connectives? • Is this a valid equivalence? Solution: Yes! The left and the right side will always have the same truth value no matter what propositional functionsare denoted by P(x) and Q(x). • Is this a valid equivalence? Solution: No! The left and the right side may have different truth values.Pick “x is a fish” for P(x) and “x has scales” for Q(x) with the domain of discourse being all animals. Then the left side is false, because there are some fish that do not have scales. But the right side is true since not all animals are fish.

### BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

#### "There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

#### "I used the money I made selling my notes & study guides to pay for spring break in Olympia, Washington...which was Sweet!"

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

#### "Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.