17
Music AI Music AI Lecture 3 Lecture 3 More on Knowledge More on Knowledge Representation Representation (anaparastasi gnosis) (anaparastasi gnosis) Introduction to searching Introduction to searching (anazitisi) (anazitisi)

Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Embed Size (px)

Citation preview

Page 1: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Music AI Music AI Lecture 3 Lecture 3

More on Knowledge More on Knowledge Representation (anaparastasi Representation (anaparastasi

gnosis) gnosis)

Introduction to searching Introduction to searching (anazitisi) (anazitisi)

Page 2: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Overview Overview

Forwards and backwards deduction Forwards and backwards deduction More on Semantic nets More on Semantic nets Frames and scripts Frames and scripts Grammars and syntactic trees in NLP Grammars and syntactic trees in NLP Break Break Introduction to searching Introduction to searching Exercises Exercises Reading for next week Reading for next week

Page 3: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Forwards deduction Forwards deduction

Knowledge base: Knowledge base: Mary coughs. Mary coughs. Mary has temperature. Mary has temperature. Mary and John are together. Mary and John are together. Is someone coughs and has temperature, then he has Is someone coughs and has temperature, then he has

a cold. a cold. If someone is together with someone else, then the If someone is together with someone else, then the

someone else is together with the someone. (?!) someone else is together with the someone. (?!) If someone has a cold and is together with someone If someone has a cold and is together with someone

else, then this someone else also has a cold. else, then this someone else also has a cold. Task 1:Task 1: Translate the above into a KR formalism. Translate the above into a KR formalism.

Page 4: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Forwards deduction Forwards deduction

Knowledge base: Knowledge base: coughs(mary). coughs(mary).

has_temperature(mary). has_temperature(mary).

together(mary,john). together(mary,john).

coughs(X) ^ has_temperature(X) coughs(X) ^ has_temperature(X) hascold(X) hascold(X)

together(Plato, Socrates) together(Plato, Socrates) together(Socrates,Plato) together(Socrates,Plato)

hascold(A) ^ together(B,A) hascold(A) ^ together(B,A) hascold(B) hascold(B) Task 2: Prove that John has a cold Task 2: Prove that John has a cold

Page 5: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Forwards deduction: Forwards deduction:

write here the correct answerwrite here the correct answer

Page 6: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Tips for deductions: Tips for deductions:

In predicate unification, make sure the In predicate unification, make sure the names of predicates match exactly. names of predicates match exactly.

You don’t have to use all the facts and rules You don’t have to use all the facts and rules in the knowledge base to prove something. in the knowledge base to prove something.

Don’t get confused with variable names. Don’t get confused with variable names. Variables start with a capital, and if they are Variables start with a capital, and if they are confusing, substitute them with X,Y etc. confusing, substitute them with X,Y etc.

If you are unsure, write down what you want If you are unsure, write down what you want to say in English. Then translate it into to say in English. Then translate it into predicate logic notation. predicate logic notation.

Page 7: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Backwards deduction Backwards deduction Knowledge base:Knowledge base: coughs(mary). coughs(mary). has_temperature(mary). has_temperature(mary). together(mary,john). together(mary,john). coughs(X) ^ has_temperature(X) coughs(X) ^ has_temperature(X) hascold(X). hascold(X). together(Plato, Socrates) together(Plato, Socrates) together(Socrates,Plato). together(Socrates,Plato). hascold(A) ^ together(B,A) hascold(A) ^ together(B,A) hascold(B). hascold(B). goes_swimming(Snoopy) goes_swimming(Snoopy) hascold(Snoopy). hascold(Snoopy). hascold(Beast) ^ together (Beauty, Beast) hascold(Beast) ^ together (Beauty, Beast)

takes_care(Beauty, takes_care(Beauty, Beast). Beast).

hascold(Cold) ^ drinks_from_same_glass(Hot, Cold) hascold(Cold) ^ drinks_from_same_glass(Hot, Cold) hascold(Hot). hascold(Hot).

weather(freezing) weather(freezing) hascold(House). hascold(House). hastemperature(mary) hastemperature(mary) says_nonsense(mary). says_nonsense(mary). (What is the problem with the last rule?) (What is the problem with the last rule?)

Page 8: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Backwards deduction Backwards deduction

Task: Using the above KB, prove that Task: Using the above KB, prove that John has a cold. In doing that, show John has a cold. In doing that, show all the options of rules and where all the options of rules and where they lead to. they lead to.

Page 9: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Backwards deduction: Backwards deduction:

Write down the answer hereWrite down the answer here

Page 10: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Semantic Networks, frames and Semantic Networks, frames and scripts scripts

Page 11: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Task Task

In groups, think of a different example In groups, think of a different example of a frame, and of a script. Write it of a frame, and of a script. Write it out into some detail. out into some detail.

Page 12: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Syntactic rules so far: Syntactic rules so far:

s s np, vp. np, vp. np np det, n. det, n. np np n. n. vp vp v. v. vp vp v, np. v, np.

Page 13: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Task: Draw the syntactic tree: Task: Draw the syntactic tree:

The baby cries. The baby cries.

Obelix ate the Roman. Obelix ate the Roman.

Page 14: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Ungrammatical sentences : Ungrammatical sentences :

A sentence that cannot be explained with A sentence that cannot be explained with our grammar is our grammar is UngrammaticalUngrammatical. .

Which of the following are ungrammatical? Which of the following are ungrammatical? • I am reading. I am reading. • Tarzan kissed Jane in the rain. Tarzan kissed Jane in the rain. • I hate Mondays. I hate Mondays. • A dictionary of philosophy. A dictionary of philosophy. • Sing! Sing! • The book is on the shelf. The book is on the shelf. • Chris wears glasses. Chris wears glasses.

Page 15: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Searching (anazitisi) Searching (anazitisi)

Lets play tic tac toe (triliza) ... Lets play tic tac toe (triliza) ... What is a What is a search spacesearch space? (xwros anazitisis) ? (xwros anazitisis) What is a What is a search treesearch tree? (dentro) ? (dentro) What is a What is a search strategysearch strategy? (stratigiki) ? (stratigiki) What is What is depth first search (DFS)depth first search (DFS)? (kata vathos) ? (kata vathos) What is What is breadth first search (BFS)breadth first search (BFS)? (kata platos) ? (kata platos) What is a What is a heuristicheuristic? (euristiki sinartisi) ? (euristiki sinartisi) How can we use heuristics to cut down the search How can we use heuristics to cut down the search

tree? tree?

Page 16: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Task: Think of a favourite game or problem that needs Task: Think of a favourite game or problem that needs solving. Create the (part of) the first two levels of the solving. Create the (part of) the first two levels of the

search space in a tree diagramsearch space in a tree diagram..

Page 17: Music AI Lecture 3 More on Knowledge Representation (anaparastasi gnosis) Introduction to searching (anazitisi)

Reading for next week Reading for next week

Revise everything so far Revise everything so far

Question: Can we devise grammars Question: Can we devise grammars for music? (200-300 words) for music? (200-300 words)