Skip to content

Commit 00a9f32

Browse files
authored
Basics: fix typos, add some explanations
1 parent 2a5448d commit 00a9f32

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

src/Basics.lidr

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ that can be used to prove simple properties of Idris programs.
6161

6262
One unusual aspect of Coq is that its set of built-in features is _extremely_
6363
small, For example, instead of providing the usual palette of atomic data types
64-
(booleans, integers, strings, etc.), Coq offers a powerl mechanism for defining
65-
new data types from scratch, from which all these familiar types arise as
66-
instances.
64+
(booleans, integers, strings, etc.), Coq offers a powerful mechanism for
65+
defining new data types from scratch, from which all these familiar types arise
66+
as instances.
6767

6868
Naturally, the Coq distribution comes with an extensive standard library
6969
providing definitions of booleans, numbers, and many common data structures like
@@ -153,7 +153,7 @@ definition.
153153
Having defined a function, we should check that it works on some examples. There
154154
are actually three different .ways to do this in Idris.
155155

156-
First, we can evalute an expression involving `nextWeekday` in a REPL.
156+
First, we can evaluate an expression involving `nextWeekday` in a REPL.
157157

158158
```idris
159159
λΠ> nextWeekday Friday
@@ -226,13 +226,20 @@ members `False` and `True`.
226226

227227
```idris
228228
||| Boolean Data Type
229+
data Bool = True | False
230+
```
231+
232+
This definition is written in the simplified style, similar to `Day`. It can
233+
also be written in the verbose style (which is more powerful):
234+
235+
```idris
229236
data Bool : Type where
230237
True : Bool
231238
False : Bool
232239
```
233240

234241
Although we are rolling our own booleans here for the sake of building up
235-
everything from scratch, Idiris does, of course, provide a default
242+
everything from scratch, Idris does, of course, provide a default
236243
implementation of the booleans in its standard library, together with a
237244
multitude of useful functions and lemmas. (Take a look at `Prelude` in the Idris
238245
library documentation if you're interested.) Whenever possible, we'll name our
@@ -272,7 +279,7 @@ truth table -- for the `orb` function:
272279
-- TODO: Edit this
273280

274281
We can also introduce some familiar syntax for the boolean operations we have
275-
just defined. The `syntax` command defines new notation for an existing
282+
just defined. The `syntax` command defines a new notation for an existing
276283
definition, and `infixl` specifies left-associative fixity.
277284
\color{black}
278285

@@ -291,10 +298,10 @@ definition, and `infixl` specifies left-associative fixity.
291298

292299
=== Exercises: 1 star (nandb)
293300

294-
Fill in the hole `?nandb_rhs` and omplete the following function; then make sure
295-
that the assertions below can each be verified by Idris. (Fill in each of the
296-
holes, following the model of the `orb` tests above.) The function should return
297-
`True` if either or both of its inputs `False`.
301+
Fill in the hole `?nandb_rhs` and complete the following function; then make
302+
sure that the assertions below can each be verified by Idris. (Fill in each of
303+
the holes, following the model of the `orb` tests above.) The function should
304+
return `True` if either or both of its inputs `False`.
298305

299306
> nandb : (b1 : Bool) -> (b2 : Bool) -> Bool
300307
> nandb b1 b2 = ?nandb_rhs
@@ -348,7 +355,7 @@ For example, the type of `negb True` is `Bool`.
348355
```idris
349356
λΠ> :type True
350357
-- True : Bool
351-
λΠ> :t negb True : Bool
358+
λΠ> :t negb True
352359
-- negb True : Bool
353360
```
354361

@@ -385,9 +392,9 @@ Idris provides a _module system_, to aid in organizing large developments.
385392
> namespace Numbers
386393

387394
The types we have defined so far are examples of "enumerated types": their
388-
definitions explicitly enumerate a finit set of elements. A More interesting way
389-
of defining a type is to give a collection of _inductive rules_ describing its
390-
elements. For example, we can define the natural numbers as follows:
395+
definitions explicitly enumerate a finite set of elements. A More interesting
396+
way of defining a type is to give a collection of _inductive rules_ describing
397+
its elements. For example, we can define the natural numbers as follows:
391398

392399
```idris
393400
data Nat : Type where
@@ -461,7 +468,7 @@ These are all things that can be applied to a number to yield a number. However,
461468
there is a fundamental difference between the first one and the other two:
462469
functions like `pred` and `minusTwo` come with _computation rules_ -- e.g., the
463470
definition of `pred` says that `pred 2` can be simplified to `1` -- while the
464-
definition of `S` has no such behavior attached. Althrough it is like a function
471+
definition of `S` has no such behavior attached. Although it is like a function
465472
in the sense that it can be applied to an argument, it does not _do_ anything at
466473
all!
467474

@@ -489,7 +496,7 @@ definition that is a bit easier to work with:
489496
> testOddb2 : oddb 4 = False
490497
> testOddb2 = Refl
491498

492-
Naturally we can also define multi-argument functions by recursion.
499+
Naturally, we can also define multi-argument functions by recursion.
493500

494501
> namespace Playground2
495502
> plus : (n : Nat) -> (m : Nat) -> Nat
@@ -532,7 +539,7 @@ mult (S k) = plus m (mult k m)
532539
> testMult1 : (mult 3 3) = 9
533540
> testMult1 = Refl
534541

535-
You can match two expression at once:
542+
You can match two expressions at once:
536543

537544
```idris
538545
minus : (n, m : Nat) -> Nat
@@ -680,19 +687,14 @@ Other similar theorems can be proved with the same pattern.
680687
> mult_0_l : (n : Nat) -> 0 * n = 0
681688
> mult_0_l n = Refl
682689

683-
The `_l` suffix in the names of these theorems is pronounces "on the left."
690+
The `_l` suffix in the names of these theorems is pronounced "on the left."
684691

685692
Although simplification is powerful enough to prove some fairly general facts,
686693
there are many statements that cannot be handled by simplification alone. For
687694
instance, we cannot use it to prove that `0` is also a neutral element for `+`
688695
_on the right_.
689696

690697

691-
```idris
692-
plus_n_Z : (n : Nat) -> n = n + 0
693-
plus_n_Z n = Refl
694-
```
695-
696698
```idris
697699
plus_n_Z : (n : Nat) -> n = n + 0
698700
plus_n_Z n = Refl
@@ -719,6 +721,11 @@ The next chapter will introduce _induction_, a powerful technique that can be
719721
used for proving this goal. For the moment, though, let's look at a few more
720722
simple tactics.
721723

724+
725+
== Proof by Rewriting
726+
727+
This theorem is a bit more interesting than the others we've seen:
728+
722729
> plus_id_example : (n, m : Nat) -> (n = m)
723730
> -> n + n = m + m
724731

0 commit comments

Comments
 (0)