Skip to content

Commit 218aeb2

Browse files
author
Alex Gryzlov
committed
remove duplication
1 parent 13fdd3c commit 218aeb2

File tree

1 file changed

+21
-23
lines changed

1 file changed

+21
-23
lines changed

src/IndPrinciples.lidr

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
= IndPrinciples : Induction Principles
22

33
> module IndPrinciples
4-
4+
>
5+
> import IndProp
6+
>
57
> %access public export
68
> %default total
9+
>
710

811
With the Curry-Howard correspondence and its realization in Idris in mind, we
912
can now take a deeper look at induction principles.
1013

14+
\ \todo[inline]{We've written all induction principles by hand throughout the
15+
chapter, Idris doesn't generate them. Edit the text to reflect this}
1116

12-
== Basics
1317

14-
\ \todo[inline]{Edit, this is probably also made redundant by pattern matching}
18+
== Basics
1519

1620
Every time we declare a new \idr{data} type, Idris automatically generates an
1721
_induction principle_ for this type. This induction principle is a theorem like
@@ -433,11 +437,11 @@ evidence.
433437
For example, from what we've said so far, you might expect the inductive
434438
definition of \idr{Ev}...
435439

436-
\todo[inline]{Redefine for now}
437-
438-
> data Ev : Nat -> Type where
439-
> Ev_0 : Ev Z
440-
> Ev_SS : Ev n -> Ev (S (S n))
440+
```idris
441+
data Ev : Nat -> Type where
442+
Ev_0 : Ev Z
443+
Ev_SS : Ev n -> Ev (S (S n))
444+
```
441445

442446
...to give rise to an induction principle that looks like this...
443447

@@ -510,13 +514,6 @@ example, we can use it to show that \idr{Ev'} (the slightly awkward alternate
510514
definition of evenness that we saw in an exercise in the `IndProp` chapter)
511515
is equivalent to the cleaner inductive definition \idr{Ev}:
512516

513-
\todo[inline]{Copy here for now}
514-
515-
> data Ev' : Nat -> Type where
516-
> Ev'_0 : Ev' Z
517-
> Ev'_2 : Ev' 2
518-
> Ev'_sum : Ev' n -> Ev' m -> Ev' (n + m)
519-
520517
> ev_ev' : Ev n -> Ev' n
521518
> ev_ev' {n} = ev_ind {P=Ev'}
522519
> Ev'_0
@@ -539,13 +536,13 @@ argument \idr{n} is the same everywhere in the definition, so we can actually
539536
make it a "general parameter" to the whole definition, rather than an argument
540537
to each constructor.
541538

542-
\todo[inline]{This doesn't seem to change anything}
543-
544-
> data Le : (n:Nat) -> Nat -> Type where
545-
> Le_n : Le n n
546-
> Le_S : Le n m -> Le n (S m)
539+
\todo[inline]{This doesn't actually seem to change anything in our case}
547540

548-
> syntax [m] "<='" [n] = Le m n
541+
```idris
542+
data Le : (n:Nat) -> Nat -> Type where
543+
Le_n : Le n n
544+
Le_S : Le n m -> Le n (S m)
545+
```
549546

550547
The second one is better, even though it looks less symmetric. Why? Because it
551548
gives us a simpler induction principle.
@@ -655,8 +652,9 @@ this form of proof is also known as _induction on derivations_.
655652

656653
_Template_:
657654

658-
- _Theorem_: <Proposition of the form "\idr{Q -> P}," where \idr{Q} is some inductively
659-
defined proposition (more generally, "For all \idr{x} \idr{y} \idr{z}, \idr{Q x y z -> P x y z}")>
655+
- _Theorem_: <Proposition of the form "\idr{Q -> P}," where \idr{Q} is some
656+
inductively defined proposition (more generally, "For all \idr{x} \idr{y}
657+
\idr{z}, \idr{Q x y z -> P x y z}")>
660658

661659
_Proof_: By induction on a derivation of \idr{Q}. <Or, more generally,
662660
"Suppose we are given \idr{x}, \idr{y}, and \idr{z}. We show that

0 commit comments

Comments
 (0)