Created
February 4, 2026 22:06
-
-
Save mscuthbert/c8c8889ea0bb10fd3a3b50027237add4 to your computer and use it in GitHub Desktop.
Generate all 256 Syllogism forms, whether correct or incorrect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ###################### | |
| # syllogisms.py -- generate all possible syllogisms, | |
| # whether valid or not | |
| # | |
| # Output is at: | |
| # https://prolatio.blogspot.com/2016/08/all-256-syllogism-forms-with-examples.html | |
| # | |
| # Copyright 2015, Michael Scott Cuthbert (cuthbert@post.harvard.edu) | |
| # Released freely under a BSD license. | |
| # Cleaned up 2026 Feb. and remove Py2 compatibility layers | |
| ######################## | |
| import random | |
| # change these to make your own funny versions... | |
| sylloExamples = [ | |
| # Subject, Middle, Predicate | |
| ('men', 'women', 'humans'), | |
| ('people', 'animals', 'rational beings'), | |
| ('stools', 'chairs', 'furniture'), | |
| ('spiders', 'insects', 'animals'), | |
| ('musicians', 'musicologists', 'scholars'), | |
| ('rabbits', 'pets', 'furry beasts'), | |
| ('flowers', 'plants', 'fungi'), | |
| ('tacos', 'delicious foods', 'platos') | |
| ] | |
| wordType = {'S': 'subject', | |
| 'M': 'middle', | |
| 'P': 'predicate'} | |
| class Figure: | |
| def __init__(self, type=1): | |
| self.figureType = type | |
| if type == 1: | |
| self.major = ['M', 'P'] | |
| self.minor = ['S', 'M'] | |
| elif type == 2: | |
| self.major = ['P', 'M'] | |
| self.minor = ['S', 'M'] | |
| elif type == 3: | |
| self.major = ['M', 'P'] | |
| self.minor = ['M', 'S'] | |
| elif type == 4: | |
| self.major = ['P', 'M'] | |
| self.minor = ['M', 'S'] | |
| self.conclusion = ['S', 'P'] | |
| class Mood: | |
| linkMapping = {'a': 'all ', | |
| 'e': 'no ', | |
| 'i': 'some ', | |
| 'o': 'some '} | |
| postVerbLink = {'a': '', | |
| 'e': '', | |
| 'i': '', | |
| 'o': 'not '} | |
| def __init__(self, links): | |
| self.links = links | |
| self.majorLink = links[0] | |
| self.minorLink = links[1] | |
| self.conclusionLink = links[2] | |
| logical = { | |
| '1aaa': 'barbara', | |
| '1eae': 'celarent', | |
| '1aii': 'darii', | |
| '1eio': 'ferio', | |
| '1aai': 'barbari', | |
| '1eao': 'celaront', | |
| '2eae': 'cesare', | |
| '2aee': 'camestres', | |
| '2eio': 'festino', | |
| '2aoo': 'baroco', | |
| '2eao': 'cesaro', | |
| '2aeo': 'camestros', | |
| '3aii': 'datisi', | |
| '3iai': 'disamis', | |
| '3eio': 'ferison', | |
| '3oao': 'bocardo', | |
| '3eao': 'felapton', | |
| '3aai': 'darapti', | |
| '4aee': 'calemes', | |
| '4iai': 'dimatis', | |
| '4eio': 'fresison', | |
| '4aeo': 'calemos', | |
| '4eao': 'fesapo', | |
| '4aai': 'bamalip', | |
| } | |
| # existential fallacy -- requires at least one member of the set to exist. | |
| existential = { | |
| '1aai', '1eao', '2eao', '2aeo', '3eao', '3aai', '4aeo', '4eao', '4aai' | |
| } | |
| # weakened -- it is possible to make a stronger statement about the claims | |
| # all instead of some, no instead of some not. | |
| weakened = existential - {'3eao', '3aai', '4eao', '4aai'} | |
| class Syllogism: | |
| def __init__(self, figure, mood, syllowords=None): | |
| self.figure = Figure(figure) | |
| self.mood = Mood(mood) | |
| if syllowords is None: | |
| syllowords = random.choice(sylloExamples) | |
| self.subject = syllowords[0] | |
| self.middle = syllowords[1] | |
| self.predicate = syllowords[2] | |
| def generate(self): | |
| allSentences = [] | |
| for sentence in ('major', 'minor', 'conclusion'): | |
| sOut = '' | |
| if sentence == 'conclusion': | |
| sOut = 'Therefore, ' | |
| linkage = getattr(self.mood, sentence + 'Link') | |
| linkWord = self.mood.linkMapping[linkage] | |
| if sOut == '': | |
| linkWord = linkWord.capitalize() | |
| sOut += linkWord | |
| sFormat = getattr(self.figure, sentence) | |
| wt = wordType[sFormat[0]] | |
| sOut += getattr(self, wt) | |
| sOut += ' are ' | |
| sOut += self.mood.postVerbLink[linkage] | |
| wt = wordType[sFormat[1]] | |
| sOut += getattr(self, wt) | |
| sOut += '. ' | |
| allSentences.append(sOut) | |
| return('\n'.join(allSentences)) | |
| def generateAll(): | |
| for i in range(1, 5): | |
| for a in 'aeio': | |
| for b in 'aeio': | |
| for c in 'aeio': | |
| shorthand = '{0}{1}'.format(i, a + b + c) | |
| print(shorthand, end='') | |
| if shorthand in logical: | |
| print(' (' + logical[shorthand].capitalize() + ')', end='') | |
| if shorthand in weakened: | |
| print(' [weak]', end='') | |
| if shorthand in existential: | |
| print(' [existential]', end='') | |
| print('') | |
| s = Syllogism(i, a + b + c) | |
| print(s.generate()) | |
| print('-----------------------\n') | |
| if __name__ == '__main__': | |
| generateAll() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment