GithubHelp home page GithubHelp logo

spidermoy / monads_kleislitriples_proof Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 587 KB

Computer Scientist Degree - Thesis Work

Coq 100.00%
coq coq-formalization unam fciencias monads kleisli category-theory functional-programming mexico-city natural-transformation

monads_kleislitriples_proof's Introduction

Monads in functional programming: a formalized proof of their equivalence with Kleisli triples

“Being a language, mathematics may be used not only to inform but also, among other things, to seduce.”
─Benoît Mandelbrot

“There is no branch of mathematics, however abstract, which may not some day be applied to phenomena of the real world.”
─Nikolai Ivanovich Lobachevsky

“Category theory is a relatively young branch of pure mathematics that most computer scientists would consider esoteric”
─Benjamin C. Pierce

This repository contains my work for obtain my computer scientist degree. My thesis is here.

My work consisted in to formalize basic concepts of Category Theory in Coq, and realize a formal verification of a proof of equivalence between monads and Kleisli triples.


A few history

The notion of monad was invented by Roger Godement in 1958 under the name "standard construction." In the 1960s and 1970s, many people used the name "triple." The now standard term "monad" is due to Saunders Mac Lane. (See Monad)

Eugenio Moggi was the first to explicitly link the monad of category theory to functional programming. In earlier work, several computer scientists had advanced using category theory to provide semantics for the lambda calculus. Several others popularized and built on this idea, including Philip Wadler and Simon Peyton Jones, both of whom were involved in the specification of Haskell. At first, programming with monads was largely confined to Haskell and its derivatives, but as functional programming has influenced other paradigms, many languages have incorporated a monad pattern (in spirit if not in name). Formulations now exist in Scheme, Perl, Python, Racket, Clojure, Scala, F#, and have also been considered for a new ML standard. (See Monad (functional programming))

The more common definition for a monad in functional programming is actually based on a Kleisli triple rather than category-theory's standard definition. The two constructs turn out to be mathematically equivalent. (See Kleisli Triple)

In 1991, Moggi give us a small and informal proof of the mathematical equivalence between monads and Kleisli triples. (See Moggi, E. (1991). Notions of computation and monads). In 2007, Gammon shows a detailed and extended formal proof of the mathematical equivalence between monads and Kleisli triples. (See Gammon, S. C. (2007). Notions of category theory in functional programming (Doctoral dissertation, University of British Columbia).) Finally, in 2016, I formalized Gammon's proof in the proof assistant Coq.


Coq

I used CoqIde 8.11 to run my script.

I use type classes to define category theory concepts (see A Gentle Introduction to Type Classes and Relations in Coq) and inspiration given from Matthieu Sozeau's work.

My script contains:

* Category definition
* Category examples
* Functor definition
* Identity functor definition
* Functors composition definition
* Natural Transformation definition
* Monad definition
* Kleisli triple definition
* Formalized proof of the mathematical equivalence between monads and Kleisli triples

monads_kleislitriples_proof's People

Contributors

spidermoy avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.