Skip to content

Commit 4cfa26b

Browse files
author
Alex Gryzlov
committed
stylistic fixes
1 parent e445308 commit 4cfa26b

File tree

2 files changed

+50
-34
lines changed

2 files changed

+50
-34
lines changed

src/Basics.lidr

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -103,28 +103,28 @@ Having defined `Day`, we can write functions that operate on days.
103103
Type the following:
104104

105105
```idris
106-
nextWeekday : Day -> Day
106+
nextWeekday : Day -> Day
107107
```
108108

109109
Then with point on `nextWeekday`, call \gls{idris-add-clause}.
110110

111111
```idris
112-
nextWeekday : Day -> Day
113-
nextWeekday x = ?nextWeekday_rhs
112+
nextWeekday : Day -> Day
113+
nextWeekday x = ?nextWeekday_rhs
114114
```
115115

116116
With the point on `day`, call \mintinline[]{elisp}{idris-case-split}
117117
(\mintinline[]{elisp}{M-RET c} in Spacemacs).
118118

119119
```idris
120-
nextWeekday : Day -> Day
121-
nextWeekday Monday = ?nextWeekday_rhs_1
122-
nextWeekday Tuesday = ?nextWeekday_rhs_2
123-
nextWeekday Wednesday = ?nextWeekday_rhs_3
124-
nextWeekday Thursday = ?nextWeekday_rhs_4
125-
nextWeekday Friday = ?nextWeekday_rhs_5
126-
nextWeekday Saturday = ?nextWeekday_rhs_6
127-
nextWeekday Sunday = ?nextWeekday_rhs_7
120+
nextWeekday : Day -> Day
121+
nextWeekday Monday = ?nextWeekday_rhs_1
122+
nextWeekday Tuesday = ?nextWeekday_rhs_2
123+
nextWeekday Wednesday = ?nextWeekday_rhs_3
124+
nextWeekday Thursday = ?nextWeekday_rhs_4
125+
nextWeekday Friday = ?nextWeekday_rhs_5
126+
nextWeekday Saturday = ?nextWeekday_rhs_6
127+
nextWeekday Sunday = ?nextWeekday_rhs_7
128128
```
129129

130130
Fill in the proper `Day` constructors and align whitespace as you like.
@@ -213,17 +213,17 @@ In a similar way, we can define the standard type `Bool` of booleans, with
213213
members `False` and `True`.
214214

215215
```idris
216-
||| Boolean Data Type
217-
data Bool = True | False
216+
||| Boolean Data Type
217+
data Bool = True | False
218218
```
219219

220220
This definition is written in the simplified style, similar to `Day`. It can
221221
also be written in the verbose style:
222222

223223
```idris
224-
data Bool : Type where
225-
True : Bool
226-
False : Bool
224+
data Bool : Type where
225+
True : Bool
226+
False : Bool
227227
```
228228

229229
The verbose style is more powerful because it allows us to assign precise
@@ -385,9 +385,9 @@ way of defining a type is to give a collection of _inductive rules_ describing
385385
its elements. For example, we can define the natural numbers as follows:
386386

387387
```idris
388-
data Nat : Type where
389-
Z : Nat
390-
S : Nat -> Nat
388+
data Nat : Type where
389+
Z : Nat
390+
S : Nat -> Nat
391391
```
392392

393393
The clauses of this definition can be read:
@@ -519,9 +519,9 @@ can be written together. In the following definition, `(n, m : Nat)` means just
519519
the same as if we had written `(n : Nat) -> (m : Nat)`.
520520

521521
```idris
522-
mult : (n, m : Nat) -> Nat
523-
mult Z = Z
524-
mult (S k) = plus m (mult k m)
522+
mult : (n, m : Nat) -> Nat
523+
mult Z = Z
524+
mult (S k) = plus m (mult k m)
525525
```
526526

527527
> testMult1 : (mult 3 3) = 9
@@ -530,10 +530,10 @@ mult (S k) = plus m (mult k m)
530530
You can match two expressions at once:
531531

532532
```idris
533-
minus : (n, m : Nat) -> Nat
534-
minus Z _ = Z
535-
minus n Z = n
536-
minus (S k) (S j) = minus k j
533+
minus : (n, m : Nat) -> Nat
534+
minus Z _ = Z
535+
minus n Z = n
536+
minus (S k) (S j) = minus k j
537537
```
538538

539539
\todo[inline]{Verify this.}
@@ -578,9 +578,9 @@ We can make numerical expressions a little easier to read and write by
578578
introducing _syntax_ for addition, multiplication, and subtraction.
579579

580580
```idris
581-
syntax [x] "+" [y] = plus x y
582-
syntax [x] "-" [y] = minus x y
583-
syntax [x] "*" [y] = mult x y
581+
syntax [x] "+" [y] = plus x y
582+
syntax [x] "-" [y] = minus x y
583+
syntax [x] "*" [y] = mult x y
584584
```
585585

586586
```idris
@@ -723,7 +723,7 @@ is pronounced "implies."
723723
As before, we need to be able to reason by assuming the existence of some
724724
numbers `n` and `m`. We also need to assume the hypothesis `n = m`.
725725

726-
-- FIXME
726+
\todo[inline]{Edit.}
727727
The `intros` tactic will serve to move all three of these from the goal into
728728
assumptions in the current context.
729729

src/Lists.lidr

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ The new pair notation can be used both in expressions and in pattern matches
5151
definition of the `minus` function -- this works because the pair notation is
5252
also provided as part of the standard library):
5353

54-
```idris λΠ>
55-
fst_pair (3,5)
54+
```idris
55+
λΠ> fst_pair (3,5)
5656
-- 3 : Nat
5757
```
5858

@@ -86,7 +86,7 @@ When checking right hand side of
8686
Type mismatch between p and Pair (fst p) (snd p)
8787
```
8888

89-
We have to expose the structure of `p` so that `simpl` can perform the pattern
89+
We have to expose the structure of `p` so that Idris can perform the pattern
9090
match in `fst` and `snd`. We can do this with `case`.
9191

9292
> surjective_pairing : (p : NatProd) -> p = (fst p, snd p)
@@ -470,7 +470,7 @@ will make no sense when you get to them. 'Nuff said.
470470
Proofs by induction over datatypes like `NatList` are a little less familiar
471471
than standard natural number induction, but the idea is equally simple. Each
472472
`data` declaration defines a set of data values that can be built up using the
473-
declared constructors: a boolean can be either `True` or `False` ; a number can
473+
declared constructors: a boolean can be either `True` or `False`; a number can
474474
be either `Z` or `S` applied to another number; a list can be either `Nil` or
475475
`Cons` applied to a number and a list.
476476
@@ -518,15 +518,23 @@ _Theorem_: For all lists `l1`, `l2`, and `l3`,
518518
_Proof_: By induction on `l1`.
519519
520520
- First, suppose `l1 = []`. We must show
521+
521522
`([] ++ l2) ++ l3 = [] ++ (l2 ++ l3),`
523+
522524
which follows directly from the definition of `++`.
523525
524526
- Next, suppose `l1 = n :: l1'`, with
527+
525528
`(l1' ++ l2) ++ l3 = l1' ++ (l2 ++ l3)`
529+
526530
(the induction hypothesis). We must show
531+
527532
`((n :: l1') ++ l2) ++ l3 = (n :: l1') ++ (l2 ++ l3)`.
533+
528534
By the definition of `++`, this follows from
535+
529536
`n :: ((l1' ++ l2) ++ l 3) = n :: (l1' ++ (l2 ++ l3))`,
537+
530538
which is immediate from the induction hypothesis. $\square$
531539
532540
@@ -596,18 +604,25 @@ Now we can complete the original proof.
596604
For comparison, here are informal proofs of these two theorems:
597605
598606
_Theorem_: For all lists `l1` and `l2`,
607+
599608
`length (l1 ++ l2) = length l1 + length l2`.
600609
601610
_Proof_: By induction on `l1`.
602611
603612
- First, suppose `l1 = []`. We must show
613+
604614
`length ([] ++ l2) = length [] + length l2`,
615+
605616
which follows directly from the definitions of `length` and `++`.
606617
607618
- Next, suppose `l1 = n :: l1'`, with
619+
608620
`length (l1' ++ l2) = length l1' + length l2`.
621+
609622
We must show
623+
610624
`length ((n :: l1') ++ l2) = length (n :: l1') + length l2)`.
625+
611626
This follows directly from the definitions of `length` and `++` together
612627
with the induction hypothesis. $\square$
613628
@@ -893,6 +908,7 @@ We'll also need an equality test for `Id`s:
893908
==== Exercise: 1 star (beq_id_refl)
894909
895910
> beq_id_refl : (x : Id) -> True = beq_id x x
911+
> beq_id_refl x = ?beq_id_refl_rhs
896912
897913
$\square$
898914

0 commit comments

Comments
 (0)