@@ -299,7 +299,7 @@ existing definition, and \idr{infixl} specifies left-associative fixity.
299
299
>
300
300
301
301
302
- === Exercise: 1 star (nandb)
302
+ ==== Exercise: 1 star (nandb)
303
303
304
304
Fill in the hole \idr{?nandb_rhs} and complete the following function; then make
305
305
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}.
325
325
$\square$
326
326
327
327
328
- === Exercise: 1 star (andb3)
328
+ ==== Exercise: 1 star (andb3)
329
329
330
330
Do the same for the \idr{andb3} function below . This function should return
331
331
\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.
576
576
>
577
577
578
578
579
- === Exercise: 1 star (factorial)
579
+ ==== Exercise: 1 star (factorial)
580
580
581
581
Recall the standard mathematical factorial function :
582
582
@@ -634,27 +634,29 @@ yielding a \idr{b}oolean.
634
634
> beq_nat (S k ) (S j ) = beq_nat k j
635
635
>
636
636
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
638
638
its second argument, yielding a boolean.
639
639
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
648
650
>
649
- > testLeb2 : leb 2 4 = True
650
- > testLeb2 = Refl
651
+ > testLte2 : lte 2 4 = True
652
+ > testLte2 = Refl
651
653
>
652
- > testLeb3 : leb 4 2 = False
653
- > testLeb3 = Refl
654
+ > testLte3 : lte 4 2 = False
655
+ > testLte3 = Refl
654
656
>
655
657
656
658
657
- === Exercise: 1 star (blt_nat)
659
+ ==== Exercise: 1 star (blt_nat)
658
660
659
661
The \idr{blt_nat} function tests \idr{Nat}ural numbers for
660
662
\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
780
782
left side of the equality hypothesis \idr{prf} with the right side .
781
783
782
784
783
- === Exercise: 1 star (plus_id_exercise)
785
+ ==== Exercise: 1 star (plus_id_exercise)
784
786
785
787
Fill in the proof .
786
788
@@ -816,7 +818,7 @@ Unlike in Coq, we don't need to perform such a rewrite for \idr{mult_0_plus} in
816
818
Idris and can just use \idr{Refl} instead.
817
819
818
820
819
- === Exercise: 2 starts (mult_S_1)
821
+ ==== Exercise: 2 starts (mult_S_1)
820
822
821
823
> mult_S_1 : (n, m : Nat) -> (m = S n ) -> m * (1 + n) = m * m
822
824
> 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:
920
922
>
921
923
922
924
923
- === Exercise: 2 stars (andb_true_elim2)
925
+ ==== Exercise: 2 stars (andb_true_elim2)
924
926
925
927
Prove the following claim , lift cases (and subcases ) to lemmas when case split.
926
928
@@ -931,7 +933,7 @@ Prove the following claim, lift cases (and subcases) to lemmas when case split.
931
933
$\square$
932
934
933
935
934
- === Exercise: 1 star (zero_nbeq_plus_1)
936
+ ==== Exercise: 1 star (zero_nbeq_plus_1)
935
937
936
938
> zero_nbeq_plus_1 : (n : Nat) -> beq_nat 0 (n + 1) = False
937
939
> zero_nbeq_plus_1 n = ?zero_nbeq_plus_1_rhs
@@ -973,7 +975,8 @@ unnatural ways.
973
975
974
976
== More Exercises
975
977
976
- === Exercise: 2 stars (boolean_functions)
978
+
979
+ ==== Exercise: 2 stars (boolean_functions)
977
980
978
981
Use the tactics you have learned so far to prove the following theorem about
979
982
boolean functions .
@@ -994,7 +997,7 @@ the property that \idr{f x = negb x}.
994
997
$\square$
995
998
996
999
997
- === Exercise: 2 start (andb_eq_orb)
1000
+ ==== Exercise: 2 start (andb_eq_orb)
998
1001
999
1002
Prove the following theorem . (You may want to first prove a subsidiary lemma or
1000
1003
two. Alternatively, remember that you do not have to introduce all hypotheses at
@@ -1006,7 +1009,7 @@ the same time.)
1006
1009
$\square$
1007
1010
1008
1011
1009
- === Exercise: 3 stars (binary)
1012
+ ==== Exercise: 3 stars (binary)
1010
1013
1011
1014
Consider a different, more efficient representation of natural numbers using a
1012
1015
binary rather than unary system. That is , instead of saying that each natural
0 commit comments