prolog
play

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),


  1. Prolog • sword(Lancelot) • sword(Arthur) • shield(Lancelot) • shield(Arthur) • crown(Arthur) • king(X) :- sword(X), shield(X), crown(X) • ?- king(X)

  2. Prolog ?- king(X)

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

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

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

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

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

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

  9. But how much does a duck weigh?

  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).

Recommend


More recommend