Prolog sword(Lancelot) sword(Arthur) shield(Lancelot) - - PowerPoint PPT Presentation

prolog
SMART_READER_LITE
LIVE PREVIEW

Prolog sword(Lancelot) sword(Arthur) shield(Lancelot) - - PowerPoint PPT Presentation

Prolog sword(Lancelot) sword(Arthur) shield(Lancelot) shield(Arthur) crown(Arthur) king(X) :- sword(X), shield(X), crown(X) ?- king(X) Prolog ?- king(X) Prolog ?- king(X) X = Z ?- sword(Z), shield(Z),


slide-1
SLIDE 1

Prolog

  • sword(Lancelot)
  • sword(Arthur)
  • shield(Lancelot)
  • shield(Arthur)
  • crown(Arthur)
  • king(X) :- sword(X), shield(X), crown(X)
  • ?- king(X)
slide-2
SLIDE 2

Prolog

?- king(X)

slide-3
SLIDE 3

Prolog

?- king(X) ?- sword(Z), shield(Z), crown(Z) X = Z

slide-4
SLIDE 4

Prolog

?- king(X) ?- sword(Z), shield(Z), crown(Z) X = Z Z = Lancelot ?- shield(Lancelot), crown(Lancelot)

slide-5
SLIDE 5

Prolog

?- king(X) ?- sword(Z), shield(Z), crown(Z) X = Z Z = Lancelot ?- shield(Lancelot), crown(Lancelot) ?- crown(Lancelot)

slide-6
SLIDE 6

Prolog

?- king(X) X = Z Z = Lancelot ?- shield(Lancelot), crown(Lancelot) ?- crown(Lancelot) ?- shield(Arthur), crown(Arthur) ?- sword(Z), shield(Z), crown(Z) Z = Arthur

slide-7
SLIDE 7

Prolog

?- king(X) X = Z Z = Lancelot ?- shield(Lancelot), crown(Lancelot) ?- crown(Lancelot) ?- shield(Arthur), crown(Arthur) ?- sword(Z), shield(Z), crown(Z) Z = Arthur ?- crown(Arthur)

slide-8
SLIDE 8

Prolog

king(X) X = Z Z = Lancelot shield(Lancelot), crown(Lancelot) crown(Lancelot) shield(Arthur), crown(Arthur) sword(Z), shield(Z), crown(Z) Z = Arthur crown(Arthur)

slide-9
SLIDE 9

But how much does a duck weigh?

slide-10
SLIDE 10

May we burn her?

  • witch(X):-burns(X),female(X).
  • burns(X):-wooden(X).
  • wooden(X):-floats(X).
  • floats(X):-sameweight(duck, X).
  • female(suspect1).
  • female(suspect2).
  • sameweight(duck,suspect1).