这是另一个答案的注释。我的大脑很痛,所以我尝试了之前发布的简洁而完整的答案,它奏效了。但这只是“给男人一条鱼”,所以我必须看看背后是什么。
然后是 ChrisChen3121 的 2014 年 1 月 22 日解决方案,仅对括号、注释和换行符进行了更改。大多数括号与它们的匹配垂直排列。希望这能让事情变得容易看到。在美学上重新编写的代码之后,会产生中间关系以尝试将解决方案可视化/概念化。
长话短说:
--查找目标比萨饼;
--使用\cross,建立一个幻想超集列表,就好像所有的比萨店都提供所说的馅饼一样;
--从那里减去所有“实际供应”的馅饼以创建“这些缺失”列表;
——最后,从“现实”的[新副本]中,减去“缺失的”,然后……就是这样。
\project_{pizzeria}(Serves)// “Actual” list of what pizzerias serve. Results shown below.
\diff
\project_{pizzeria}
(// After the diff, this is a list of "What's Missing". Results shown below
(// Super-set of all pizzerias combined with all "over30pies". Results shown below
// NOTE: Some combos here do not match reality
\project_{pizzeria}(Serves)
\cross
(// "over30pies": Within these parentheses produces table shown below
//Next line is what I used, it’s effectively equivalent, yes.
//roject_{pizza} ( \select_{age > 30 } Person \join Eats)
\project_{pizza} (\project_{name}(\select_{age > 30 } (Person))\join Eats)
)
)
\diff
( // “Actual” list of what pizzerias serve. Results shown below.
\project_{pizzeria,pizza}(Serves)
)
)
// “over30pies”,目标馅饼(30 岁以上的人吃的)
cheese
supreme
// 所有比萨店的超级集与所有目标(“over30pies”)相结合 // 注意:一些组合与现实不符。
Chicago Pizza | cheese
Chicago Pizza | supreme
Dominos | cheese
Dominos | supreme
Little Caesars | cheese
Little Caesars | supreme
New York Pizza | cheese
New York Pizza | supreme
Pizza Hut | cheese
Pizza Hut | supreme
Straw Hat | cheese
Straw Hat | supreme
// 实际的,哪些比萨店实际提供什么服务的完整列表
Chicago Pizza | cheese
Chicago Pizza | supreme
Dominos | cheese
Dominos | mushroom
Little Caesars | cheese
Little Caesars | mushroom
Little Caesars | pepperoni
Little Caesars | sausage
New York Pizza | cheese
New York Pizza | pepperoni
New York Pizza | supreme
Pizza Hut | cheese
Pizza Hut | pepperoni
Pizza Hut | sausage
Pizza Hut | supreme
Straw Hat | cheese
Straw Hat | pepperoni
Straw Hat | sausage
//从幻想的“超集”中减去“实际”后的差异(剩下的)。然后,这表示缺少什么或“<em>这些比萨店不提供列出的所需比萨”
Dominos | supreme
Little Caesars | supreme
Straw Hat | supreme