@@ -110,8 +110,8 @@ When checking argument n to IndType.Wrong_ev:
110
110
Nat (Expected type)
111
111
`` `
112
112
113
- \ todo[inline]{Edit the explanation, it works fine if you remove the first \ idr{n
114
- -> } in \ idr{Wrong_ev_SS }}
113
+ \ todo[inline]{Edit the explanation, it works fine if you remove the first
114
+ \ idr{n -> } in \ idr{Wrong_ev_SS }}
115
115
116
116
(" Parameter" here is Idris jargon for an argument on the left of the colon in an
117
117
Inductive definition; " index" is used to refer to arguments on the right of the
@@ -223,8 +223,8 @@ generates two subgoals. Even worse, in doing so, it keeps the final goal
223
223
unchanged, failing to provide any useful information for completing the proof.
224
224
225
225
The inversion tactic, on the other hand, can detect (1 ) that the first case does
226
- not apply, and (2 ) that the \ idr{n'} that appears on the \ idr{Ev_SS } case must be the
227
- same as \ idr{n}. This allows us to complete the proof
226
+ not apply, and (2 ) that the \ idr{n'} that appears on the \ idr{Ev_SS } case must
227
+ be the same as \ idr{n}. This allows us to complete the proof
228
228
229
229
> evSS_ev (Ev_SS e') = e'
230
230
>
@@ -283,10 +283,11 @@ trivially.
283
283
284
284
> ev_even Ev_0 = (Z ** Refl )
285
285
286
- Unfortunately , the second case is harder. We need to show \ idr{(k ** S (S n') =
287
- double k}, but the only available assumption is \ idr{e'}, which states that
288
- \ idr{Ev n'} holds. Since this isn't directly useful, it seems that we are stuck
289
- and that performing case analysis on \ idr{Ev n} was a waste of time.
286
+ Unfortunately , the second case is harder. We need to show
287
+ \ idr{(k ** S (S n') = double k}, but the only available assumption is \ idr{e'},
288
+ which states that \ idr{Ev n'} holds. Since this isn't directly useful, it seems
289
+ that we are stuck and that performing case analysis on \ idr{Ev n} was a waste of
290
+ time.
290
291
291
292
If we look more closely at our second goal, however, we can see that something
292
293
interesting happened : By performing case analysis on \idr{Ev n}, we were able to
@@ -335,9 +336,9 @@ Let's try our current lemma again:
335
336
> rewrite cprf in (S k ** Refl )
336
337
>
337
338
338
- Here , we can see that Idris produced an `IH` that corresponds to `E'` , the single
339
- recursive occurrence of ev in its own definition. Since E' mentions n', the
340
- induction hypothesis talks about n', as opposed to n or some other number.
339
+ Here , we can see that Idris produced an `IH` that corresponds to `E'` , the
340
+ single recursive occurrence of ev in its own definition. Since E' mentions n',
341
+ the induction hypothesis talks about n', as opposed to n or some other number.
341
342
342
343
The equivalence between the second and third definitions of evenness now
343
344
follows.
@@ -694,9 +695,9 @@ follows:
694
695
> Star : Reg_exp t -> Reg_exp t
695
696
>
696
697
697
- Note that this definition is _polymorphic_ : Regular expressions in \idr{Reg_exp
698
- t} describe strings with characters drawn from\ idr{t} -- that is, lists of
699
- elements of \ idr{t}.
698
+ Note that this definition is _polymorphic_ : Regular expressions in
699
+ \ idr{ Reg_exp t} describe strings with characters drawn from\ idr{t} -- that is,
700
+ lists of elements of \ idr{t}.
700
701
701
702
(We depart slightly from standard practice in that we do not require the type
702
703
\ idr{t} to be finite. This results in a somewhat different theory of regular
@@ -711,11 +712,11 @@ when a regular expression _matches_ some string:
711
712
712
713
- The expression \ idr{Chr x} matches the one- character string \ idr{[x]}.
713
714
714
- - If \ idr{re1} matches \ idr{s1}, and \ idr{re2} matches \ idr{s2}, then \ idr{ App
715
- re1 re2} matches \ idr{s1 ++ s2}.
715
+ - If \ idr{re1} matches \ idr{s1}, and \ idr{re2} matches \ idr{s2}, then
716
+ \ idr{ App re1 re2} matches \ idr{s1 ++ s2}.
716
717
717
- - If at least one of \ idr{re1} and \ idr{re2} matches \ idr{s}, then \ idr{ Union
718
- re1 re2} matches \ idr{s}.
718
+ - If at least one of \ idr{re1} and \ idr{re2} matches \ idr{s}, then
719
+ \ idr{ Union re1 re2} matches \ idr{s}.
719
720
720
721
- Finally , if we can write some string \ idr{s} as the concatenation of a
721
722
sequence of strings \ idr{s = s_1 ++ ... ++ s_k}, and the expression \ idr{re}
@@ -827,9 +828,9 @@ reg_exp_ex2 = MApp {s1=[1]} {s2=[2]} MChar MChar
827
828
`` `
828
829
829
830
Notice how the last example applies \ idr{MApp } to the strings \ idr{[1 ]} and
830
- \ idr{[2 ]} directly. While the goal mentions \ idr{[1 ,2 ]} instead of \ idr{[ 1 ] ++
831
- [ 2 ]}, Idris is able to figure out how to split the string on its own, so we can
832
- drop the implicits :
831
+ \ idr{[2 ]} directly. While the goal mentions \ idr{[1 ,2 ]} instead of
832
+ \ idr{[ 1 ] ++ [ 2 ]}, Idris is able to figure out how to split the string on its
833
+ own, so we can drop the implicits :
833
834
834
835
> reg_exp_ex2 : [1,2] =~ (App (Chr 1) (Chr 2))
835
836
> reg_exp_ex2 = MApp MChar MChar
@@ -1257,11 +1258,11 @@ parameter of the whole \idr{data} declaration.
1257
1258
1258
1259
The reflect property takes two arguments : a proposition \idr{p} and a boolean
1259
1260
\idr{b}. Intuitively, it states that the property \idr{p} is _reflected_ in
1260
- (i.e., equivalent to ) the boolean \idr{b}: \idr{p} holds if and only if \idr{b =
1261
- True}. To see this, notice that , by definition , the only way we can produce
1262
- evidence that \idr{Reflect p True} holds is by showing that \idr{p} is true and
1263
- using the \idr{ReflectT} constructor. If we invert this statement, this means
1264
- that it should be possible to extract evidence for \idr{p} from a proof of
1261
+ (i.e., equivalent to ) the boolean \idr{b}: \idr{p} holds if and only if
1262
+ \idr{b = True}. To see this, notice that , by definition , the only way we can
1263
+ produce evidence that \idr{Reflect p True} holds is by showing that \idr{p} is
1264
+ true and using the \idr{ReflectT} constructor. If we invert this statement, this
1265
+ means that it should be possible to extract evidence for \idr{p} from a proof of
1265
1266
\idr{Reflect p True}. Conversely, the only way to show \idr{Reflect p False} is
1266
1267
by combining evidence for \idr{Not p } with the \idr{ReflectF} constructor.
1267
1268
@@ -1336,9 +1337,9 @@ Use \idr{beq_natP} as above to prove the following:
1336
1337
$\square$
1337
1338
1338
1339
This technique gives us only a small gain in convenience for the proofs we've
1339
- seen here , but using \idr{Reflect} consistently often leads to noticeably shorter and
1340
- clearer scripts as proofs get larger . We'll see many more examples in later
1341
- chapters.
1340
+ seen here , but using \idr{Reflect} consistently often leads to noticeably
1341
+ shorter and clearer scripts as proofs get larger . We'll see many more examples
1342
+ in later chapters.
1342
1343
1343
1344
\todo[inline]{Add http ://math-comp.github.io/math-comp/ as a link}
1344
1345
@@ -1454,8 +1455,8 @@ and
1454
1455
Now, suppose we have a set \idr{t}, a function \idr{test : t->Bool}, and a list
1455
1456
\idr{l} of type \idr{List t }. Suppose further that \idr{l} is an in-order merge
1456
1457
of two lists, \idr{l1} and \idr{l2}, such that every item in \idr{l1} satisfies
1457
- \idr{test} and no item in \idr{l2} satisfies \idr{test}. Then \idr{ filter test l
1458
- = l1}.
1458
+ \idr{test} and no item in \idr{l2} satisfies \idr{test}. Then
1459
+ \idr{ filter test l = l1}.
1459
1460
1460
1461
Translate this specification into a Idris theorem and prove it . (You'll need to
1461
1462
begin by defining what it means for one list to be a merge of two others . Do
@@ -1531,18 +1532,19 @@ $\square$
1531
1532
1532
1533
=== Exercise: 4 stars , advanced, optional (NoDup)
1533
1534
1534
- Recall the definition of the \idr{In} property from the \idr{Logic} chapter, which asserts
1535
- that a value \idr{x} appears at least once in a list \idr{l}:
1535
+ Recall the definition of the \idr{In} property from the \idr{Logic} chapter,
1536
+ which asserts that a value \idr{x} appears at least once in a list \idr{l}:
1536
1537
1537
1538
```idris
1538
1539
In : (x : t) -> (l : List t ) -> Type
1539
1540
In x [] = Void
1540
1541
In x (x' :: xs) = (x' = x) `Either` In x xs
1541
1542
```
1542
1543
1543
- Your first task is to use \idr{In} to define a proposition \idr{Disjoint {t} l1
1544
- l2}, which should be provable exactly when \idr{l1} and \idr{l2} are lists (with
1545
- elements of type \idr{t}) that have no elements in common .
1544
+ Your first task is to use \idr{In} to define a proposition
1545
+ \idr{Disjoint {t} l1 l2 }, which should be provable exactly when \idr{l1} and
1546
+ \idr{l2} are lists (with elements of type \idr{t}) that have no elements in
1547
+ common.
1546
1548
1547
1549
> -- FILL IN HERE
1548
1550
>
0 commit comments