Skip to content

Instantly share code, notes, and snippets.

@seankearon
Last active January 12, 2020 11:03
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 seankearon/dbbd257b52e0fb0951318366db0bbf79 to your computer and use it in GitHub Desktop.
Save seankearon/dbbd257b52e0fb0951318366db0bbf79 to your computer and use it in GitHub Desktop.
Curry-Howard Exercise
// (A => B and not B) => not A
Not<A> ModusTollens<A, B>(
Func<A, B> A_implies_B,
Not<B> not_B)
{
Absurd A_to_Absurd(A a)
{
return not_B.Apply(A_implies_B(a));
}
return new Not<A>(A_to_Absurd);
}
// (A => B and B => C) => A => C
Func<A, C> Syllogism<A, B, C>(
Func<A, B> A_implies_B,
Func<B, C> B_implies_C)
{
C Composed(A a)
{
return B_implies_C(A_implies_B(a));
}
return Composed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment