Artificial Intelligence - PowerPoint PPT Presentation

1 / 69
About This Presentation
Title:

Artificial Intelligence

Description:

Knowledge bases consist of sentences. ... Example: Prove that A ? B and B ? A are logically equivalent. / 68. 21. Logical Equivalences ... – PowerPoint PPT presentation

Number of Views:159
Avg rating:3.0/5.0
Slides: 70
Provided by: ahmed8
Category:

less

Transcript and Presenter's Notes

Title: Artificial Intelligence


1
Artificial Intelligence
2
  • Ahmed M. Zeki
  • Sem 2, Nov 2004

2
Logic
  • Knowledge bases consist of sentences.
  • These sentences are expressed according to the
    syntax of the representation language, which
    specifies all the sentences that are well formed.
  • The notion of syntax is clear enough in ordinary
    arithmetic x y 4 is a well-formed
    sentence, whereas x2y is not.

3
Logic
  • The logic must also define the semantics of the
    language. Semantics has to do with the meaning
    of sentences.
  • The semantics of the language defines the truth
    of each sentence with respect to each possible
    world (or model).
  • For example, the usual semantics adopted for
    arithmetic specifies that the sentence x y
    4 is true in a world where x is 2 and y is 2,
    but false in a world where x is 1 and y is 1.
  • In standard logics, every sentence must be either
    true or false in each possible world, there is no
    in-between.

4
Logic
  • The relation of logical entailment between
    sentences the idea that a sentence follows
    logically from another sentence.
  • a ? b means that sentence a entails the sentence
    b.
  • The formal definition of entailment is
  • a ? b if and only if, in every model in which a
    is true, b is also true.
  • a ? b if a is true, then b must also be true.
  • a ? b the truth of b is contained in the truth of
    a.

5
Propositional Logic
  • The syntax of propositional logic defines the
    allowable sentences.
  • The atomic sentences -the indivisible syntactic
    elements- consists of a single proposition
    symbol.
  • Each such symbol stands for a proposition that
    can be true or false.
  • Uppercase names will be used for symbols (e.g. P,
    Q and R).

6
Propositional Logic
  • There are two proposition symbols with fixed
    meanings
  • True is the always-true proposition.
  • False is the always-false proposition.
  • Complex sentences are constructed from simpler
    sentences using logical connectives.

7
The five connectives
  • not
  • The sentence such as W is called the negation of
    W.
  • ? and
  • A sentence whose main connective is ?, such as W
    ? P, is called conjunction its parts are the
    conjuncts.
  • V or
  • A sentence using V, such as W V P is a
    disjunction of the disuncts W and P.
  • ? implies
  • A sentence such as (W ? P) ? W is called an
    implication (or conditional). Its premise or
    antecedent is (W ? P) and its conclusion or
    consequent is W.
  • ? if and only if
  • The sentence W ?? P is a biconditional

8
Propositional Logic
  • The grammar is very strict about parentheses
    every sentence constructed with binary
    connectives must be enclosed in parentheses.
  • The order of precedence in propositional logic is
    from higher to lowest , ?, V, ? and ? .
  • e.g The sentence
  • P V Q ? R ? S
  • is equivalent to the sentence
  • ((P) V (Q ? R)) ? S

9
Propositional Logic
  • Precedence does not resolve ambiguity in
    sentences such as A ? B ? C which could be read
    as ((A ? B) ? C) or as (A ? (B ? C)).
  • Sentences such as A ? B ? C are not allowed
    because the two readings have different meanings,
    hence we insist on parentheses in this case.

10
Propositional Logic
  • The semantics defines the rules for determining
    the truth of a sentence with respect to a
    particular model.
  • In propositional logic, a model simply fixes the
    truth values true or false- for every
    proposition symbol.
  • For example, if the sentences in the knowledge
    base make use of the proposition symbols P, Q and
    S, then one possible model is
  • m1 P false, Q false, S true)
  • With three proposition symbols, there are 23 8
    possible models.

11
Propositional Logic
  • The semantics for propositional logic must
    specify how to compute the truth value of any
    sentence, given a model.
  • All sentences are constructed from atomic
    sentences and the five connectives.
  • We need to specify
  • how to compute the truth of atomic sentences
  • How to compute the truth of sentences formed with
    each of the five connectives.

12
Propositional Logic
  • Atomic sentences are easy
  • True is true in every model and false is false in
    every model.
  • The truth value of every other proposition symbol
    must be specified directly in the model. For
    example in the model m1, P is false.
  • m1 P false, Q false, S true)
  • For complex sentences, we have rules such as
  • For any sentence s and any model m, the sentence
    s is true in m if and only if s is false in m.

13
Truth Tables
  • Such rules reduce the truth of a complex sentence
    to the truth of simpler sentences.
  • The rules for each connective can be summarized
    in a truth table that specifies the truth value
    of a complex sentence for each possible
    assignment of truth values to its components.
  • Using the truth tables in the next slide, the
    truth value of any sentence s can be computed
    with respect to any model m by simple process of
    recursive evaluation.

14
The Truth Tables for the five logical connectives
XOR.
15
Example
  • m1 P false, Q false, S true)
  • The sentence P ? (Q V S) evaluated in m1, gives
  • T ? (F V T) T ? T T
  • It can also be solved using truth tables.

16
Example
  • Apply the given connectives on the following
    sentences
  • P 5 is odd
  • Q Kuala Lumpur is the Capital of Malaysia

17
Examples
  • Construct a truth table for the proposition
  • ( Q ? P ) ? P
  • Construct a truth table for the proposition
  • ( P ? Q) V R ? P

18
Tautology and Contradiction
  • A tautology is a propositional form whose truth
    values is true for all possible values of its
    propositional variables, e.g., P V P. It is also
    known as valid sentence, i.e a sentence is valid
    if it is true in all models.
  • A contradiction is a propositional form which is
    always false, such as P ? P.
  • A propositional form which is neither a tautology
    nor a contradiction is called a contingency.

19
Propositional Logic
  • Previously we said that a knowledge base consists
    of a set of sentences.
  • We can now see that a logical knowledge base is a
    conjunction of those sentences.
  • That is, if we start with an empty KB and do
  • TELL(KB S1)
  • TELL(KB Sn)
  • then KB S1 ? ? Sn.
  • This means that we can treat knowledge bases and
    sentences interchangeably.

20
Equivalence
  • Two sentences A and B are logically equivalent if
    they are true in the same set of models. A ? B
  • Example Prove that A ? B and B ? A are logically
    equivalent.

21
Logical Equivalences
  • (A ? B) ? (B ? A) Commutativity of ?
  • (A V B) ? (B V A) Commutativity of V
  • (( A ? B) ? C) ? ( A ? (B ? C)) Associativity of
    ?
  • (( A V B) V C) ? ( A V (B V C)) Associativity of
    V
  • (P) ? P Double-Negation Elimination

22
Logical Equivalences
  • (A ? B) ? ( B ? A) Contraposition
  • (A ? B) ? (A V B) Implication elimination
  • (A ? B) ? (( A ? B) ? (B ? A)) biconditional
    elimination
  • ( A ? B ) ? (A V B) de Morgan
  • ( A V B ) ? (A ? B) de Morgan
  • (A ? ( B V C)) ? ((A ? B ) V (A ? C ))
    Distributivity of ? over V
  • (A V ( B ? C)) ? ((A V B ) ? (A V C ))
    Distributivity of V over ?

23
Example
  • Simplify the following propositional form
  • (A ? B) V (A ? D) ? (BVD)
  • Answer
  • (A V B) V (A V D) ? (B V D)
  • A V (B V D) ? (B V D)
  • A V (B V D) V (B V D)
  • A ? (B V D) V (B V D)
  • (A V B V D) ? (B V D) V (B V D)
  • (A V B V D) ? 1
  • A V B V D

24
Reasoning Patterns in Propositional Logic
  • The standard patterns of inference that can be
    applied to derive chains of conclusions that lead
    to the desired goal are called inference rules.
  • The best-known rule is called Modus Ponens and is
    written as follows
  • A ? B, A then B
  • The notation means that, if (A ? B) and A are
    true then B should be true.
  • Another useful inference rule is And-Elimination,
    which says that, from a conjunction, any of the
    conjuncts can be inferred
  • If (A ? B) is true then A is true
  • All of the logical equivalences can be used as
    inference rules.

25
Reasoning Patterns in Propositional Logic
  • If A ? B then (A ? B) ? (B ? A)
  • If (A ? B) ? (B ? A) then A ? B

26
Summary
  • Intelligent agents need knowledge about the world
    in order to reach good decisions.
  • Knowledge is contained in agents in the form of
    sentences in a knowledge representation language
    that are stored in a knowledge base.
  • A knowledge-based agent is composed of a
    knowledge base and an inference mechanism. It
    operates by storing sentences about the world in
    its knowledge base, using the inference mechanism
    to infer new sentences, and using these sentences
    to decide what action to take.

27
Summary
  • A representation language is defined by its
    syntax, which specifies the structure of
    sentences, and its semantics, which defines the
    truth of each sentence in each possible world or
    model.
  • The relationship of entailment between sentences
    is crucial to our understanding of reasoning. A
    sentence A is entails another sentence B if B is
    true in all worlds where A is true. Equivalent
    definitions include the validity of the sentence
    A ? B and the unsatisfiability of the sentence A
    ? B.

28
Summary
  • Inference is the process of deriving new
    sentences from old ones.
  • Propositional logic is a very simple language
    consisting of proposition symbols and logical
    connectives. It can handle propositions that are
    known true, known false, or completely unknown.
  • The set of possible models, given a fixed
    propositional vocabulary is finite, so entailment
    can be checked by enumerating models. Efficient
    model-checking inference algorithms for
    propositional logic include backtracking and
    local-search methods and can often solve large
    problems very quickly.

29
Summary
  • Inference rules are patterns of inference that
    can be used to find proofs. The resolution rule
    yields a complete inference algorithm for
    knowledge bases that are expressed in conjuctive
    normal form.

30
Exercises
  • Russell, page 236
  • 7.3 b
  • 7.5
  • 7.7
  • 7.8
  • 7.12 a,b

31
Assignment (3rd Jan)
  • (1) Construct a truth table for the propositions
  • (Q ? P ) ? P
  • (P ? Q ) V R ? P

32
  • (2) Simplify the following propositional form
  • (A ? B) V (A ? D) ? (B V D)
  • (3) Prove the following logical implications
  • P ? (P V Q)
  • P ? (P V Q) ? Q
  • (P ? Q) ? (Q ? R) ? (P ? R)

33
  • (4) Let P be the proposition It is snowing
  • Let Q be the proposition I will go to town
  • Let R be the proposition I have time
  • Using logical connectives, write a proposition
    which symbolizes each of the following
  • If it is snowing and I have time, then I will go
    to town.
  • I will go to town only if I have time.
  • It is not snowing.
  • It is snowing, and I will not go to town.
  • Write the following sentences in English
  • Q ? (R ? P)
  • (Q ? R) ? (R ? Q)

34
  • (5) Establish whether the following propositions
    are tautologies, contingencies or contradictions
  • P V P
  • P ? P
  • P ? (P V Q)
  • (P ? Q) ? P
  • (P ? Q) ? P ? P ? Q
  • (P ? Q) V (R ? S) ? (P V R) ? (Q V S)

35
  • (6) For each of the following expressions, use
    identities to find equivalent expressions which
    use only ? and and are as simple as possible.
  • P V Q V R
  • P V (Q ? R) ? P
  • P ? (Q ? P)

36
  • (7) Establish the following tautologies by
    simplifying the left side to the form of the
    right side
  • (P ? P) ? (P ? P) ? 0

37
First-Order Logic
  • We used propositional logic as our representation
    language because it sufficed to illustrate the
    basic concepts of logic and knowledge-based
    agents. Unfortunately, propositional logic is too
    puny a language to represent knowledge of complex
    environments in a concise way.
  • First-order logic is sufficiently expressive to
    represent a good deal of our commonsense
    knowledge.

38
Programming Languages
  • Programming languages such as C or Java or Lisp
    are by far the largest class of formal languages
    in common use.
  • Programmers themselves represent, in a direct
    sense, only computational processes.
  • Data structures within programs can represent
    facts. For example, a 1 by 2 array may represent
    4 different cases.

39
  • What programming languages lack is any general
    mechanism for deriving facts from other facts
    each update to a data structure is done by a
    domain-specific procedure whose details are
    derived by the programmer from his or her own
    knowledge of the domain.
  • This procedural approach can be contrasted with
    the declarative nature of propositional logic, in
    which knowledge and inference are separate, and
    inference is entirely domain-independent.

40
  • Another drawback of data structure in programs is
    the lack of any easy way to say There is a king
    in square 4,5 or if the queen is in square 5,2
    then he is not in 7,6. Programs can store a
    single value for each variable, and some systems
    allow the value to be unknown, but they lack the
    expressiveness required to handle partial
    information.

41
  • Propositional logic is declarative language
    because its semantics is based on a truth
    relation between sentences and possible worlds.
    It also has sufficient expressive power to deal
    with partial information, using disjunction and
    negation.
  • Propositional logic has a third property that is
    desirable in representation languages, namely
    compositionality which means that the meaning of
    a sentence is a function of the meaning of its
    parts.
  • Eg.
  • A it is raining
  • B I have no umbrella
  • A ? B It is raining and I have no umbrella
  • Impossible A ? B IIUM is a university ?

42
  • Propositional logic lacks the expressive power to
    describe an environment with many objects
    concisely.
  • Example any piece in a square adjacent to the
    king can be killed.
  • The language of first-order logic is built around
    objects and relations.
  • First-order logic can also express facts about
    some or all of the objects in the universe. This
    represent general laws or rules.

43
Models for First-Order Logic
  • Models of FOL have objects in them. The domain of
    a model is the set of objects it contains these
    objects are sometimes called domain elements.
  • Atomic Sentence is formed from a predicate symbol
    (relation) followed by a parenthesized list of
    terms (objects).
  • Brother(Al-Hasan, Al-Husain)
  • Married(Father(Al-Hasan), Mother(Al-Husain))
  • An atomic sentence is true in a given model,
    under a given interpretation, if the relation
    referred to by the predicate symbol holds among
    the objects referred to by the arguments.

44
  • Logical connectives are used to construct more
    complex senteces.
  • Brother(Ahmed, Father(Naim))
  • Brother(Fadhil, Anees) ? Brother(Ali, Khalid)
  • King(Zul) ? King(Khairul)

45
Quantifiers
  • Used to express properties of entire collections
    of objects instead of enumerating the objects by
    name.
  • Universal (For all)
  • Existential
  • Universal
  • All kings are persons
  • Å x King(x) ? Person(x)
  • For all x, if x is a king, then x is a person.
  • x is a variable

46
  • Å x P, where P is any logical expression, means
    that P is true for every object x.
  • If the assertion P(x) is true for every possible
    value of x, then Å x P(x) is true otherwise Å x
    P(x) is false.
  • For any predicate P and any element c of the
    universe (domain) Å x P(x) ? P(c).

47
Examples
  • Å x x lt x 1 true
  • Å x x 3 false
  • If A is an integer array with 50 entries, A1,
    A2 A50 then we can assert that all entries
    are nonzero as follows
  • Å i (1 i and i 50) ? Ai ? 0
  • The entries of the array are sorted in
    non-decreasing order if the following assertion
    holds.
  • Å i (1 i and i 50) ? Ai Ai1
  • Å x Å y x y gt x is true if U I.

48
Existential
  • 3 x, P(x) is read as There exists a value of x
    for which the assertion P(x) is true.
  • The symbol 3 is also read as for some or for
    at least one.
  • P(c) ? 3 x, P(x)

49
Examples
  • 3 x, x lt x 1 is true in I.
  • 3 x x 4 is true in I.
  • 3 x x x 1 is false.

50
There is one and only one x3!
  • 3! x x lt 1 is true in I0.
  • 3! x x 5 is true.
  • 3! x x gt 1 is false.

51
Example
  • Let the universe consist of the integer 1, 2, and
    3. then
  • Å x P(x)
  • is equivalent to the conjunction
  • P(1) ? P(2) ? P(3)
  • The proposition
  • 3xP(x)
  • is equivalent to the disjunction
  • P(1) V P(2) V P(3)
  • The proposition
  • 3!x P(x)
  • is equivalent to
  • P(1) ? P(2) ? P(3) V
  • P(1) ? P(2) ? P(3) V
  • P(1) ? P(2) ? P(3)

52
Example
  • In I0, Å x P(x) means P(1) ? P(2) ? P(3) ?
  • The predicate P(x,y,z) represents x y z
    all of its 3 variables are free.
  • If we assign x 2 then the result is the
    predicate P with a bound variable P(2,y,z) which
    can be considered as a new predicate of 2
    variables R(y,z)
  • R(y,z) ?? 3xP(x,y,z) ?? 3xxyz ?? (y z)

53
  • Å x Å y P(x,y) denotes Å x Å y P(x,y)
  • Å x 3 y P(x,y) can be read as no matter what
    value of x is chosen, a value of y can be found
    such that
  • 3 y Å x P(x,y) is read as A value of y can be
    chosen so that no matter what value is chosen for
    x
  • Å x Å y can be replaced by Å y Å x
  • 3 x 3 y can be replaced by 3 y 3 x

54
Examples
  • Å x 3 y x is married to y
  • 3 y Å x x is married to y
  • In I, Å x 3 y x y 0
  • In I, 3 y Å x x y 0
  • In I, Å x Å y 3!z x y z
  • In I, Å x 3!z Å yx y z
  • In I, 3!xx 6 0
  • In I, 3!x Å yx y 0
  • In I, Å y 3!xx y lt 0
  • In I, Å y 3!xx y lt 0
  • T
  • F
  • T
  • F
  • T
  • F
  • T
  • T
  • F
  • F

55
Exercises
  • Let S(x,y,z) denote the predicate xyz
    P(x,y,z) denote x.yz
    L(x,y) denote xlty

    Let the universe of discourse be the natural
    numbers N. Using
    the above predicates, express the following
    assertions.
  • For every x and y, there is a z such that xyz
  • No x is less than 0
  • For all x, x0x
  • For all x,y x.yy
  • There is an x for all y such that x.yy

Correct syntax but the meaning is wrong
56
Example
  • Consider these statements, of which the first
    three are premises and the fourth is a valid
    conclusion.
  • All hummingbirds are richly colored
  • No large birds live on honey
  • Birds that do not live on honey are dull in
    color
  • Hummingbirds are small
  • P(x) denotes x is a hummingbird
  • Q(x) denotes x is large
  • R(x) denotes x lives on honey
  • S(x) denotes x is richly colored

57
Exercises
  • Determine which of the following propositions are
    true if the universe is the set of integers I and
    . denotes the operation of multiplication.
  • True
  • False
  • False
  • True

58
Exercises
  • Specify a universe of discourse for which the
    following propositions are true. Try to choose
    the universe to be as large a subset of the
    integers as possible.
  • All integers greater than 10
  • The universe contains only 3
  • x belongs to I-, y 436-x
  • y belong to I-, xlt-y

59
Exercises
  • Consider the universe of integers and let
    P(x,y,z) denote x-yz. Transcribe the following
    assertions into logical notation.
  • For every x and y, there is some z such that
    x-yz.
  • For every x and y, there is some z such that
    x-zy.
  • There is an x such that for all y, y-xy.
  • When 0 is subtracted from any integer, the result
    is the original integer.
  • 3 subtracted from 5 gives 2.

60
Quantifiers and Logical Operators
  • The the universe be the integers and let

    N(x) denote x is a nonnegative integer,
    E(x) denote
    x is even
    O(x) denote x
    is odd and
    P(x) denote x is
    prime
  • There exists an even integer
  • Every integer is even or odd
  • All prime integers are nonnegative
  • The only even prime is two
  • There is one and only one ven prime
  • Not all integers are odd
  • Not all primes are odd
  • If an integer is not odd, then it is even

61
Examples
  • Consider the universe of integers and let
    P(x,y,z) denote xyz
  • If x 0 then xy0 for all values of y
  • If xy 0 for every y, then x 0

62
Logical Relationships Involving Quantifiers
63
Example
64
Example
  • Let P(x,y,z) denote xy z E(x,y) denote x y
    and G(x,y) denote x gt y.
  • Let the universe of discourse be the integers.
    Transcribe the following into logical notation
  • If y 1, then xy x for any x.
  • 3x 6 if and only if x 2
  • xlty and y ltx is a sufficient condition for yx
  • If x lty and zlt0, then xzgtyz

65
Example
  • Let the universe of discourse be the set of
    arithmetic assertions with predicates defined as
    follows
  • P(x) denotes x is provable
  • T(x) denotes x is true
  • S(x) denotes x is satisfiable
  • D(x,y,z) denotes z is the discjunction x V y
  • Translate the following assertions into English
    statements. Make your transcription as natural as
    possible
  • If y is the assertion w V x, z is the assertion x
    V w and y is provable, then z is provable
  • Every arithmetic assertion which is provable is
    true
  • If z x V y and z is provable, then x is
    provable or y is provable

66
Example
  • Put the following into logical notation. Choose
    predicates so that each assertion requires at
    least one quantifier.
  • There is one and only one even prime.
  • Every train is faster than some cars
  • If it rains tomorrow, then somebody will get wet

67
Example
  • Find an assertion which is logically equivalent
    to but uses only the quantifier
    and the logical operator . Similarly, express
    in terms of and .

68
Example
  • Show that the following is valid for the universe
    of natural numbers N either by expanding the
    statement or by applying identities.

69
Example
  • Show that the following is valid for the universe
    of natural numbers N either by expanding the
    statement or by applying identities.
Write a Comment
User Comments (0)
About PowerShow.com