@@ -321,12 +321,14 @@ recursive occurrence of the property in question.
321
321
Let's try our current lemma again :
322
322
323
323
> ev_even' : Ev n -> (k ** n = double k)
324
- > ev_even' Ev_0 = (Z ** Refl )
325
- > ev_even' (Ev_SS e') = let
326
- > (k** prf) = ev_even e'
327
- > cprf = cong {f= S } $ cong {f= S } prf
328
- > in
329
- > rewrite cprf in (S k ** Refl )
324
+ > ev_even' Ev_0 = (Z ** Refl )
325
+ > ev_even' (Ev_SS e') =
326
+ > let
327
+ > (k** prf) = ev_even e'
328
+ > cprf = cong {f= S } $ cong {f= S } prf
329
+ > in
330
+ > rewrite cprf in (S k ** Refl )
331
+ >
330
332
331
333
Here , we can see that Idris produced an `IH` that corresponds to `E'` , the single
332
334
recursive occurrence of ev in its own definition. Since E' mentions n', the
@@ -925,22 +927,23 @@ We can then phrase our theorem as follows:
925
927
926
928
> in_app_iff : (In a (l++l')) <-> (In a l `Either ` In a l')
927
929
> in_app_iff {l} {l'} = (to l l', fro l l')
928
- > where
929
- > to : (l, l' : List x) -> In a (l ++ l') -> (In a l) `Either ` (In a l')
930
- > to [] [] prf = absurd prf
931
- > to [] _ prf = Right prf
932
- > to (_ :: _ ) _ (Left Refl ) = Left $ Left Refl
933
- > to (_ :: xs) l' (Right prf) =
934
- > case to xs l' prf of
935
- > Left ixs => Left $ Right ixs
936
- > Right il' => Right il'
937
- > fro : (l, l' : List x) -> (In a l) `Either ` (In a l') -> In a (l ++ l')
938
- > fro [] _ (Left prf) = absurd prf
939
- > fro (_ :: _ ) _ (Left (Left Refl )) = Left Refl
940
- > fro (_ :: xs) l' (Left (Right prf)) = Right $ fro xs l' (Left prf)
941
- > fro _ [] (Right prf) = absurd prf
942
- > fro [] _ (Right prf) = prf
943
- > fro (_ :: ys) l' prf@(Right _ ) = Right $ fro ys l' prf
930
+ > where
931
+ > to : (l, l' : List x) -> In a (l ++ l') -> (In a l) `Either ` (In a l')
932
+ > to [] [] prf = absurd prf
933
+ > to [] _ prf = Right prf
934
+ > to (_ :: _ ) _ (Left Refl ) = Left $ Left Refl
935
+ > to (_ :: xs) l' (Right prf) =
936
+ > case to xs l' prf of
937
+ > Left ixs => Left $ Right ixs
938
+ > Right il' => Right il'
939
+ > fro : (l, l' : List x) -> (In a l) `Either ` (In a l') -> In a (l ++ l')
940
+ > fro [] _ (Left prf) = absurd prf
941
+ > fro (_ :: _ ) _ (Left (Left Refl )) = Left Refl
942
+ > fro (_ :: xs) l' (Left (Right prf)) = Right $ fro xs l' (Left prf)
943
+ > fro _ [] (Right prf) = absurd prf
944
+ > fro [] _ (Right prf) = prf
945
+ > fro (_ :: ys) l' prf@(Right _ ) = Right $ fro ys l' prf
946
+ >
944
947
945
948
\ todo[inline]{Some unfortunate implicit plumbing}
946
949
@@ -1193,11 +1196,11 @@ repeated any number of times and the result, when combined with \idr{s1} and
1193
1196
the empty string, this gives us a (constructive!) way to generate strings
1194
1197
matching \idr{re} that are as long as we like.
1195
1198
1196
- > pumping : (s =~ re) -> ((pumping_constant re ) <=' (length s ))
1197
- > -> (s1 ** s2 ** s3 ** ( s = s1 ++ s2 ++ s3
1198
- > , Not (s2 = [])
1199
- > , (m:Nat) -> (s1 ++ napp m s2 ++ s3) =~ re
1200
- > ))
1199
+ > pumping : (s =~ re) -> ((pumping_constant re ) <=' (length s )) ->
1200
+ > (s1 ** s2 ** s3 ** ( s = s1 ++ s2 ++ s3
1201
+ > , Not (s2 = [])
1202
+ > , (m:Nat) -> (s1 ++ napp m s2 ++ s3) =~ re
1203
+ > ))
1201
1204
1202
1205
\todo[inline]{Edit hint }
1203
1206
@@ -1305,12 +1308,11 @@ the second).
1305
1308
1306
1309
> beq_nat_true_iff : (n1, n2 : Nat) -> (beq_nat n1 n2 = True) <-> (n1 = n2)
1307
1310
> beq_nat_true_iff n1 n2 = (to, fro n1 n2)
1308
- > where
1309
- > to : (beq_nat n1 n2 = True) -> (n1 = n2)
1310
- > to = beq_nat_true {n=n1} {m=n2}
1311
- > fro : (n1, n2 : Nat) -> (n1 = n2) -> (beq_nat n1 n2 = True)
1312
- > fro n1 n1 Refl = sym $ beq_nat_refl n1
1313
-
1311
+ > where
1312
+ > to : (beq_nat n1 n2 = True) -> (n1 = n2)
1313
+ > to = beq_nat_true {n=n1} {m=n2}
1314
+ > fro : (n1, n2 : Nat) -> (n1 = n2) -> (beq_nat n1 n2 = True)
1315
+ > fro n1 n1 Refl = sym $ beq_nat_refl n1
1314
1316
>
1315
1317
> iff_sym : (p <-> q) -> (q <-> p)
1316
1318
> iff_sym (pq, qp) = (qp, pq)
@@ -1333,14 +1335,18 @@ case of the destruct.)
1333
1335
> filter_not_empty_In' {l=[]} contra = contra Refl
1334
1336
> filter_not_empty_In' {n} {l=(x::xs)} contra with (beq_natP {n} {m=x})
1335
1337
> filter_not_empty_In' _ | (ReflectT eq _) = Left $ sym eq
1336
- > filter_not_empty_In' {n} {l=(x::xs)} contra | (ReflectF _ notbeq) = let
1338
+ > filter_not_empty_In' {n} {l=(x::xs)} contra | (ReflectF _ notbeq) =
1339
+ > let
1337
1340
1338
1341
\todo[inline]{How to rewrite more neatly here ?}
1339
1342
1340
- > contra' = replace notbeq contra {P = \a => Not ((if a
1341
- > then x :: filter (beq_nat n ) xs
1342
- > else filter (beq_nat n ) xs) = [])}
1343
- > in Right $ filter_not_empty_In' contra'
1343
+ > contra' = replace notbeq contra
1344
+ > {P = \a =>
1345
+ > Not ((if a
1346
+ > then x :: filter (beq_nat n ) xs
1347
+ > else filter (beq_nat n ) xs) = [])}
1348
+ > in
1349
+ > Right $ filter_not_empty_In' contra'
1344
1350
>
1345
1351
1346
1352
0 commit comments