first-order logic and plans reading: c. 11 (plans)

32
First-Order Logic and Plans Reading: C. 11 (Plans)

Upload: bernard-griffith

Post on 03-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

First-Order Logic and Plans

Reading: C. 11 (Plans)

2

Grades Handed back at end of class. Midterms will

only be given to owners

All of your grades are online in the Courseworks gradebook. You can check.

Class participation grade• Represents your effort to date• For remainder of semester, I will use class list to call on

people, particularly those who are less vocal. This will give everyone a chance. Of course, you must be present to take advantage of your turn.

3

Tournament Start date: Tuesday, Nov.16th

You must sign up by Nov. 11th, midnight to participate. It’s optional.

2 person games only 1 minute time limitation per move Passing to second round:

• Each program will play two times against every other program, as first and as second player

• Top 50% will move on to second round Number of rounds will be determined in part by number of

entrants If you decide to enter, you must include a script to run your

program with proper parameters You determine search depth that you will play at

4

Extra Credit

5 points for entering and finishing without faults• No crashes

• < 50% timeouts

5 points for moving to round 2 10 points for moving to round 3 (or top 50% of

round 2) 10 points for top 4 10 points for #1 finish

5

Example

Family trees

What does the model look like?• Father-of

• Mother-of

• Sibling

What can we infer?• Cousin

• Ancestors

6

To Make Inferences in FOL

Method 1• Unification of variables with literals (in the KB)

• Generalized Modus Ponens

• Forward-chaining or Backward-chaining

Method 2• Resolution

7

Unification

We want to find a substitution such that x and y match literals

Unify (,) = if = Some examples

8

Unification for example

9

P`1= father-of(Kathy)=Michael

P1= father-of(x)=y

={x/Kathy,y/Michael}

q=ancestor(x,y)

q`=ancestor(Kathy,Michael)

10

11

Example inference using forward chaining (production systems)

12

Properties of forward-chaining

Sound and complete for first-order definite clauses

Datalog is first-order definite clauses and no functions

May not terminate in general if is not entailed This is unavoidable: entailment with definite

clauses is semi-decidable Forward chaining is widely used in deductive

databases

13

14

Example inference using backward chaining

15

Properties of backward-chaining

Depth-first recursive proof search: space is linear in size of proof

Incomplete due to infinite loops• Fix by checking current goal against every goal on stack

Inefficient due to repeated subgoals (both success and failure)

• Fix using cache of previous results (extra space!)

Widely used (without improvements!) for logic programming (e.g., Prolog)

16

Refutation and generalized resolution

Inference with generalized modus ponens is not complete for FOL

Proof by refutation and generalized resolution is complete

• But slow and only semi-decidable (cannot know that a sentence is not entailed)

17

Refutation/Resolution

Introduce negated sentence Convert to a CNF (disjunction of terms, or

“literals”) Apply resolution search to determine

satisfiability (SAT) or unsatsifiability (UNSAT) SAT, then not entailed

• Semi-decidability implies there may be a SAT solution we can never find

UNSAT, then entailed

18

Conversion to CNF

1. Eliminate using ⌐ and V

2. Push ⌐ inward using de Morgan’s laws

3. Standardize variables apart

4. Eliminate using Skolem functions

5. Move to front, and drop

6. Distribute Λ over V to get CNF

7. Split into separate clauses (remove Λ)

8. Standardize variables apart (across clauses)

19

20

Example using Resolution

21

Planning

An approach to problem solving that combines logic with search

Cognitively motivated?

Suited for more complex problems

22

Problem solving so far

Typical • Problem -> language -> representation + algorithm

-> solution

For example, recall the 8-puzzle• Choose a representation

• Choose a heuristic

• Choose a search algorithm

23

General Problem solving

Ideally, we would like to describe a problem at a high level, let AI take care of the rest

Problem -> representation -> solutions general general language algorithm

24

Required Planning Components

Expressive Formal Language:• Initial state of world

• Description of the agent’s goal

• Description of the possible actions that can be performed

Solver generates a sequence of actions which achieve the goal

• Key idea will be to use structure to extract admissable heuristics automatically

25

STRIPS language(Fikes&Nilsson 71)

State is a conjunction of positive ground literals• No variables and no functions

• AT(,Kathy,Gate70), Weight-limit-lifted(CO36)

Goal is a conjunction of positive ground literals• At(Kathy,Denver)Λ⌐onboard(Kathy,C036)

Action schemas• Conjunction of positive literals as preconditions

• Conjunction of positive and negative literals as effects

26

Action Schema

Action: Go(p,x,y) Precond: At(P,x) Effect: ⌐At(p,x) At(p,y)

delete list add list

27

Comments: STRIPS

Closed World assumption• Unmentioned literals are false (no need to

explicitly list out)

• w/an open world assumption unmentioned literals are unknown

STRIPS assumption• Every literal not mentioned in the “effect” of an

action schema remains unchanged

28

Travel Example

29

STRIPS Expressiveness Literals are function free: Any action scheme can be

propositionalized• E.g., 10 planes, 5 airports, then Fly(p,from,to) can be

expressed as 250 purely propositional actions Cannot address the ramifications of an action

• The people, packages, wine, etc. on an airplane also change location when the plane flies

Cannot express disjunctive goals• At(Kathy,Denver)ΛDay(Friday) V

At(Kathy,Denver)ΛDay(Saturday) No conditional effects

• No way to say “At(Kathy,Denver)” an effect of Fly(Kathy,Co36,Denver) only if ⌐crash(CO36)

30

Planning Algorithms

Forward vs. Backward search Partial-order vs. Total-order

• Partial: search in plan space• Can work on several subgoals independently,

solve and then combine subplans

• Total: search in state space• Search linear sequence of actions directly

connected to the start or the goal

31

32

Forward State Space Search

State: positive ground literals Initial state: set of initial world literals Search operator: Choose an action A that

• 1.preconditions are satisfied (perhaps finding a unifier)

• Construct the new search state

• Add all positive effects; remove all negative effects

Solution: when current state is goal state