Stanford University's "Introduction to Logic" --------------------------------------------- Problem 1.4 Deduction: six syllogisms are presented; the instructions are: "In each question, decide whether the inference given is correct deduction." I used the files at subbot.org/intrologic/golfers to answer the questions: $ ruby logicbot.rb Hello >> load graph golfers.yaml golfers.yaml loaded. >> print graph golfers = all golfers golfers = golfers all farmers = farmers all golfers = golfers farmers = all farmers farmers = farmers -------------------------------------------------------------------------- Question 1: -------------------------------------------------------------------------- >> All farmers are golfers. >> All golfers play tennis. >> Therefore, all farmers play tennis. Yes, all farmers are tennis players. >> why are all farmers tennis players? all farmers are tennis players because: all farmers = golfers, and golfers = all golfers, and all golfers = tennis players -------------------------------------------------------------------------- Question 2: -------------------------------------------------------------------------- >> load graph golfers.yaml >> Some farmers are golfers. >> All golfers play tennis. >> Therefore, all farmers play tennis. I have no knowledge that all farmers are tennis players. -------------------------------------------------------------------------- Question 3: -------------------------------------------------------------------------- >> load graph golfers.yaml >> Some farmers are golfers. >> All golfers play tennis. >> Therefore, some farmers play tennis. Yes, some farmers are tennis players. >> why are some farmers tennis players. some farmers are tennis players because: some farmers are golfers, and golfers = all golfers, and all golfers = tennis players -------------------------------------------------------------------------- Question 4: -------------------------------------------------------------------------- >> load graph golfers.yaml >> All farmers are golfers. >> Some golfers play tennis. >> Therefore, all farmers play tennis. I have no knowledge that all farmers are tennis players. -------------------------------------------------------------------------- Question 5: -------------------------------------------------------------------------- >> load graph golfers.yaml >> All farmers are golfers. >> Some golfers play tennis. >> Therefore, some farmers play tennis. I have no knowledge that some farmers are tennis players. -------------------------------------------------------------------------- Question 6: -------------------------------------------------------------------------- >> load graph golfers.yaml >> Some farmers are golfers. >> Some golfers play tennis. >> Therefore, some farmers play tennis. I have no knowledge that some farmers are tennis players. >> --- Note: I included some necessary axioms in golfers.yaml; these propositions (such as "all golfers include golfers") are inferences that are hidden in the natural language representation of the questions. I have modeled the "includes" relation as an equivalence relation, which works for these problems; however, I should make it not symmetric, so that "all golfers >= golfers" instead of "all golfers = golfers". Also note that I included a rule to transform "play tennis" into "are tennis players". This rule has been hard-coded into the logicbot.rb file at http://subbot.org/intrologic/golfers/logicbot.txt I can also submit the rule at runtime, while interacting with the program: >> logicbot: if input =~ /(.*) (?:plays|play) tennis/i then response, s = self.send("#{$1} are tennis players") end Okay [...] --- I need the above rule to transform the "play tennis" relation into an "are tennis players" relation. Turning the verb "play" into the verb "are" makes the graph simpler, so that the path-finding algorithm can use existing code that works with the "is" (or "are") relation. Another possible solution is to make it easy to add new relations, such as "play/plays", in such a way that the program could easily parse sentences containing them and store them in the graph, so that the path-finding algorithm could operate on them. (I'm exploring such a solution, with the "generic_a_r_b()" functions; see http://subbot.org/logicagent/dialogs/johnny.html for example.)