Artificial Intelligence: Methods and Applications. Info about Assignment 1. Minesweeper. Lecture 4: FO Logic and Knowledge Representation

Assignment 1 Info Artificial Intelligence: Methods and Applications Lecture 4: FO Logic and Knowledge Representation Info about Assignment 1 Henrik...
Author: Kathlyn Willis
6 downloads 0 Views 118KB Size
Assignment 1 Info

Artificial Intelligence: Methods and Applications Lecture 4: FO Logic and Knowledge Representation

Info about Assignment 1

Henrik Björklund Umeå University

21 november 2011

Björklund (UmU)

AIM

21 november 2011

1 / 26

Björklund (UmU)

Assignment 1 Info

AIM

21 november 2011

2 / 26

Assignment 1 Info

Lab sessions

What to hand in

You will have to hand in the following Java files: �

A class definition that implements the interface OthelloAlgorithm.



Assignment 1 is due at 12:00 (noon) on December 5th.





There are lab sessions on November 23d, November 30th, and December 1st.

A class definition that implements the interface OthelloEvaluator, and that works together with your algorightm class.





The session on November 23d (tomorrow) will only last until 11:15.

A class definition that extends the abstract class AbstractOthelloPosition and that works together with your algorithm and evaluator classes.

You also have to hand in a report that describes the structure of your solution. Notice that the class OthelloAction has been updated. (If you do not use Java, contact me about what to hand in.)

Björklund (UmU)

AIM

21 november 2011

3 / 26

Björklund (UmU)

Assignment 1 Info

AIM

21 november 2011

4 / 26

21 november 2011

6 / 26

Minesweeper

Requirements

With appropriate parameters set (e.g., depth), your solution should not use more than 10 seconds per move on average over a game. It should never use more than 30 seconds for any single move.

Minesweeper

The algorithms will be run on a computer from room MA426 or MA436. These computers are HP DC7900 with the following specs: �

OS: Debian GNU/Linux 6.0 64bit.



Processor: Intel Core 2 Quad, 4x266MHz



Memory: 4GB

Your solutions should beat an Alpha-Beta algorithm using the board representation from AbstractOthelloPosition and a very simple heuristic.

Björklund (UmU)

AIM

21 november 2011

5 / 26

Björklund (UmU)

AIM

Minesweeper

Minesweeper

How it should work

Basics

We assume that the system already has vocabulary and axioms for natural numbers, i.e. a relation Num, a function +, relations < and ≤, etc. We use the two unary relations MaxRow and MaxCol to keep track of the number of rows and columns. These numbers have to be unique:

Assume that we want to play a game of Minesweeper on an n × m board. We should be able to dothe following: 1. Tell our KRS that the bord has n rows and m columns. 2. Click on some square in the Minesweeper application. 3. Enter all information we gain into the KRS (e.g., ”square (5,3) has the number 2 on it”). 4. Ask the KRS for a list of safe squares to click on, if there are any. 5. Repeat from (2).

Björklund (UmU)

AIM

21 november 2011

7 / 26

Björklund (UmU)

AIM

Minesweeper

21 november 2011

8 / 26

Minesweeper

Basics

Rows, columns, and squares

We assume that the system already has vocabulary and axioms for natural numbers, i.e. a relation Num, a function +, relations < and ≤, etc. We use the two unary relations MaxRow and MaxCol to keep track of the number of rows and columns. These numbers have to be unique:

We define rows and colums: ∀x (Row(x) ⇔ Num(x) ∧ 0 < x ∧ ∃y (MaxRow(y ) ∧ x ≤ y )) ∀x (Col(x) ⇔ Num(x) ∧ 0 < x ∧ ∃y (MaxCol(y ) ∧ x ≤ y ))

¬∃ x, y (x �= y ∧ MaxRow(x) ∧ MaxRow(x)) ¬∃ x, y (x �= y ∧ MaxCol(x) ∧ MaxCol(x))

Björklund (UmU)

AIM

21 november 2011

8 / 26

Björklund (UmU)

Minesweeper

AIM

21 november 2011

9 / 26

Minesweeper

Rows, columns, and squares

Neighbors

Next, we define the neighbor relation between squares: We define rows and colums:

∀x1 , y1 , x2 , y2 (Neighbor (x1 , y1 , x2 , y2 ) ⇔

∀x (Row(x) ⇔ Num(x) ∧ 0 < x ∧ ∃y (MaxRow(y ) ∧ x ≤ y ))

Square(x1 , y1 ) ∧ Square(x2 , y2 ) ∧ (x1 �= x2 ∨ y1 �= y2 )∧

x1 ≤ x2 + 1 ∧ x2 ≤ x1 + 1 ∧ y1 ≤ y2 + 1 ∧ y2 ≤ y1 + 1)

∀x (Col(x) ⇔ Num(x) ∧ 0 < x ∧ ∃y (MaxCol(y ) ∧ x ≤ y )) And squares:

Björklund (UmU)

∀x, y (Square(x, y ) ⇔ Row(x) ∧ Col(y ))

AIM

21 november 2011

9 / 26

Björklund (UmU)

AIM

21 november 2011

10 / 26

Minesweeper

Minesweeper

Neighbors

Values

Next, we define the neighbor relation between squares:

Finally, we need to define what the numbers on the squares mean. We use one formula for each of the values 0, 1, 2, 3, 4, 5, 6, 7, 8.

∀x1 , y1 , x2 , y2 (Neighbor (x1 , y1 , x2 , y2 ) ⇔

Square(x1 , y1 ) ∧ Square(x2 , y2 ) ∧ (x1 �= x2 ∨ y1 �= y2 )∧

x1 ≤ x2 + 1 ∧ x2 ≤ x1 + 1 ∧ y1 ≤ y2 + 1 ∧ y2 ≤ y1 + 1)

Neighbors with mines on them: ∀x1 , y1 , x2 , y2 (MNeighbor (x1 , y1 , x2 , y2 ) ⇔

Neighbor (x1 , y1 , x2 , y2 ) ∧ Mine(x2 , y2 )

Björklund (UmU)

AIM

21 november 2011

10 / 26

Björklund (UmU)

AIM

Minesweeper

21 november 2011

11 / 26

Minesweeper

Values

Values

Finally, we need to define what the numbers on the squares mean. We use one formula for each of the values 0, 1, 2, 3, 4, 5, 6, 7, 8. For Value(x, y ) = 0 we get

Finally, we need to define what the numbers on the squares mean. We use one formula for each of the values 0, 1, 2, 3, 4, 5, 6, 7, 8. For Value(x, y ) = 0 we get

∀x, y (Value(x, y ) = 0 ⇔ ¬∃x1 , y1 (MNeighbor (x, y , x1 , y2 ))).

∀x, y (Value(x, y ) = 0 ⇔ ¬∃x1 , y1 (MNeighbor (x, y , x1 , y2 ))). For Value(x, y ) = 1: ∀x, y (Value(x, y ) = 1 ⇔ ∃x1 , y1 (MNeighbor (x, y , x1 , y1 )∧

¬∃x2 , y2 ((x1 �= x2 ∨ y1 �= y2 ) ∧ MNeighbor (x, y , x2 , y2 ))))

Björklund (UmU)

AIM

21 november 2011

11 / 26

Björklund (UmU)

Minesweeper

21 november 2011

11 / 26

Minesweeper

Value(x, y ) = 3

Vocabulary

In summary, we have the following vocabulary (on top of the one for natural numbers):

∀x, y (Value(x, y ) = 3 ⇔ ∃x1 , y1 , x2 , y2 , x3 , y3 ((x1 �= x2 ∨ y1 �= y2 ) ∧ (x1 �= x3 ∨ x1 �= y3 )∧ (x2 �= x3 ∨ y2 �= y3 )∧

MNeighbor (x, y , x1 , y1 ) ∧ MNeighbor (x, y , x2 , y2 ) ∧ MNeighbor (x, y , x3 , y3 )∧

¬∃x4 , y4 (x1 �= x4 ∨ y1 �= y4 ) ∧ (x2 �= x4 ∨ y2 �= y4 )∧

(x3 �= x4 ∨ y3 �= y4 ) ∧ MNeighbor (x, y , x4 , y4 )

Björklund (UmU)

AIM

AIM

21 november 2011

12 / 26



No constant names (except for numbers)



The unary relation names Row and Col



The binary relation names Square and Mine



The four-ary relation names Neighbor and MNeighbor



The two-ary function name Value

Björklund (UmU)

AIM

21 november 2011

13 / 26

Minesweeper

Minesweeper

Playing the game

Playing the game

To initialize a game on an n times m board, we simply have to give our KRS the following two assertions:

To initialize a game on an n times m board, we simply have to give our KRS the following two assertions:



MaxRow(n)



MaxRow(n)



MaxCol(m)



MaxCol(m)

Once we click on some squares, we gain informations and add more assertions, e.g.

Björklund (UmU)

AIM

21 november 2011



Value(1, 1) = 1



Value(2, 2) = 2

14 / 26

Björklund (UmU)

Minesweeper

AIM

21 november 2011

14 / 26

21 november 2011

15 / 26

Ontologies for Knowledge Representation

Playing the game

To initialize a game on an n times m board, we simply have to give our KRS the following two assertions: �

MaxRow(n)



MaxCol(m)

Ontologies

Once we click on some squares, we gain informations and add more assertions, e.g. �

Value(1, 1) = 1



Value(2, 2) = 2

Before the next move, we query the KRS for safe squares: �

? ∃x, y (¬Mine(x, y ))

Björklund (UmU)

AIM

21 november 2011

14 / 26

Björklund (UmU)

Ontologies for Knowledge Representation

AIM

Ontologies for Knowledge Representation

Specialized vs. general KRSs

What is an ontology?

As we have seen, we can handle things like arithmetic and minesweeping with rather small, specialized knowledge representation systems.

In philosophy, ontology is the study of that which is.

When do we need larger ones?



onto-: being, that which is



logia: science, study



Robotics



Natural language processing

In knowledge representation, an ontology is a systematic way of representing knowledge about the world.



Etc.

This means that there can be many different ontologies.

Björklund (UmU)

AIM

21 november 2011

16 / 26

Björklund (UmU)

AIM

21 november 2011

17 / 26

Ontologies for Knowledge Representation

Ontologies for Knowledge Representation

Biological ontologies

DAG ontologies

Classification of human beings: Kingdom: Phylum: Class: Order: Family Tribe: Genus: Species:

Most ontologies, however, are not pure trees.

Animalia Chordata Mammalia Primates Hominidae Hominini Homo Homo sapiens

Consider adding the category ”Things that walk on two legs” to a biological ontology. A human and a wolf are closer to each other in the biological ontology than either are to an ostrich, which - ironically - belongs to the class aves. Yet both humans and ostriches are ”Things that walk on two legs”, while wolfs are not.

The dominating feature of most ontologies is a hierarchical, tree-like structure.

Björklund (UmU)

AIM

21 november 2011

18 / 26

Björklund (UmU)

Ontologies for Knowledge Representation

AIM

21 november 2011

Ontologies for Knowledge Representation

Building a general purpose ontology

Categories

Challenges:

To be able to do any useful reasoning, we have to be able to reason about categories, rather than only about single objects.



Generalizations are, generally speaking, not absolute



A general ontology should be applicable to all special-purpose domains Different domains must be handled in a uniform way

� �

A general ontology is a social contract: it works only as long as people agree on it

Björklund (UmU)

19 / 26

AIM

21 november 2011

20 / 26

Compare the following: �

Fruit is healthy



Apples are healthy and oranges are healthy and bananas are healthy and peaches are healthy and ...



Healthy (Apple1 ) ∧ Healthy (Apple2 ) ∧ Healthy (Apple3 ) ∧ ...

Björklund (UmU)

Ontologies for Knowledge Representation

AIM

21 november 2011

21 / 26

Ontologies for Knowledge Representation

Categories

Reification Rather than treating all categories as relations (predicates) in FO, we can use an object for each category. Let Apples be constant name that refers to such an object.

Categories can be seen as sets � �

We can then use a membership relation to say that another object x belongs to the category Apples:

Each apple is a member of the category of all apples: Apple1 ∈ Apples All apples are fruits: Apples ⊂ Fruits

This makes it possible to state properties that are inherited by sub-categories � �

∀x (x ∈ Fruits ⇒ Healthy (x))

It follows that all apples are healthy.

Member (x, Apples) Which we abbreviate as: x ∈ Apples The benefit is that we will need fewer relations and fewer axioms.

Björklund (UmU)

AIM

21 november 2011

22 / 26

Björklund (UmU)

AIM

21 november 2011

23 / 26

Ontologies for Knowledge Representation

Ontologies for Knowledge Representation

Objects with objects as parts

Representing time

PartOf (CS, NT ) PartOf (NT , UmU) PartOf (CS, UmU)

The starting point we choose and the unit we measure in are arbitrary: any choice will do. The objects we work with are intervals. These objects belong to the category Intervals.

The PartOf relation is transitive and reflexive. Notice that this is neither the same as the subset relation nor the Member relation. � � �

The subset relation relates two categories: Apples ⊂ Fruits

The Member relation relates an object and a category: Apple1 ∈ Apples

The PartOf relation relate two objects: PartOf (MyLeftHand, MyLeftArm).

Björklund (UmU)

AIM

21 november 2011

24 / 26

Ontologies for Knowledge Representation

Time interval relations [Allen, 1983]

Meet(i, j) Before(i, j) Overlap(i, j) After (i, j) During(i, j) Begins(i, j) Finishes(i, j) Equals(i, j)

Björklund (UmU)

⇔ End(i) = Begin(j) ⇔ End(i) < Begin(j)

⇔ Begin(i) < Begin(j) < End(i) < End(j) ⇔ Before(j, i)

⇔ Begin(j) < Begin(i) < End(i) < End(j) ⇔ Begin(i) = Begin(j) ⇔ End(i) = End(j)

⇔ Begin(i) = Begin(j) ∧ End(i) = End(j)

AIM

21 november 2011

26 / 26



The Begin funktion gives the moment when an interval begins



The End funktion gives the moment when an interval ends



The Time function maps moments to our time scale

Björklund (UmU)

AIM

21 november 2011

25 / 26

Suggest Documents