Skip to content

Commit 2979c58

Browse files
authored
Merge pull request #14 from clayrat/poly
WIP: Poly
2 parents c53d715 + 51d9255 commit 2979c58

File tree

5 files changed

+1087
-2
lines changed

5 files changed

+1087
-2
lines changed

software_foundations.ipkg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package software_foundations
33
modules = Basics
44
, Induction
55
, Lists
6+
, Poly
67

78
brief = "Software Foundations in Idris"
89
version = 0.0.1.0

src/Induction.lidr

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
= Induction: Proof by Induction
22

3+
> module Induction
4+
35
First, we import all of our definitions from the previous chapter.
46

57
> import Basics

src/Lists.lidr

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
= Lists: Working with Structured Data
22

3+
> module Lists
4+
35
> import Basics
46

57
> %hide Prelude.Basics.fst
@@ -52,7 +54,7 @@ definition of the `minus` function -- this works because the pair notation is
5254
also provided as part of the standard library):
5355

5456
```idris
55-
λΠ> fst_pair (3,5)
57+
λΠ> fst (3,5)
5658
-- 3 : Nat
5759
```
5860

@@ -513,6 +515,7 @@ we remind them exactly what the induction hypothesis is in the second case.
513515
For comparison, here is an informal proof of the same theorem.
514516
515517
_Theorem_: For all lists `l1`, `l2`, and `l3`,
518+
516519
`(l1 ++ l2) ++ l3 = l1 ++ (l2 ++l3)`.
517520
518521
_Proof_: By induction on `l1`.
@@ -631,17 +634,27 @@ _Theorem_: For all lists `l`, `length (rev l) = length l`.
631634
_Proof_: By induction on `l`.
632635
633636
- First, suppose `l = []`. We must show
637+
634638
`length (rev []) = length []`,
639+
635640
which follows directly from the definitions of `length` and `rev`.
636641
637642
- Next, suppose l = n :: l' , with
643+
638644
`length (rev l') = length l'`.
645+
639646
We must show
647+
640648
`length (rev (n :: l')) = length (n :: l')`.
649+
641650
By the definition of `rev`, this follows from
651+
642652
`length ((rev l') ++ [n]) = S (length l')`
653+
643654
which, by the previous lemma, is the same as
655+
644656
`length (rev l') + length [n] = S (length l')`.
657+
645658
This follows directly from the induction hypothesis and the definition of
646659
`length`. $\square$
647660
@@ -664,6 +677,7 @@ audience will already be familiar with. The more pedantic style is a good
664677
default for our present purposes.
665678
666679
\todo[inline]{Edit: `apropos`?}
680+
667681
=== Search
668682
669683
We've seen that proofs can make use of other theorems we've already proved,

src/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ PANDOC_FLAGS := \
1414
LIDRFILES := Preface.lidr \
1515
Basics.lidr \
1616
Induction.lidr \
17-
Lists.lidr
17+
Lists.lidr \
18+
Poly.lidr
1819
# TODO: Add more chapters, in order, here.
1920

2021

0 commit comments

Comments
 (0)