@@ -1091,8 +1091,8 @@ The \idr{MStar''} lemma below (combined with its converse, the \idr{MStar'}
1091
1091
exercise above ), shows that our definition of \idr{Exp_match} for \idr{Star} is
1092
1092
equivalent to the informal one given previously.
1093
1093
1094
- > MStar'' : (s =~ Star re ) ->
1095
- > (ss : List (List t ) **
1094
+ > MStar'' : (s =~ Star re ) ->
1095
+ > (ss : List (List t ) **
1096
1096
> (s = fold (++) ss [], (s': List t ) -> In s' ss -> s' =~ re)
1097
1097
> )
1098
1098
> MStar'' m = ?MStar''_rhs
@@ -1327,13 +1327,13 @@ need in this course. Try to solve this exercise without any help at all.
1327
1327
1328
1328
We say that a list "stutters" if it repeats the same element consecutively. The
1329
1329
property "\idr{Nostutter mylist }" means that \idr{mylist} does not stutter.
1330
- Formulate an inductive definition for \idr{nostutter }. (This is different from
1330
+ Formulate an inductive definition for \idr{Nostutter }. (This is different from
1331
1331
the \idr{NoDup} property in the exercise below; the sequence \idr{[1,4,1]}
1332
1332
repeats but does not stutter.)
1333
1333
1334
1334
> data Nostutter : List t -> Type where
1335
1335
> -- FILL IN HERE
1336
- > RemoveMe : Nostutter [] -- needed for typechecking, shouldn't be empty
1336
+ > RemoveMe : Nostutter [] -- needed for typechecking, data shouldn't be empty
1337
1337
1338
1338
Make sure each of these tests succeeds, but feel free to change the suggested
1339
1339
proof (in comments ) if the given one doesn't work for you . Your definition might
@@ -1414,8 +1414,8 @@ and
1414
1414
[4,3]
1415
1415
```
1416
1416
1417
- Now, suppose we have a set \idr{x }, a function \idr{test : x ->Bool}, and a list
1418
- \idr{l} of type \idr{List x }. Suppose further that \idr{l} is an in-order merge
1417
+ Now, suppose we have a set \idr{t }, a function \idr{test : t ->Bool}, and a list
1418
+ \idr{l} of type \idr{List t }. Suppose further that \idr{l} is an in-order merge
1419
1419
of two lists, \idr{l1} and \idr{l2}, such that every item in \idr{l1} satisfies
1420
1420
\idr{test} and no item in \idr{l2} satisfies \idr{test}. Then \idr{filter test l
1421
1421
= l1}.
@@ -1494,22 +1494,22 @@ Recall the definition of the \idr{In} property from the \idr{Logic} chapter, whi
1494
1494
that a value \idr{x} appears at least once in a list \idr{l}:
1495
1495
1496
1496
```idris
1497
- In : (x : a ) -> (l : List a ) -> Type
1497
+ In : (x : t ) -> (l : List t ) -> Type
1498
1498
In x [] = Void
1499
1499
In x (x' :: xs) = (x' = x) `Either` In x xs
1500
1500
```
1501
1501
1502
- Your first task is to use \idr{In} to define a proposition \idr{Disjoint {x } l1
1502
+ Your first task is to use \idr{In} to define a proposition \idr{Disjoint {t } l1
1503
1503
l2}, which should be provable exactly when \idr{l1} and \idr{l2} are lists (with
1504
- elements of type \idr{x }) that have no elements in common .
1504
+ elements of type \idr{t }) that have no elements in common .
1505
1505
1506
1506
> -- FILL IN HERE
1507
1507
1508
- Next, use \idr{In} to define an inductive proposition \idr{NoDup {x } l}, which
1508
+ Next, use \idr{In} to define an inductive proposition \idr{NoDup {t } l}, which
1509
1509
should be provable exactly when \idr{l} is a list (with elements of type
1510
- \idr{x }) where every member is different from every other . For example ,
1511
- \idr{NoDup {x =Nat} [1,2,3,4]} and \idr{NoDup {x =Bool} []} should be provable,
1512
- while \idr{NoDup {x =Nat} [1,2,1]} and \idr{NoDup {x =Bool} [True,True]} should
1510
+ \idr{t }) where every member is different from every other . For example ,
1511
+ \idr{NoDup {t =Nat} [1,2,3,4]} and \idr{NoDup {t =Bool} []} should be provable,
1512
+ while \idr{NoDup {t =Nat} [1,2,1]} and \idr{NoDup {t =Bool} [True,True]} should
1513
1513
not be .
1514
1514
1515
1515
> -- FILL IN HERE
@@ -1534,12 +1534,12 @@ First prove an easy useful lemma.
1534
1534
> in_split : In x l -> (l1 ** l2 ** l = l1 ++ x :: l2)
1535
1535
> in_split prf = ?in_split_rhs
1536
1536
1537
- Now define a property \idr{Repeats} such that \idr{Repeats {x } l} asserts that
1538
- \idr{l} contains at least one repeated element (of type \idr{x }).
1537
+ Now define a property \idr{Repeats} such that \idr{Repeats {t } l} asserts that
1538
+ \idr{l} contains at least one repeated element (of type \idr{t }).
1539
1539
1540
- > data Repeats : {x : Type} -> List x -> Type where
1540
+ > data Repeats : List t -> Type where
1541
1541
> -- FILL IN HERE
1542
- > RemoveMe' : Repeats [] -- needed for typechecking, shouldn't be empty
1542
+ > RemoveMe' : Repeats [] -- needed for typechecking, data shouldn't be empty
1543
1543
1544
1544
Now, here's a way to formalize the pigeonhole principle . Suppose list \idr{l2}
1545
1545
represents a list of pigeonhole labels , and list \idr{l1} represents the labels
@@ -1552,13 +1552,12 @@ However, it is also possible to make the proof go through _without_ assuming
1552
1552
that \idr{In} is decidable ; if you manage to do this , you will not need the
1553
1553
\idr{excluded_middle} hypothesis.
1554
1554
1555
- > pigeonhole_principle: (l1, l2 : List a ) ->
1556
- > ((x : a) -> In x l1 -> In x l2) ->
1557
- > ((length l2 ) <' (length l1 )) ->
1558
- > Repeats l1
1559
- > pigeonhole_principle l1 l2 f prf = ?pigeonhole_principle_rhs
1555
+ > pigeonhole_principle : ((x : t) -> In x l1 -> In x l2) ->
1556
+ > ((length l2 ) <' (length l1 )) ->
1557
+ > Repeats l1
1558
+ > pigeonhole_principle f prf = ?pigeonhole_principle_rhs
1560
1559
> where
1561
- > excluded_middle : (a : Type) -> a `Either` (Not a )
1560
+ > excluded_middle : (p : Type) -> p `Either` (Not p )
1562
1561
> excluded_middle p = really_believe_me p
1563
1562
1564
1563
$\square$
0 commit comments