Racket 使用AND、NOT和>;进行逻辑编程时,如何获得最高值;

Racket 使用AND、NOT和>;进行逻辑编程时,如何获得最高值;,racket,logic-programming,Racket,Logic Programming,这是关于计算机程序的结构和解释的逻辑编程 这是一个理解如何获得最高价值的简单问题 这是一个示例数据库: ((is-student Anna) (is-student Bart) (is-student Charlie) (is-student David) (is-student Eddy) (is-student Fanny) (has-points Anna 73) (has-points Bart 84) (has-points Charlie 65) (has-p

这是关于计算机程序的结构和解释的逻辑编程

这是一个理解如何获得最高价值的简单问题

这是一个示例数据库:

((is-student Anna)
(is-student  Bart)
(is-student  Charlie)
(is-student  David)
(is-student  Eddy)
(is-student  Fanny)

(has-points Anna    73)
(has-points Bart    84)
(has-points Charlie 65)
(has-points David   34)
(has-points Eddy    85)
(has-points Fanny   70))
我理解以下代码是对学生及其观点的总结:

;;; Query input:
(and (is-student ?student1)
       (has-points ?student1 ?points1))

;;; Query results:
(and (is-student fanny) (has-points fanny 70))
(and (is-student eddy) (has-points eddy 85))
(and (is-student david) (has-points david 34))
(and (is-student charlie) (has-points charlie 65))
(and (is-student bart) (has-points bart 84))
(and (is-student anna) (has-points anna 73))
与和&或的组合也一样,可以理解。它主要是计算出组合并过滤出结果

我很难理解下面的代码,从而让学生获得最高分数。它看起来很简单,但我不明白与&不&“>points2 points1”的组合如何提供最大的值(点)

这是我运行它(在DrRacket中)以使学生获得最高分数时得到的结果:

;;; Query input:
(and (is-student ?student1)
       (has-points ?student1 ?points1)
       (not (and (is-student ?student2)
                 (has-points ?student2 ?points2)
                 (lisp-value > ?points2 ?points1))))

;;; Query results:
(and (is-student eddy) 
     (has-points eddy 85) 
     (not (and (is-student ?student2) 
               (has-points ?student2 ?points2) 
               (lisp-value > ?points2 85))))
将第二个列表的否定与第一个列表的否定进行比较,效果如何? 是否将第一个结果的每一行答案与第二个和第二个结果的每一行进行比较? 我不知道如何阅读/解释代码,以及为什么这会给出我们正在搜索的内容

任何有助于理解这如何提供最高价值的帮助都将不胜感激

谢谢


附言:我不是以英语为母语的人,对于任何语法或拼写错误,我深表歉意。

在我看来,我可以对此做出解释:我有一个学生1有一个点1和一个点2存在一种情况,即有一个学生2有一个点2并且点2大于点1。 粗体的与代码完全匹配。
希望这能对您有所帮助,我也不是以英语为母语的人:)

谢谢YoarkYANG!,我好像忘了谢谢你!抱歉耽搁了!