Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
39 lines (29 sloc) 1.77 KB
(rule (wheel ?person)
  (and (supervisor ?middle-manager ?person)
       (supervisor ?x ?middle-manager)))

(wheel ?who)

(wheel (Warbucks Oliver))
(wheel (Bitdiddle Ben))
(wheel (Warbucks Oliver))
(wheel (Warbucks Oliver))
(wheel (Warbucks Oliver))

(wheel ?who)应用过程如下:

  • (wheel ?who)使用框架f0: []匹配规则结论(wheel ?person),产生一个新的框架 f1: [?person ?who]

  • 规则体用框架f1: [?person ?who]求值,and的第一部分(supervisor ?middle-manager ?who)使用f1求值后,生产一个新的框架f2,包含下面8个绑定:

    • [?middle-manager : (Aull DeWitt) ?who : (Warbucks Oliver)]
    • [?middle-manager : (Cratchet Robert) ?who : (Scrooge Eben)]
    • [?middle-manager : (Scrooge Eben) ?who : (Warbucks Oliver)]
    • [?middle-manager : (Bitdiddle Ben) ?who : (Warbucks Oliver)]
    • [?middle-manager : (Reasoner Louis) ?who : (Hacker Alyssa P)]
    • [?middle-manager : (Tweakit Lem E) ?who : (Bitdiddle Ben)]
    • [?middle-manager : (Fect Cy D) ?who : (Bitdiddle Ben)]
    • [?middle-manager : (Hacker Alyssa P) ?who : (Bitdiddle Ben)]
  • and的第二部分(supervisor ?x ?middle-manager)使用框架f2求值后生成一个新的框架f3,包含下面5个绑定:

    • [?x : (Cratchet Robert) ?middle-manager : (Scrooge Eben)] ?who : (Warbucks Oliver)
    • [?x : (Tweakit Lem E) ?middle-manager : (Bitdiddle Ben)] ?who : (Warbucks Oliver)
    • [?x : (Fect Cy D) ?middle-manager : (Bitdiddle Ben)] ?who : (Warbucks Oliver)
    • [?x : (Hacker Alyssa P) ?middle-manager : (Bitdiddle Ben)] ?who : (Warbucks Oliver)
    • [?x : (Reasoner Louis) ?middle-manager : (Hacker Alyssa P)] ?who : (Bitdiddle Ben)

查询最终生成5个结果,所以有5条记录出现在最终结果里面。