1

I am working on a software project that allows users to formulate logical statements in order to filter data. E. g. a user might set their filter as: (size = 100 and weight < 50) or (area > 200 and weight < 100) or color = blue which would roughly translate to Filter for all objects with a size equal to 100 and a weight less than 50 - or an area larger than 200 and a weight less than 100 - or simply any blue object.

Is there a way to make nested conjunctions and parenthesis easy to read? Is there a general way to do this? I am looking for rules to convert the logical statement to natural language.

  • 5
    This is an old problem, and is part of the reason why logical notations such as propositional calculus were invented. If you want to be unambiguous, you're far better to use formulae; tables (e.g. logic tables); diagrams (Venn diagrams, decision trees, flow charts, etc); or other solutions; and not written descriptions. – Stuart F Oct 12 '21 at 12:35
  • You might end up reinventing COBOL, which probably isn't what you want. – user888379 Oct 12 '21 at 15:41
  • It's not really about converting natural language to a logical statement, rather about representing a logical statement as a simple text so that users can check if it's actually doing what they want it to do – Moritz_st Oct 12 '21 at 16:18
  • Right. It's important to be able to read off logical formulas so they sound like English, because that's usually what they mean. – John Lawler Oct 12 '21 at 16:45
  • To @StuartF's point, though, you bump into things like "is 'or' inclusive or exclusive?" – user888379 Oct 12 '21 at 17:29
  • 1
    To put Stuart F's point more bluntly, the answer is no, there is no way of doing this that is, at the same time (1) as unambigous as the original, and (2) natural-sounding and easy to read. As long as the matter is somewhat complex, some compromise between (1) and (2) will be needed. In legal materials that is usually done by creating lists (possibly nested) of numbered items: that makes it possible to accomplish (1), and also to accomplish (2) within each item, but sacrifices (2) for the list as a whole. – jsw29 Oct 12 '21 at 20:49
  • @StuartF That is good advice. Logical calculus notation is, if anything, harder to 'read' than maths notation. And you can't avoid nests. There is a panoply of symbols available: '&' for 'and';!~' for 'not'; 'v' for inclusive 'or' (Latin 'vel'); inverted 'v' for exclusive 'or' (Latin 'Aut') ... But who will be willing to learn propositional calculus? – Tuffy Oct 13 '21 at 00:23

0 Answers0