Syllogisms
For two thousand years logic meant the syllogism: two premises and a conclusion, each saying how two classes are related. Here validity is not looked up in a list. It is decided, by checking every way of filling in a Venn diagram, and the traditional names and rules are reported beside the answer.
Four forms of statement
| Form | Statement | On the Venn diagram |
|---|---|---|
| A | All S are P | S outside P is empty |
| E | No S are P | S inside P is empty |
| I | Some S are P | S inside P has something in it |
| O | Some S are not P | S outside P has something in it |
import { categorical, categoricalText } from "@ratmath/logic";
categorical("No reptiles are mammals"); // { form: "E", subject: "reptiles", predicate: "mammals" }
categoricalText({ form: "O", subject: "birds", predicate: "fliers" }); // "Some birds are not fliers"
Mood and figure
A syllogism has three terms: the minor term S (the subject of the conclusion), the major term P (its predicate), and the middle term M, which appears in both premises and not in the conclusion. The major premise, written first, contains P. The mood is the three forms in order, and the figure (1 to 4) says where M stands:
| Figure | Major premise | Minor premise |
|---|---|---|
| 1 | M – P | S – M |
| 2 | P – M | S – M |
| 3 | M – P | M – S |
| 4 | P – M | M – S |
So there are syllogisms. Give one in words, or by mood and figure:
import { syllogism } from "@ratmath/logic";
const s = syllogism("All men are mortal", "All Greeks are men", "All Greeks are mortal");
s.valid, s.form, s.name; // true, "AAA-1", "Barbara"
s.terms; // { S: "Greeks", M: "men", P: "mortal" }
s.venn.shaded; // ["¬SM¬P", "S¬M¬P", "S¬MP", "SM¬P"]: the regions forced empty
syllogism("EIO-2", { S: "poets", M: "rich", P: "happy" }).statements;
// ["No happy are rich", "Some poets are rich", "Some poets are not happy"]
Deciding validity
The three circles of a Venn diagram make eight regions. A statement says some regions are empty, or that some region among a few has something in it. Each of the choices of which regions have something in them either makes the premises true or not; the syllogism is valid when every choice that makes the premises true makes the conclusion true. If one does not, it is a counterexample, and the fewest occupied regions are reported.
const bad = syllogism("All dogs are animals", "All cats are animals", "All cats are dogs");
bad.valid; // false
bad.counterexample; // ["SM¬P"]: a cat that is an animal and not a dog
bad.rules.filter((r) => r.broken).map((r) => r.rule);
// ["the middle term is distributed at least once"]
The tests build actual sets from each counterexample, one element per occupied region, and check that the premises come out true and the conclusion false, for every invalid syllogism.
Existential import
Aristotle took every term to have members, so "All S are P" carried "Some S are P" with it. Modern logic does not: "All unicorns have horns" is true because there are no unicorns. The modern reading has 15 valid syllogisms; with existential import, nine more become valid, each with its own name.
syllogism("AAI-3").valid; // false: "All M are P, All M are S, so Some S are P"
syllogism("AAI-3").counterexample; // []: everything empty
syllogism("AAI-3", { existentialImport: true }).name; // "Darapti"
validSyllogisms().map((x) => x.name).join(", ");
// "Barbara, Camestres, Calemes, Darii, Datisi, Baroco, Celarent, Cesare,
// Ferio, Festino, Ferison, Fresison, Disamis, Dimatis, Bocardo"
The traditional rules
Medieval logicians gave rules that a valid syllogism keeps. A term is distributed when the statement says something about all of it: the subject of A and E, the predicate of E and O.
- The middle term is distributed at least once.
- A term distributed in the conclusion is distributed in its premise (otherwise "illicit major" or "illicit minor").
- Not both premises are negative.
- A negative premise needs a negative conclusion, and a negative conclusion needs a negative premise.
- On the modern reading, two universal premises do not give a particular conclusion.
Each result lists the rules and which are broken. A syllogism is valid exactly when it breaks none, which the tests check against the Venn decision on all 256.
Reference
| Export | What it does |
|---|---|
categorical(text | { form, subject, predicate }) | A statement in one of the four forms. |
categoricalText(statement) | The statement in words. |
syllogism(major, minor, conclusion, { existentialImport }) | Decide a syllogism given in words or as objects. |
syllogism("AAA-1", { existentialImport, S, M, P }) | Decide by mood and figure, with names for the terms if you like. |
result | valid, mood, figure, form, name, terms, statements, counterexample (occupied regions), venn (shaded, marked), rules. |
validSyllogisms({ existentialImport }) | Every valid mood and figure with its name: 15, or 24 with existential import. |
@ratmath/logic and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.