info 2950
Download
Skip this Video
Download Presentation
Info 2950

Loading in 2 Seconds...

play fullscreen
1 / 56

Info 2950 - PowerPoint PPT Presentation


  • 129 Views
  • Uploaded on

Info 2950. Prof. Carla Gomes [email protected] Module Logic (part 1) Rosen, Chapter 1 . Logic in general. Logics are formal languages for formalizing reasoning, in particular for representing information such that conclusions can be drawn A logic involves:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Info 2950' - kieu


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
info 2950

Info 2950

Prof. Carla Gomes

[email protected]

Module

Logic (part 1)

Rosen, Chapter 1

logic in general
Logic in general
  • Logics are formal languages for formalizing reasoning, in particular for representing information such that conclusions can be drawn
  • A logic involves:
    • A language with a syntax for specifying what is a legal expression in the language; syntax defines well formed sentences in the language
    • Semantics for associating elements of the language with elements of some subject matter. Semantics defines the "meaning" of sentences (link to the world); i.e., semantics defines the truth of a sentence with respect to each possible world
    • Inference rules for manipulating sentences in the language

Original motivation: Early Greeks, settle arguments based on

purely rigorous (symbolic/syntactic) reasoning starting from a given

set of premises. “Reasoning based on form, content.”

example of a formal language arithmetic
Example of a formal language: Arithmetic
  • E.g., the language of arithmetic
    • x+2 ≥ y is a sentence; x2+y > {} is not a sentence
    • x+2 ≥ y is true iff the number x+2 is no less than the number y
    • x+2 ≥ y is true in a world where x = 7, y = 1
    • x+2 ≥ y is false in a world where x = 0, y = 6
simple robot domain
blockSimple Robot Domain
  • Consider a robot that is able to lift a block, if that block is liftable (i.e., not
  • too heavy), and if the robot’s battery power is adequate. If both of these
  • conditions are satisfied, then when the robot tries to lift a block it is
  • holding, its arm moves.

Feature 1: BatIsOk (True or False)

Feature 2: BlockLiftable (True or False)

Feature 3: RobotMoves (True or False)

simple robot domain5
blockSimple Robot Domain

We need a language to express

the features/properties/assertions and constraints

among them; also inference mechanisms, i.e,

principled ways of performing reasoning.

Example logical statement about the robot:

(BatIsOkandBlockLiftable) implies RobotMoves

binary valued featured descriptions
Binary valued featured descriptions
  • Consider the following description:
    • The router can send packets to the edge system only if it supports the new address space. For the router to support the new address space it is necessary that the latest software release be installed. The router can send packets to the edge system if the latest software release is installed. The router does not support the new address space.
    • Features:
      • Router
        • Feature 1 – router can send packets to the edge of system
        • Feature 2 – router supports the new address space
      • Latest software release
        • Feature 3 – latest software release is installed
binary valued featured descriptions7
Binary valued featured descriptions
    • Constraints:
      • The router can send packets to the edge system only if it supports the new address space. (constraint between feature 1 and feature 2);
      • It is necessary that the latest software release be installed for the router to support the new address space . (constraint between feature 2 and feature 3);
      • The router can send packets to the edge system if the latest software release is installed. (constraint between feature 1 and feature 3);
  • How can we write these specifications in a formal language and reason about the system?
syntax elements of the language
P

propositional symbols

(atomic propositions)

Q

P  Q ( - stands for and)

Syntax: Elements of the language

Primitive propositions --- statements like:

Bob loves Alice

Alice loves Bob

Compound propositions

Bob loves Alice and Alice loves Bob

connectives
Connectives
  • ¬ - not
  •  - and
  •  - or
  •  - implies
  •  - equivalent (if and only if)
slide11
Syntax
  • Syntax of Well Formed Formulas (wffs)or sentences
    • Atomic sentences are wffs:

Propositional symbol (atom)

Examples: P, Q, R, BlockIsRed, SeasonIsWinter

    • Complex or compound wffs.

Given w1 and w2 wffs:

 w1 (negation)

(w1  w2) (conjunction)

(w1  w2) (disjunction)

(w1  w2) (implication; w1 is the antecedent;

w2 is the consequent)

(w1  w2) (biconditional)

slide12
Propositional logic: Examples

Examples of wffs

  • P  Q
  • (P  Q)  R
  • P  Q  P
  • (P  Q)  (Q  P)
  •  P
  • P  

This is not a wff!

  • Note1: atoms or negated atoms are called literals; examples p and p are literals. P  Q is a “compound statement or proposition”.
  • Note2: parentheses are important to ensure that the syntax is unambiguous. Quite often parentheses are omitted. The order of precedence in propositional logic is (from highest to lowest):  ,, , , 
propositional logic syntax vs semantics
Propositional Logic:Syntax vs. Semantics
  • Semantics has to do with “meaning”:
  • it associates the elements of a logical language with the elements of a “domain of discourse” (“the world”).
  • Propositional Logic – we associate atoms with propositions / assertionsabout the world (therefore propositional logic).
propositional logic semantics
Propositional Logic:Semantics
  • Interpretation or Truth Assignment:
  • Assignment of truth values (True or False) to every proposition (atom).
  • So if for n atomic propositions, there are 2n truth assignments or interpretations.
  • This makes the representation powerful: the propositions implicitly capture 2n possible states of the world.
slide15
Which ones are propositions?
  • Cornell University is in Ithaca, NY
  • Cornell University is in Palo Alto, CA
  • 1 + 1 = 2
  • what time is it?
  • 2 + 3 = 10
  • watch your step!

Note that a proposition can be False!

slide16
Aside:

We might associate the atom (just a symbol!) BlockIsRed with the proposition: “The block is Red”, but we could also associate it with the proposition “The table is round” even though this would be quite confusing…

BlockIsRed has value True just in the case the block is red; otherwise BlockIsRed is False. (Aside: computers manipulate symbols. The string “BlockIsRed” does not “mean” anything to the computer. Meaning has to come from how to come from …

relations to other symbols and the “external world”.

How can a computer / robot obtain the meaning ``The block is Red’’?

The fact that computers only “push around symbols” led to quite a bit of confusion in the early days or Artificial Intelligence, Robotics, and natural language understanding. Need: “Symbol Grounding”.

propositional logic semantics17
Propositional Logic:Semantics

Truth table for connectives

Given the values of atoms under some interpretation, we can use a truth table to compute the value for any wff under that same interpretation; the truth table establishes the semantics (meaning) of thepropositional connectives. (“Compositional semantics.”)

We can use the truth table to compute the value of any wff given the values of the constituent atom

in the wff. Note: In table, P and Q can be compound propositions themselves. Note: implication

not necessarily aligned with English usage.

slide18
Implication (p  q)
  • This is only False (violated) when q is False and p is True.
  • So, when thinking about an implication, think about the “False case”.
  • Related implications:
    • Converse: q  p
    • Contra-positive: q   p
    • Inversep   q

Important: only the contra-positive of p  q is equivalent to p  q (i.e., has the same truth values in all models); the converse and the inverse are equivalent.

slide19
Implication (p  q)
  • if p then q
  • if p, q
  • p is sufficient for q
  • q if p
  • q when p
  • a necessary condition for p is q (*)
  • p implies q
  • p only if q (*)
  • a sufficient condition for q is p
  • q whenever p
  • q is necessary for p (*)
  • q follows from p
  • Implication plays an important role in reasoning a variety of terminology
  • is used to refer to implication:

Note: the mathematical concept of implication is independent of a cause and effect

relationship between the hypothesis (p) and the conclusion (q), that is normally

present when we use implication in English.

Note: Focus on the case, when is the statement False. I.e., p is True and q is False, should

be the only case that makes the statement false.

(*) Note: assuming the statement true, for p to be true, q has to be true.

slide20
Propositional Logic:Semantics

Notes: Bi-conditionals (p  q)

  • p is necessary and sufficient for q
  • if p then q, and conversely
  • p if and only if q
  • p iff q
  • Variety of terminology :

p  q is equivalent to (pq)  (q p)

Note: the if and only if construction used in biconditionals is rarely used in common language.

Example: “if you finish your meal, then you can play,” what is really meant is:

“If you finish your meal, then you can play” (i.e., (p  q)) and

“You can play, only if you finish your meal” (i.e., (q  p)).

exclusive or
Exclusive Or
  • Truth Table
  • P Q P  Q
  • _____________
  • T T F
  • T F T
  • F T T
  • F F F

P  Q is equivalent to (P ¬Q)  (¬PQ)

and also equivalent to ¬ (P  Q)

Use a truth table to check these equivalences.

propositional logic satisfiability and models
Propositional Logic:Satisfiability and Models

Satisfiability and Models

An interpretation or truth assignment satisfiesa wff, if the wff is assigned the

value True, under that interpretation. An interpretation that satisfies a wff is

called a modelof that wff.

Given an interpretation (i.e., the truth values for the n atoms) the one

can use the truth table to find the value of any wff.

the truth table method
The truth table method

(Propositional) logic has a “truth compositional semantics”:

Meaning is built up from the meaning of its primitive parts (just like English text).

inconsistency unsatisfiability and validity
Inconsistency (Unsatisfiability) and Validity

Inconsistent or Unsatisfiable set of WFFs

  • It is possible that no interpretation satisfies a set of wffs
  • In that case we say that the set of wffs is inconsistent or unsatisfiable or a contradiction
  • Examples of inconsistent sets:
  • 1 {P  P}
  • 2 { P  Q, P Q, P  Q, P Q}

Why??

Validity (Tautology) of a set of WFFS

If a wff is True under all the interpretations of its constituents atoms, we say that

the wff is valid or it is a tautology.

Examples:

1 P  P 2 (P  P) 3 [P  (Q  P)] 4 [(P  Q) P) P]

logical equivalence

Logical equivalence

Useful to

understand it

and memorize it

  • Two sentences p an q are logically equivalent ( or ) iff p  q is a tautology
  • (and therefore p and q have the same truth value for all truth assignments)

Note: logical equivalence (or iff) allows us to make statements about PL, pretty

much like we use = in in ordinary mathematics.

example formalization of software specification
Example:Formalization of software specification
  • Consider the following description:
    • The router can send packets to the edge system only if it supports the new address space. For the router to support the new address space it is necessary that the latest software release be installed. The router can send packets to the edge system if the latest software release is installed. The router does not support the new address space.
    • Features:
      • Router
        • P - router can send packets to the edge of system
        • Q - router supports the new address space
      • Latest software release
        • R – latest software release is installed
slide27
P - router can send packets to the edge of system

Q - router supports the new address space

R – latest software release is installed

Formal:

  • The router can send packets to the edge of system only if it supports

the new address space. (constraint between feature 1 and feature 2)

    • If (router can send packets to the edge of system) then P  Q

(router supports the new address space )

  • For the router to support the new address space it is necessary that the

latest software release be installed. (constraint between feature 2 and feature 3);

    • If (router supports the new address space ) then

(latest software release is installed) Q  R

  • The router can send packets to the edge system if the latest software release

is installed. (constraint between feature 1 and feature 3);

If (latest software release is installed) then

(router can send packets to the edge of system) R  P

  • The router does not support the new address space. ¬ Q
propositional logic rules of inference or methods of proof
Propositional logic: Rules of Inference or Methods of Proof
  • How to produce additional wffs (sentences) from other ones? What steps can we
  • perform to show that a conclusion follows logically from a set of hypotheses?
  • Example: Modus Ponens

P

P  Q

______________

 Q

The hypotheses (premises) are written in a column and the conclusions below bar.

The symbol  denotes “therefore”. Given the hypotheses, the conclusion follows.

The basis for this rule of inference is the tautology (P  (P  Q))  Q)

[aside: check tautology with truth table to make sure]

  • In words: when P and P  Q are True, then Q must be True also.
  • (meaning of second implication)
  • Aside:P  Q P  Q (implication elimination)

Verify!

propositional logic rules of inference or methods of proof30
Propositional logic: Rules of Inference or Methods of Proof
  • Example
  • Modus Ponens

If you study the INFO2950 material, then you will pass

You study the INFO2950 material

______________

 You will pass

  • Nothing “deep”, but again remember the formal reason is that
  • ((P ^ (P  Q))  Q is a tautology. (I.e., this statement holds in anu conceivable world (truth assignment)!)
valid arguments or proofs
Valid Argumentsor Proofs
  • An argument is a sequence of propositions. The final proposition is called the conclusion of the argument while the other proposition are called the premises or hypotheses of the argument.
  • An argument is valid whenever the truth of all its premises implies the truth of its conclusion.
  • How to show that q logically follows from the hypotheses (p1 p2  …pn)?

Show that

(p1  p2  …pn)  q is a tautology

Also,

one can use the rules of inference to show the validity of an argument.

Note that p1, p2, … q are generally compound propositions or wffs.

length of proofs
Length of Proofs
  • Why bother with inference rules? We could always use a truth table
  • to check the validity of a conclusion from a set of premises.

But, resulting proof can be much shorter than truth table method.

Consider premises:

p_1, p_1  p_2, p_2  p_3, …, p_(n-1)  p_n

To prove conclusion: p_n

Inference rules: Truth table:

n-1 MP steps

2n

Key open question: Is there always a short proof for any valid

conclusion? Probably not. The NP vs. co-NP question.

(The closely related: P vs. NP question carries a $1M prize.)

predicates
Predicates
  • Propositional logic assumes the world contains facts that are true or false.
  • But let’s consider a statement containing a variable:
  • x > 3 since we don’t know the value of x we cannot say whether the expression is true or false
  • x > 3 which corresponds to “x is greater than 3”

Predicate, i.e. a property of x

slide36
“x is greater than 3” can be represented as P(x), where P denotes “greater than 3”
  • In general a statement involving n variables x1, x2, … xn can be denoted by
  • P(x1, x2, … xn )
  • P is called a predicate or the propositional function P at the n-tuple (x1, x2, … xn ).
slide37
When all the variables in a predicate are assigned values 

Proposition, with a certain truth value.

Predicate: On(x,y)

Propositions:

ON(A,B) is False (in figure)

ON(B,A) is True

Clear(B) is True

variables and quantification
Variables and Quantification
  • How would we say that every block in the world has a property – say “clear”? We would have to say:
  • Clear(A); Clear(B); … for all the blocks… (it may be long or worse we may have an infinite number of blocks…)

What we need is: Quantifiers

 Universal quantifier

x P(x)

- P(x) is true for all the values x in the universe of discourse

 Existential quantifier

x P(x)

- there exists an element x in the universe of discourse

such that P(x) is true

universal quantification
Universal quantification
  • Everyone at Cornell is smart:
  • x At(x,Cornell)  Smart(x)
  • Implicity equivalent to the conjunction of instantiations of P

At(Mary,Cornell)  Smart(Mary)

 At(Richard,Cornell)  Smart(Richard)

 At(John,Cornell) Smart(John)

 …

a common mistake to avoid
A common mistake to avoid
  • Typically,  is the main connective with 
  • Common mistake: using  as the main connective with :

x At(x,Cornell)  Smart(x)

Means:

“Everyone is at Cornell and everyone is smart.”

existential quantification
Existential quantification
  • Someone at Cornell is smart:
  • x (At(x,Cornell)  Smart(x))
  • xP(x) “ There exists an element x in the universe of discourse such that P(x) is true”
  • Equivalent to the disjunction of instantiations of P

(At(John,Cornell)  Smart(John))

 (At(Mary,Cornell)  Smart(Mary))

 (At(Richard,Cornell)  Smart(Richard))

 ...

another common mistake to avoid
Another common mistake to avoid
  • Typically,  is the main connective with 
  • Common mistake: using  as the main connective with :
  • x At(x,Cornell)  Smart(x)
  • when is this true?

is true if there is anyone who is not at Cornell!

quantified formulas
Quantified formulas
  • If α is a wff and x is a variable symbol, then both x αand x αare
  • wffs.
  • x is the variable quantified over
  • α is said to be within the scope of the quantifier
  • if all the variables in α are quantified over in α, we say that we have a closed wff or closed sentence.
  • Examples:
  • x [P(x)  R(x)]
  • x [P(x)(y [R(x,y)  S(x))]]
properties of quantifiers
Properties of quantifiers
  • x y is the same as yx
  • x y is the same as yx
  • x y is not the same as yx
  • xy Loves(x,y)
    • “Everyone in the world loves at least one person”
  • y x Loves(x,y)
  • Quantifier duality: each can be expressed using the other
  • x Likes(x,IceCream) x Likes(x,IceCream)
  • x Likes(x,Broccoli) xLikes(x,Broccoli)
  • “There is a person who is loved by everyone in the world”
love affairs loves x y x loves y
Love Affairs Loves(x,y) x loves y
  • Loves(x,y) --- x loves y
  • Everybody loves Jerry
  • x Loves (x, Jerry)
  • Everybody loves somebody
  • x yLoves (x, y)
  • There is somebody whom somebody loves
  • yxLoves (x, y)
  • Nobody loves everybody
  •  x yLoves (x, y) ≡ xyLoves (x, y)
  • There is somebody whom Lydia doesn’t love
  • yLoves (Lydia, y)

Note: flipping quantifiers when ¬ moves in.

love affairs continued
Love Affairscontinued…
  • There is somebody whom no one loves
  • y xLoves (x, y)
  • There is exactly one person whom everybody loves (uniqueness)
  • y (x Loves(x,y)  z((w Loves (w ,z)  z = y))
  • There are exactly two people whom Lynn Loves
  • x y ((xy)  Loves(Lynn,x)  Loves(Lynn,y) 
  • z ( Loves (Lynn ,z) (z=x  z=y))) (i.e. “we can count and
  • do numbers”)
  • Everybody loves himself or herself
  • x Loves(x,x)
  • There is someone who loves no one besides herself or himself
  • x y Loves(x,y)  (x = y) (note biconditional – why?)
slide47
Let Q(x,y) denote “xy =0”; consider the domain of discourse the real
  • numbers
  • What is the truth value of
  • a) y x Q(x,y)?
  • b) x y Q(x,y)?
  • So, we can concisely formulate properties (potentially rather complex) of
  • numbers.

False

True (additive inverse)

slide50
The kinship domain:
  • Brothers are siblings

x,yBrother(x,y) Sibling(x,y)

  • One's mother is one's female parent

m,cMother(c) = m (Female(m) Parent(m,c))

[defines the functionsymbol“Mother(x)”]

  • “Sibling” is symmetric

x,ySibling(x,y) Sibling(y,x)

slide52
Example:
  • Let Info2950(x) denote: x is taking Info2950 class
  • Let IS(x) denote: x has taken a course in IS
  • Consider the premises x (Info2950(x)  IS(x))
  • Info2950(Ron)
  • We can conclude IS(Ron)
arguments
Arguments
  • Argument (formal):
  • Step Reason
  • 1 x (Info2950(x)  IS(x)) premise
  • 2 Info2950(Ron)  IS(Ron) Universal Instantiation
  • 3 Info2950(Ron) Premise
  • 4 IS(Ron) Modus Ponens (2 and 3)
example
Example
  • Show that the premises:
  • 1- A student in this class has not read the textbook
  • 2- Everyone in this class passed the first homework
  • Imply
  • Someone who has passed the first homework has not read the textbook

Aside: not recommended of course! 

example55
Example
  • Solution:
  • Let
  • C(x) x is in this class
  • T(x) x has read the textbook
  • P(x) x passed the first homework
  • [always define carefully!]
  • Premises:
  • x (C(x)  T(x))
  • x (C(x)  P(x))
  • Conclusion: we want to show x (P(x)  T(x))
slide56
  • Step Reason
  • 1 x (C(x) T(x)) Premise
  • 2 C(a)  T(a) Existential Instantiation from 1
  • 3 C(a) Simplification 2
  • 4 x (C(x)P(x)) Premise
  • 5 C(a)  P(a) Universal Instantiation from 4
  • 6 P(a) Modus ponens from 3 and 5
  • 7 T(a) Simplification from 2
  • 8 P(a)   T(a) Conjunction from 6 and 7
  • x P(x) T(x) Existential generalization from 8

Note the careful step-by-step (linear) line of argument. That’s

what we are looking for in rigorous arguments / proofs!!

ad