灯下 登录
计算机科学 / SICP / 4.4.1 Deductive Information Retrieval

Exercise 4.59 · 习题

Exercise 4.59: Ben Bitdiddle has missed one
meeting too many. Fearing that his habit of forgetting meetings could cost him
his job, Ben decides to do something about it. He adds all the weekly meetings
of the firm to the Microshaft data base by asserting the following:

(meeting accounting (Monday 9am))
(meeting administration (Monday 10am))
(meeting computer (Wednesday 3pm))
(meeting administration (Friday 1pm))

Each of the above assertions is for a meeting of an entire division. Ben also
adds an entry for the company-wide meeting that spans all the divisions. All
of the company’s employees attend this meeting.

(meeting whole-company (Wednesday 4pm))

On Friday morning, Ben wants to query the data base for all the meetings that
occur that day. What query should he use?

Alyssa P. Hacker is unimpressed. She thinks it would be much more useful to be
able to ask for her meetings by specifying her name. So she designs a rule
that says that a person’s meetings include all whole-company meetings
plus all meetings of that person’s division. Fill in the body of Alyssa’s
rule.

(rule (meeting-time ?person ?day-and-time)
⟨rule-body⟩)

Alyssa arrives at work on Wednesday morning and wonders what meetings she has

to attend that day. Having defined the above rule, what query should she make

to find this out?

练习 4.59:Ben Bitdiddle 已经错过了太多次会议。担心自己忘记会议的习惯会让他丢掉工作,Ben 决定采取行动。他将公司所有每周例会加入 Microshaft 数据库,断言如下:

(meeting accounting (Monday 9am))
(meeting administration (Monday 10am))
(meeting computer (Wednesday 3pm))
(meeting administration (Friday 1pm))

以上每条断言都是某个部门的例会。Ben 还为全公司范围的会议添加了一条记录,公司所有员工都要参加该会议。

(meeting whole-company (Wednesday 4pm))

周五上午,Ben 想查询数据库,找出当天举行的所有会议。他应使用什么查询?

Alyssa P. Hacker 对此不以为然。她认为能按姓名查询自己的会议会更有用。为此,她设计了一条规则:一个人的会议包括所有全公司会议以及该人所在部门的所有会议。请填写 Alyssa 规则的体。

(rule (meeting-time ?person ?day-and-time)
⟨rule-body⟩)

Alyssa 周三早上来到公司,想知道当天有哪些会议要参加。在定义了上述规则之后,她应该如何查询才能得到答案?

Racket #lang sicp
(meeting accounting (Monday 9am))
(meeting administration (Monday 10am))
(meeting computer (Wednesday 3pm))
(meeting administration (Friday 1pm))
Racket #lang sicp
(meeting whole-company (Wednesday 4pm))