mscroggs.co.uk
mscroggs.co.uk

subscribe

Blog

Logic bot, pt. 2

 2015-03-15 
A few months ago, I set @mathslogicbot (and @logicbot@mathstodon.xyz and @logicbot.bsky.social) going on the long task of tweeting all the tautologies (containing 140 characters or less) in propositional calculus with the symbols \(\neg\) (not), \(\rightarrow\) (implies), \(\leftrightarrow\) (if and only if), \(\wedge\) (and) and \(\vee\) (or). My first post on logic bot contains a full explanation of propositional calculus, formulae and tautologies.

An alternative method

Since writing the original post, I have written an alternative script to generate all the tautologies. In this new method, I run through all possible strings of length 1 made with character in the logical language, then strings of length 2, 3 and so on. The script then checks if they are valid formulae and, if so, if they are tautologies.
In the new script, only formulae where the first appearances of variables are in alphabetical order are considered. This means that duplicate tautologies are removed. For example, \((b\rightarrow(b\wedge a))\) will now be counted as it is the same as \((a\rightarrow(a\wedge b))\).
You can view or download this alternative code on github. All the terms of the sequence that I have calculated so far can be viewed here and the tautologies for these terms are here.

Sequence

One advantage of this method is that it generates the tautologies sorted by the number of symbols they contain, meaning we can generate the sequence whose \(n\)th term is the number of tautologies of length \(n\).
The first ten terms of this sequence are
$$0, 0, 0, 0, 2, 2, 12, 6, 57, 88$$
as there are no tautologies of length less than 5; and, for example two tautologies of length 6 (\((\neg a\vee a)\) and \((a\vee \neg a)\)).
This sequence is listed as A256120 on OEIS.

Properties

There are a few properties of this sequence that can easily be shown. Throughout this section I will use \(a_n\) to represent the \(n\)th term of the sequence.
Firstly, \(a_{n+2}\geq a_n\). This can be explained as follows: let \(A\) be a tautology of length \(n\). \(\neg\neg A\) will be of length \(n+2\) and is logically equivalent to \(A\).
Another property is \(a_{n+4}\geq 2a_n\): given a tautology \(A\) of length \(n\), both \((a\vee A)\) and \((A\vee a)\) will be tautologies of length \(n+4\). Similar properties could be shown for \(\rightarrow\), \(\leftrightarrow\) and \(\wedge\).
Given properties like this, one might predict that the sequence will be increasing (\(a_{n+1}\geq a_n\)). However this is not true as \(a_7\) is 12 and \(a_8\) is only 6. It would be interesting to know at how many points in the sequence there is a term that is less than the previous one. Given the properties above it is reasonable to conjecture that this is the only one.
Edit: The sequence has been published on OEIS!
Edit: Added Mastodon and Bluesky links
×5      ×3      ×3      ×3      ×3
(Click on one of these icons to react to this blog post)

You might also enjoy...

Comments

Comments in green were written by me. Comments in blue were not written by me.
You should do a logic bot for logical graphs ...

https://oeis.org/wiki/Logical_Graphs
https://inquiryintoinquiry.com/2024/08...
https://inquiryintoinquiry.com/2024/09...
https://inquiryintoinquiry.com/2025/05...

it would be great !!!
Jon Awbrey
                 Reply
Great project! Would be interesting to have a version of this for the sheffer stroke.
om
×3   ×3   ×3   ×1   ×3     Reply
 Add a Comment 


I will only use your email address to reply to your comment (if a reply is needed).

Allowed HTML tags: <br> <a> <small> <b> <i> <s> <sup> <sub> <u> <spoiler> <ul> <ol> <li> <logo>
To prove you are not a spam bot, please type "axes" in the box below (case sensitive):

Archive

Show me a random blog post
 2026 

Feb 2026

Christmas (2025) is over
 2025 
▼ show ▼
 2024 
▼ show ▼
 2023 
▼ show ▼
 2022 
▼ show ▼
 2021 
▼ show ▼
 2020 
▼ show ▼
 2019 
▼ show ▼
 2018 
▼ show ▼
 2017 
▼ show ▼
 2016 
▼ show ▼
 2015 
▼ show ▼
 2014 
▼ show ▼
 2013 
▼ show ▼
 2012 
▼ show ▼

Tags

kenilworth pythagoras hexapawn electromagnetic field standard deviation stirling numbers anscombe's quartet crosswords countdown books alphabets newcastle edinburgh golden spiral datasaurus dozen coins statistics logo golden ratio draughts radio 4 noughts and crosses triangles crossnumber machine learning flexagons python matt parker runge's phenomenon game show probability regular expressions mathslogicbot tennis the aperiodical coventry 24 hour maths rhombicuboctahedron estimation curvature raspberry pi logs reddit logic phd approximation plastic ratio recursion sorting weak imposition inline code error bars stickers dates games royal baby matrix of minors thirteen preconditioning binary frobel arithmetic geometry sobolev spaces menace puzzles fonts mathsteroids map projections simultaneous equations propositional calculus matrices rust gerry anderson reuleaux polygons asteroids pizza cutting programming football live stream mean boundary element methods realhats matrix of cofactors wave scattering big internet math-off fractals pac-man tmip royal institution gather town final fantasy rugby exponential growth finite element method probability harriss spiral braiding sport graphs london underground computational complexity bots martin gardner signorini conditions ucl christmas card fence posts errors manchester science festival geogebra a gamut of games correlation matrix multiplication dataset inverse matrices warwick nine men's morris talking maths in public graph theory javascript folding tube maps dragon curves light friendly squares crossnumbers interpolation chebyshev pascal's triangle oeis latex misleading statistics folding paper chess pi approximation day gaussian elimination pi cambridge cross stitch weather station kings national lottery youtube php partridge puzzle london dinosaurs european cup hannah fry numbers convergence people maths sound mathsjam determinants nonograms zines manchester hyperbolic surfaces palindromes speed ternary platonic solids bubble bobble accuracy bodmas guest posts numerical analysis advent calendar quadrilaterals hats world cup craft data visualisation finite group chalkdust magazine news data polynomials captain scarlet trigonometry wool bempp game of life christmas databet go video games squares crochet turtles

Archive

Show me a random blog post
▼ show ▼
© Matthew Scroggs 2012–2026