Permalink
Browse files

Updated to latest hakyll, started rewrite of proof section

  • Loading branch information...
1 parent afc2b06 commit 19bade6d1d288bb221e2dbc0e256dc608518ea8a Liam O'Connor-Davis committed Jan 20, 2013
Showing with 337 additions and 111 deletions.
  1. +5 −0 .gitignore
  2. +30 −0 LICENSE
  3. +2 −0 Setup.hs
  4. +0 −29 hakyll.hs
  5. +21 −0 learn-you-an-agda.cabal
  6. +35 −0 main.hs
  7. +4 −8 pages/introduction.md
  8. +8 −6 pages/peano.md
  9. +231 −68 pages/proofs.md
  10. +1 −0 templates/default.html
View
@@ -0,0 +1,5 @@
+*.swp
+/_cache/
+/_site/
+/cabal-dev/
+/dist/
View
30 LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2013, Liam O'Connor-Davis
+
+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 Liam O'Connor-Davis nor the names of other
+ 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
+OWNER 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.
View
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
View
@@ -1,29 +0,0 @@
-#!/usr/bin/runhaskell
-{-# LANGUAGE OverloadedStrings #-}
-import Control.Arrow((>>>))
-import Hakyll
-
-main = hakyll $ do
- match "css/*" $ do
- route idRoute
- compile compressCssCompiler
-
- match "static/*" $ do
- route idRoute
- compile copyFileCompiler
-
- match "templates/*" $ do
- compile templateCompiler
-
- match "pages/*" $ do
- route (setExtension "html")
- compile $ pageCompiler >>> applyTemplateCompiler "templates/default.html" >>> relativizeUrlsCompiler
-
- match "toc.md" $ do
- route (setExtension "html")
- compile $ pageCompiler >>> applyTemplateCompiler "templates/toc.html" >>> relativizeUrlsCompiler
-
- match "index.md" $ do
- route (setExtension "html")
- compile $ pageCompiler >>> applyTemplateCompiler "templates/cover.html" >>> relativizeUrlsCompiler
-
View
@@ -0,0 +1,21 @@
+-- Initial learn-you-an-agda.cabal generated by cabal init. For further
+-- documentation, see http://haskell.org/cabal/users-guide/
+
+name: learn-you-an-agda
+version: 0.1.0.0
+synopsis: Agda tutorial
+-- description:
+license: BSD3
+license-file: LICENSE
+author: Liam O'Connor-Davis
+maintainer: liamoc@cse.unsw.edu.au
+-- copyright:
+-- category:
+build-type: Simple
+cabal-version: >=1.10
+
+executable learn-you-an-agda
+ main-is: main.hs
+ -- other-modules:
+ build-depends: hakyll >= 4.1, base >= 4.1, pandoc >= 1.10
+ default-language: Haskell2010
View
35 main.hs
@@ -0,0 +1,35 @@
+#!/usr/bin/runhaskell
+{-# LANGUAGE OverloadedStrings #-}
+import Control.Arrow((>>>))
+import Hakyll
+import Text.Pandoc.Options
+compiler = pandocCompilerWith r w >>= relativizeUrls
+ where r = defaultHakyllReaderOptions
+ w = defaultHakyllWriterOptions { writerHTMLMathMethod = MathJax "https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js" }
+
+main = hakyll $ do
+ match "css/*" $ do
+ route idRoute
+ compile compressCssCompiler
+
+ match "static/*" $ do
+ route idRoute
+ compile copyFileCompiler
+
+ match "templates/*" $ do
+ compile templateCompiler
+
+ match "pages/*" $ do
+ route (setExtension "html")
+ compile $ compiler >>=
+ loadAndApplyTemplate "templates/default.html" defaultContext
+ match "toc.md" $ do
+ route (setExtension "html")
+ compile $ compiler >>=
+ loadAndApplyTemplate "templates/toc.html" defaultContext
+
+ match "index.md" $ do
+ route (setExtension "html")
+ compile $ compiler >>=
+ loadAndApplyTemplate "templates/cover.html" defaultContext
+
View
@@ -1,7 +1,7 @@
-----
title: Introduction
date: 16th Febuary 2011
-prev:
+prev: _
next: <a href="/pages/peano.html">Hello, Peano → </a>
-----
@@ -170,23 +170,19 @@ Once you have Haskell and Emacs, there are three things you still need to do:
"agda" to find out). If not or otherwise, simply use the Haskell platform's `cabal-install` tool
to download, compile, and set up Agda.
- $ cabal install agda agda-executable
+ $ cabal install agda
* Install Agda mode for emacs. Simply type in a command prompt (where Agda is in your `PATH`):
$ agda-mode setup
-* Install Haskell mode for emacs. If Haskell mode is not available in your package manager, you
- can [download Haskell mode](http://www.iro.umontreal.ca/μonnier/elisp/#haskell-mode) and install
- it by adding to your `.emacs` file[^0]:
+* Compile Agda mode as well (you'll need to do this again if you update Agda):
- (setq load-path (cons "/path/to/my/haskell/mode" load-path))
+ $ agda-mode compile
By then you should be all set. To find out if everything went as well as expected, head on over
to the next section, "Hello Peano!".
-
-[^0]: Adjusting the path as appropriate, of course.
[^1]: Fans of C++ would know what I'm talking about here.
[^2]: If only Agda existed when Fermat was around.
View
@@ -35,7 +35,7 @@ Even `Set` (the type of our type `ℕ`) has a type: `Set₁`, which has a type `
`Set` types mean later, but for now you can think of `Set` as the type we give to all the data types we use in our program.
<div class="aside">
-This infinite heirarchy of types provides an elegant solution to [Russell's Paradox](http://en.wikipedia.org/wiki/Russell's_paradox). Seeing as for any ν∈ ℕ, `Set ν` contains
+This infinite heirarchy of types provides an elegant solution to <a href=http://en.wikipedia.org/wiki/Russell's_paradox>Russell's Paradox</a> . Seeing as for any ν∈ ℕ, `Set ν` contains
only values "smaller" than ν, (for example, `Set₁` cannot contain `Set₁` or `Set₂`, only `Set`), Russell's problematic set (which contains itself) cannot exist and is not
admissable.
</div>
@@ -64,16 +64,16 @@ But we'd quickly find our text editor full of definitions and we'd be no closer
mathematical definition. The notation I'm using here should be familiar to anyone who knows set theory and/or first-order logic - don't panic if you don't know these things,
we'll be developing models for similar things in Agda later, so you will be able to pick it up as we go along.
-* Zero is a natural number (`0∈ℕ`).
-* For any natural number `ν`, + 1` is also a natural number. For convenience, We shall refer to + 1` as `suc ν`[^1]. (`∀ν∈ℕ → suc ν∈ℕ`).
+* Zero is a natural number ($0\in\mathbb{N}$).
+* For any natural number $n$, $n + 1$ is also a natural number. For convenience, We shall refer to $n + 1$ as $\mathtt{suc}\ n$[^1]. ($\forall n \in \mathbb{N}.\ \mathtt{suc}\ n \in \mathbb{N}$).
This is called an *inductive definition* of natural numbers. We call it *inductive* because it consists of a *base* rule, where we define a fixed starting point,
and an *inductive* rule that, when applied to an element of the set, *induces* the next element of the set. This is a very elegant way to define infinitely large sets. This way
of defining natural numbers was developed by a mathematician named Giuseppe Peano, and so they're called the Peano numbers.
We will look at inductive *proof* in the coming chapters, which shares a similar structure.
-For the base case, we've already defined zero to be in by saying:
+For the base case, we've already defined zero to be in $\mathbb{N}$ by saying:
~~~{.agda}
data ℕ : Set where
@@ -82,9 +82,11 @@ data ℕ : Set where
For the second point (the inductive rule), it gets a little more complicated. First let's take a look at the inductive rule definition in first order logic:
- ∀ν ∈ ℕ → suc ν ∈ ℕ
+<center>
+ $\forall n \in \mathbb{N}.\ \mathtt{suc}\ n \in \mathbb{N}$
+</center>
-This means, given a natural number `ν`, the constructor `suc` will return another natural number. So, in other words, `suc` could be considered a *function*
+This means, given a natural number `n`, the constructor `suc` will return another natural number. So, in other words, `suc` could be considered a *function*
that, when given a natural number, produces the next natural number. This means that we can define the constructor `suc` like so:
~~~{.agda}
Oops, something went wrong.

0 comments on commit 19bade6

Please sign in to comment.