Skip to content

Commit ce2dbbc

Browse files
author
Alex Gryzlov
committed
fix formatting, remove leb
1 parent 9a9592c commit ce2dbbc

File tree

5 files changed

+532
-488
lines changed

5 files changed

+532
-488
lines changed

src/Basics.lidr

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ existing definition, and \idr{infixl} specifies left-associative fixity.
299299
>
300300

301301

302-
=== Exercise: 1 star (nandb)
302+
==== Exercise: 1 star (nandb)
303303

304304
Fill in the hole \idr{?nandb_rhs} and complete the following function; then make
305305
sure that the assertions below can each be verified by Idris. (Fill in each of
@@ -325,7 +325,7 @@ should return \idr{True} if either or both of its inputs are \idr{False}.
325325
$\square$
326326

327327

328-
=== Exercise: 1 star (andb3)
328+
==== Exercise: 1 star (andb3)
329329

330330
Do the same for the \idr{andb3} function below. This function should return
331331
\idr{True} when all of its inputs are \idr{True}, and \idr{False} otherwise.
@@ -576,7 +576,7 @@ right-hand side. This avoids the need to invent a bogus variable name.
576576
>
577577

578578

579-
=== Exercise: 1 star (factorial)
579+
==== Exercise: 1 star (factorial)
580580

581581
Recall the standard mathematical factorial function:
582582

@@ -634,27 +634,29 @@ yielding a \idr{b}oolean.
634634
> beq_nat (S k) (S j) = beq_nat k j
635635
>
636636

637-
The \idr{leb} function tests whether its first argument is less than or equal to
637+
The \idr{lte} function tests whether its first argument is less than or equal to
638638
its second argument, yielding a boolean.
639639

640-
> ||| Test whether a number is less than or equal to another.
641-
> leb : (n, m : Nat) -> Bool
642-
> leb Z m = True
643-
> leb (S k) Z = False
644-
> leb (S k) (S j) = leb k j
645-
>
646-
> testLeb1 : leb 2 2 = True
647-
> testLeb1 = Refl
640+
```idris
641+
||| Test whether a number is less than or equal to another.
642+
lte : (n, m : Nat) -> Bool
643+
lte Z m = True
644+
lte n Z = False
645+
lte (S k) (S j) = lte k j
646+
```
647+
648+
> testLte1 : lte 2 2 = True
649+
> testLte1 = Refl
648650
>
649-
> testLeb2 : leb 2 4 = True
650-
> testLeb2 = Refl
651+
> testLte2 : lte 2 4 = True
652+
> testLte2 = Refl
651653
>
652-
> testLeb3 : leb 4 2 = False
653-
> testLeb3 = Refl
654+
> testLte3 : lte 4 2 = False
655+
> testLte3 = Refl
654656
>
655657

656658

657-
=== Exercise: 1 star (blt_nat)
659+
==== Exercise: 1 star (blt_nat)
658660

659661
The \idr{blt_nat} function tests \idr{Nat}ural numbers for
660662
\idr{l}ess-\idr{t}han, yielding a \idr{b}oolean. Instead of making up a new
@@ -780,7 +782,7 @@ tells Idris to rewrite the current goal (\idr{n + n = m + m}) by replacing the
780782
left side of the equality hypothesis \idr{prf} with the right side.
781783

782784

783-
=== Exercise: 1 star (plus_id_exercise)
785+
==== Exercise: 1 star (plus_id_exercise)
784786

785787
Fill in the proof.
786788

@@ -816,7 +818,7 @@ Unlike in Coq, we don't need to perform such a rewrite for \idr{mult_0_plus} in
816818
Idris and can just use \idr{Refl} instead.
817819

818820

819-
=== Exercise: 2 starts (mult_S_1)
821+
==== Exercise: 2 starts (mult_S_1)
820822

821823
> mult_S_1 : (n, m : Nat) -> (m = S n) -> m * (1 + n) = m * m
822824
> mult_S_1 n m prf = ?mult_S_1_rhs
@@ -920,7 +922,7 @@ In more complex proofs, it is often better to lift subgoals to lemmas:
920922
>
921923

922924

923-
=== Exercise: 2 stars (andb_true_elim2)
925+
==== Exercise: 2 stars (andb_true_elim2)
924926

925927
Prove the following claim, lift cases (and subcases) to lemmas when case split.
926928

@@ -931,7 +933,7 @@ Prove the following claim, lift cases (and subcases) to lemmas when case split.
931933
$\square$
932934

933935

934-
=== Exercise: 1 star (zero_nbeq_plus_1)
936+
==== Exercise: 1 star (zero_nbeq_plus_1)
935937

936938
> zero_nbeq_plus_1 : (n : Nat) -> beq_nat 0 (n + 1) = False
937939
> zero_nbeq_plus_1 n = ?zero_nbeq_plus_1_rhs
@@ -973,7 +975,8 @@ unnatural ways.
973975

974976
== More Exercises
975977

976-
=== Exercise: 2 stars (boolean_functions)
978+
979+
==== Exercise: 2 stars (boolean_functions)
977980

978981
Use the tactics you have learned so far to prove the following theorem about
979982
boolean functions.
@@ -994,7 +997,7 @@ the property that \idr{f x = negb x}.
994997
$\square$
995998

996999

997-
=== Exercise: 2 start (andb_eq_orb)
1000+
==== Exercise: 2 start (andb_eq_orb)
9981001

9991002
Prove the following theorem. (You may want to first prove a subsidiary lemma or
10001003
two. Alternatively, remember that you do not have to introduce all hypotheses at
@@ -1006,7 +1009,7 @@ the same time.)
10061009
$\square$
10071010

10081011

1009-
=== Exercise: 3 stars (binary)
1012+
==== Exercise: 3 stars (binary)
10101013

10111014
Consider a different, more efficient representation of natural numbers using a
10121015
binary rather than unary system. That is, instead of saying that each natural

src/IndProp.lidr

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ Prove that this definition is logically equivalent to the old one. (You may want
385385
to look at the previous theorem when you get to the induction step.)
386386

387387
> ev'_ev : (Ev' n) <-> Ev n
388-
> ev'_ev = ?ev'_ev_rhs
388+
> ev'_ev = ?ev__ev_rhs
389389
>
390390

391391
$\square$
@@ -530,27 +530,27 @@ are going to need later in the course. The proofs make good practice exercises.
530530
> lt_S : (n <' m) -> (n <' S m)
531531
> lt_S x = ?lt_S_rhs
532532
>
533-
> leb_complete : leb n m = True -> (n <=' m)
534-
> leb_complete prf = ?leb_complete_rhs
533+
> lte_complete : lte n m = True -> (n <=' m)
534+
> lte_complete prf = ?lte_complete_rhs
535535
>
536536

537537
Hint: The next one may be easiest to prove by induction on \idr{m}.
538538

539-
> leb_correct : (n <=' m) -> leb n m = True
540-
> leb_correct x = ?leb_correct_rhs
539+
> lte_correct : (n <=' m) -> lte n m = True
540+
> lte_correct x = ?lte_correct_rhs
541541
>
542542

543543
Hint: This theorem can easily be proved without using induction.
544544

545-
> leb_true_trans : leb n m = True -> leb m o = True -> leb n o = True
546-
> leb_true_trans prf prf1 = ?leb_true_trans_rhs
545+
> lte_true_trans : lte n m = True -> lte m o = True -> lte n o = True
546+
> lte_true_trans prf prf1 = ?lte_true_trans_rhs
547547
>
548548

549549

550-
==== Exercise: 2 stars, optional (leb_iff)
550+
==== Exercise: 2 stars, optional (lte_iff)
551551

552-
> leb_iff : (leb n m = True) <-> (n <=' m)
553-
> leb_iff = ?leb_iff_rhs
552+
> lte_iff : (lte n m = True) <-> (n <=' m)
553+
> lte_iff = ?lte_iff_rhs
554554
>
555555

556556
$\square$
@@ -886,7 +886,7 @@ beginning of the chapter can be obtained from the formal inductive definition.
886886
> empty_is_empty = ?empty_is_empty_rhs
887887
>
888888
> MUnion' : (s =~ re1, s =~ re2) -> s =~ Union re1 re2
889-
> MUnion' m = ?MUnion'_rhs
889+
> MUnion' m = ?MUnion__rhs
890890
>
891891

892892
The next lemma is stated in terms of the \idr{fold} function from the \idr{Poly}
@@ -906,7 +906,7 @@ together.
906906
>
907907
> MStar' : ((s : List t) -> (In s ss) -> (s =~ re)) ->
908908
> (fold (++) ss []) =~ Star re
909-
> MStar' f = ?MStar'_rhs
909+
> MStar' f = ?MStar__rhs
910910
>
911911

912912
$\square$
@@ -1162,7 +1162,7 @@ equivalent to the informal one given previously.
11621162
> (ss : List (List t) **
11631163
> (s = fold (++) ss [], (s': List t) -> In s' ss -> s' =~ re)
11641164
> )
1165-
> MStar'' m = ?MStar''_rhs
1165+
> MStar'' m = ?MStar___rhs
11661166
>
11671167

11681168
$\square$

0 commit comments

Comments
 (0)