Skip to content

Instantly share code, notes, and snippets.

@wongjiahau
Created May 3, 2021 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wongjiahau/5934354b92cb9db2f950b560681ecb52 to your computer and use it in GitHub Desktop.
Save wongjiahau/5934354b92cb9db2f950b560681ecb52 to your computer and use it in GitHub Desktop.
Proving Modus Ponens and Modus Tollens in Typescript
export const modus_ponens
// Proposition
// Given: A => B and A
// We can conclude: B
: <A, B>(f: (a: A) => B, a: A) => B
= <A, B>(f: (a: A) => B, a: A) => f(a)
// Note, in intuitionistic logic, ~A (a.k.a NOT A), is represented as A => never
export const modus_tollens
// Proposition:
// Given: A => B and ~B
// We can conclude: ~A
: <A, B>(f: (a: A) => B, not_b: (b: B) => never) => (a: A) => never
// Proof
= <A, B>(f: (a: A) => B, not_b: (b: B) => never) => (a: A) => not_b(f(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment