diff --git a/Makefile b/Makefile index 660c7dd3..fa0a5d17 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ agda := $(wildcard src/*.lagda) +agdai := $(wildcard src/*.agdai) markdown := $(subst src/,out/,$(subst .lagda,.md,$(agda))) default: $(markdown) @@ -8,3 +9,18 @@ out/: out/%.md: src/%.lagda out/ agda2html --strip-implicit-args --link-to-agda-stdlib --link-local -i $< -o $@ + +.phony: clean + +clean: +ifneq ($(strip $(agdai)),) + rm $(agdai) +endif + +.phony: clobber + +clobber: clean +ifneq ($(strip $(markdown)),) + rm $(markdown) +endif + rmdir out/ diff --git a/out/Basics.md b/out/Basics.md index 1dc761c3..fee39064 100644 --- a/out/Basics.md +++ b/out/Basics.md @@ -4,41 +4,37 @@ layout : page permalink : /Basics --- -
{% raw %}
-open import Relation.Binary.PropositionalEquality using (_≡_; refl)
 {% endraw %}
-
- -# Basics: Functional Programming in Agda The functional programming style brings programming closer to simple, everyday mathematics: If a procedure or method has no side @@ -92,114 +88,114 @@ The following declaration tells Agda that we are defining a new set of data values -- a *type*.
{% raw %}
-data Day : Set where
+  monday    : Day
+  tuesday   : Day
+  wednesday : Day
+  thursday  : Day
   mondayfriday    : Day
   tuesday   saturday  : Day
   wednesday sunday    : Day
-  thursday  : Day
-  friday    : Day
-  saturday  : Day
-  sunday    : Day
 {% endraw %}
@@ -212,142 +208,142 @@ Having defined `day`, we can write functions that operate on days.
{% raw %}
-nextWeekday : Day -> Day
 nextWeekday monday    = tuesday
 nextWeekday tuesday   = wednesday
 nextWeekday wednesday = thursday
 nextWeekday thursday  = friday
 nextWeekday friday    = monday
 nextWeekday saturday  = monday
 nextWeekday sunday    = monday
 {% endraw %}
@@ -374,35 +370,35 @@ Second, we can record what we *expect* the result to be in the form of an Agda type:
{% raw %}
-test_nextWeekday : nextWeekday (nextWeekday saturday)  tuesday
 {% endraw %}
@@ -415,15 +411,15 @@ Having made the assertion, we must also verify it. We do this by giving a term of the above type:
{% raw %}
-test_nextWeekday = refl
 {% endraw %}
diff --git a/out/Maps.md b/out/Maps.md index a57ad529..e9ffcf73 100644 --- a/out/Maps.md +++ b/out/Maps.md @@ -4,8 +4,6 @@ layout : page permalink : /Maps --- -# Maps: Total and Partial Maps - Maps (or dictionaries) are ubiquitous data structures, both in software construction generally and in the theory of programming languages in particular; we're going to need them in many places in @@ -35,207 +33,207 @@ own definitions and theorems the same as their counterparts in the standard library, wherever they overlap.
{% raw %}
-open import Function         using (_∘_)
 open import Data.Bool        using (Bool; true; false)
+open import (Bool; true; false)
-open import Data.Empty       using (; ⊥-elim)
 open import Data.Maybe       using (Maybe; just; nothing)
 open import Data.Nat         using ()
+open Data.Nat         using ()
-open import Relation.Nullary using (Dec; yes; no)
 open import Relation.Binary.PropositionalEquality
 {% endraw %}
@@ -252,103 +250,140 @@ we repeat its definition here, together with the equality comparison function for ids and its fundamental property.
{% raw %}
-data Id : Set where
   id :   Id
 {% endraw %}
{% raw %}
-_≟_ : (x y : Id)  Dec (x  y)
+id x : (xid y :with Id)  Dec (x Data.Nat.≟ y)
 id x  id y with| xyes Data.Nat.≟x=y rewrite yx=y = yes refl
 id x  id y | yes x=y rewriteid y | no  x≠y x=y = yesno refl
-id x  id y | no  x≠y = no (x≠y  id-inj)
   where
     id-inj :   id x  id y  x  y
     id-inj refl = refl
 {% endraw %}
@@ -590,48 +588,48 @@ _total maps_ that return a default value when we look up a key that is not present in the map.
{% raw %}
-TotalMap : Set  Set
 TotalMap A = Id  A
 {% endraw %}
@@ -640,15 +638,15 @@ Intuitively, a total map over anfi element type $$A$$ _is_ just a function that can be used to look up ids, yielding $$A$$s.
{% raw %}
-module TotalMap where
 {% endraw %}
@@ -658,64 +656,64 @@ default element; this map always returns the default element when applied to any id.
{% raw %}
-  empty :   A  TotalMap A
   empty x = λ _  x
 {% endraw %}
@@ -725,146 +723,146 @@ a map $$m$$, a key $$x$$, and a value $$v$$ and returns a new map that takes $$x$$ to $$v$$ and takes every other key to whatever $$m$$ does.
{% raw %}
-  update :   TotalMap A -> Id -> A :   TotalMap A -> IdTotalMap A
+  update m x ->v Ay ->with TotalMapx A y
   update... m| xyes x=y = v y with
+  ... x| no  x≠y y
-  ...= |m yes x=y = v
-  ... | no  x≠y = m y
 {% endraw %}
@@ -878,84 +876,84 @@ For example, we can build a map taking ids to bools, where `id like this:
{% raw %}
-  examplemap : TotalMap Bool
   examplemap = update (update (empty false) (id 1) false) (id (empty false) (id 1) false) (id 3) true
 {% endraw %}
@@ -965,189 +963,189 @@ need to define a `find` operation because it is just function application!
{% raw %}
-  test_examplemap0 : examplemap (id 0)  false
+  test_examplemap0 = 0)  false
-  test_examplemap0 = refl
 
   test_examplemap1 : examplemap (id 1)  false
+  test_examplemap1 = 1)  false
-  test_examplemap1 = refl
 
   test_examplemap2 : examplemap (id 2)  false
+  test_examplemap2 = 2)  false
-  test_examplemap2 = refl
 
   test_examplemap3 : examplemap (id 3)  true
   test_examplemap3 = refl
 {% endraw %}
@@ -1163,96 +1161,96 @@ chapter and included in the Agda standard library.) First, the empty map returns its default element for all keys:
{% raw %}
-  postulate
     apply-empty :   empty v x  v
 {% endraw %}