I'm interested in generating random logically consistent chains of natural language sentences. I don't know anything about computational linguistics. I'm wondering if there are software packages or projects that I can use for this.

The sentences don't have to be factually correct, just logically consistent. Here is an example:

All apples are blue. This is an apple. Therefore it is blue. Cars eat blue animals. Apples are animals. Therefore, cars eat apples.

  • Do you strictly want to get syllogisms, or more generally coherent texts? Mar 2, 2023 at 9:30
  • 1
    And you need at least an operational definition of "logically consistent" that deals with semantics as well as logic. Logical consistence simply means having legal truth tables for propositions; the variables are irrelevant.
    – jlawler
    Mar 2, 2023 at 17:38
  • @phipsgabler Either one could be a good start.
    – Sia Rezaei
    Mar 7, 2023 at 1:04
  • @jlawler My definition of "logically consistent" is for all the assertion in a passage and the deductions that follow from them not to be in contradiction with each other. Are you aware of any software/database that could help with this?
    – Sia Rezaei
    Mar 7, 2023 at 1:04
  • ChatGPn can do it for you, but it won't be correct. Does that matter?
    – jlawler
    Apr 1, 2023 at 17:05

1 Answer 1


I don't think there is anything preexisting that does this (correctly), but let's focus on the linguistic issues rather than inference problems. From just the three sentences {All apples are blue. This is an apple. Therefore it is blue}, you can linguistically compute that there is no contradiction in the set. You might reach the same result from the set {All apples are blue. This is an apple. Therefore it is expensive}, depending on how you set up the semantic rule for "therefore". We ordinarily do not say that the conclusion contradicts the premises, we say that they do not necessarily follow from the premises – it is 'logically possible' that the apple is expensive, or that it is not expensive. This reflects a formal logic convention regarding "therefore". In ordinary language, "therefore" doesn't mean the same thing as it does in formal syllogisms. Let's therefore adopt a restricted definition of "therefore" for this exercise – it means "is necessarily true that".

In processing the triple {All apples are blue. This is an apple. Therefore it is red}, we require further information about the words "red" and "blue", roughly and incorrectly that no thing can be red and blue (well, what about the flags of the US or Norway?). You might be thinking that we just need another rule to the effect that when you predicate a color of a thing, that means that the thing is entirely that color unless you add something like "mostly". But that is clearly not the case, since even red apples are not entirely red.

Taken in isolation, the triple {Cars eat blue animals. Apples are animals. Therefore, cars eat apples} is false (under the stipulation about "therefore"). There is no warrant for the premise that apples are blue, so it doesn't follow. You put this after a triple that introduces the premise that apples are blue – so the system has to be sensitive not just to the particular triple, but to all premises and conclusions within the whole set. You presumably also would infer the singular conclusion that "cars eat this apple".

In this subset of language, the linguistic aspect is devising a lexical database that says what properties are entailed by particular words. It turns out that "eat", "blue", "car", "animal" and "apple" have no lexical properties, they are just variables a, b, c, d, e. There seems to be some necessary lexical meaning to "all", "therefore", "are", "an", "this" etc. which is crucial for concluding that certain triples are "logically inconsistent" (or, that they are possible rather than necessary). I guess nouns, verbs and adjectives are all variables with no build-in meaning, and articles, conjunctions, and quantifiers have built-in meaning. Then you would start by building up a collection of non-contradictory triples, as you have tried to do. With every new triple that you introduce, you run the risk of contradiction, but you expand total knowledge.

The linguistic problem with this is that nouns, verbs and adjectives are not empty variables, they do have meaning. There is a fair amount of linguo-philosophical literature on the analytic-synthetic dichotomy which touches on lexical meaning. Statements like "All bachelors are unmarried" or "All bodies occupy space" may or may not be linguistically necessary in isolation, depending on your viewpoint on the matter. There is a difference of opinion as to whether "All bodies experience a gravitational force" is necessarily true – the inventor of this concept thought that "occupying space" and "experience a gravitational force" are fundamentally different. Honestly, I have no idea how contemporary linguists view the ASD, so this may or may not be a linguistic issue – my view is that it is a question of where knowledge comes from, and not a matter of word meaning.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.