Permalink
Browse files

Cleanup for github.

  • Loading branch information...
0 parents commit de96fedc161679be91850a7b691778c37829d000 @dalaing committed Mar 26, 2013
Showing with 1,550 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +10 −0 LICENSE
  3. +11 −0 README.md
  4. +14 −0 coq/extraction/append.hs
  5. +14 −0 coq/extraction/map.hs
  6. +40 −0 coq/functor.v
  7. +55 −0 coq/monoid.v
  8. BIN latex/slides.pdf
  9. +1,398 −0 latex/slides.tex
@@ -0,0 +1,8 @@
+coq/CpdtTactics.v
+**/*.aux
+**/*.log
+**/*.nav
+**/*.out
+**/*.snm
+**/*.toc
+**/*.vrb
@@ -0,0 +1,10 @@
+Copyright (c) 2012, David Laing (dave.laing.80@gmail.com)
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,11 @@
+BFPG talk - Laws and Equations and Coq
+
+- The slides were built with
+ - cd latex
+ - pdflatex slides.tex
+
+- The coq file functor.v requires the "crush" tactic
+ from CPDT - http://adam.chlipala.net/cpdt
+ - Grab the code from http://adam.chlipala.net/cpdt/cpdt.tgz
+ - Put CpdtTactics.v next to functor.v
+
@@ -0,0 +1,14 @@
+module Append where
+
+import qualified Prelude
+
+data List a =
+ Nil
+ | Cons a (List a)
+
+append :: (List a1) -> (List a1) -> List a1
+append xs ys =
+ case xs of {
+ Nil -> ys;
+ Cons h t -> Cons h (append t ys)}
+
@@ -0,0 +1,14 @@
+module Map where
+
+import qualified Prelude
+
+data List a =
+ Nil
+ | Cons a (List a)
+
+map :: (a1 -> a2) -> (List a1) -> List a2
+map f l =
+ case l of {
+ Nil -> Nil;
+ Cons a t -> Cons (f a) (map f t)}
+
@@ -0,0 +1,40 @@
+
+Require Import Coq.Program.Basics.
+Set Implicit Arguments.
+Open Scope list_scope.
+
+Definition id {A: Type} (e: A): A := e.
+
+Class Functor (F: Type -> Type) :=
+{
+fmap : forall (A B: Type), (A -> B) -> F A -> F B;
+functor_id :
+ forall (A: Type) (e: F A),
+ fmap id e = e;
+functor_compose :
+ forall (A B C: Type) (f: A -> B) (g: B -> C) (e: F A),
+ fmap (compose g f) e = fmap g (fmap f e)
+}.
+
+Fixpoint map (A B: Type) (f: A -> B) (xs: list A) : list B :=
+match xs with
+| nil => nil
+| cons h t => cons (f h) (map f t)
+end.
+
+Instance list_Functor : Functor list :=
+{
+fmap := map
+}.
+
+(* Thanks to Adam Chlipala *)
+Load CpdtTactics.
+
+Proof.
+induction e; crush.
+induction e; crush.
+Qed.
+
+Extraction Language Haskell.
+Extraction "extraction/map.hs" map.
+
@@ -0,0 +1,55 @@
+Set Implicit Arguments.
+Open Scope list_scope.
+
+Class Monoid (A: Type) :=
+{
+mempty : A;
+mappend : A -> A -> A;
+monoid_left_id :
+ forall a: A,
+ mappend mempty a = a;
+monoid_right_id :
+ forall a: A,
+ mappend a mempty = a;
+monoid_assoc :
+ forall a b c: A,
+ mappend a (mappend b c) = mappend (mappend a b) c
+}.
+
+Fixpoint append {A: Type} (xs ys: list A) : (list A) :=
+match xs with
+| nil => ys
+| cons h t => cons h (append t ys)
+end.
+
+Instance list_Monoid {A: Type} : Monoid (list A) :=
+{
+mempty := nil;
+mappend := append
+}.
+
+Proof.
+intros a.
+simpl.
+reflexivity.
+
+intros.
+induction a.
+simpl.
+reflexivity.
+simpl.
+rewrite IHa.
+reflexivity.
+
+intros.
+induction a.
+simpl.
+reflexivity.
+simpl.
+rewrite IHa.
+reflexivity.
+Qed.
+
+Extraction Language Haskell.
+Extraction "extraction/append.hs" append.
+
Binary file not shown.
Oops, something went wrong. Retry.

0 comments on commit de96fed

Please sign in to comment.