Created
May 3, 2021 13:40
-
-
Save wongjiahau/5934354b92cb9db2f950b560681ecb52 to your computer and use it in GitHub Desktop.
Proving Modus Ponens and Modus Tollens in Typescript
This file contains 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
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