Skip to content

Commit 11b41c3

Browse files
committed
IndProp: broader whitespace tweaks
1 parent 717b84e commit 11b41c3

File tree

1 file changed

+44
-38
lines changed

1 file changed

+44
-38
lines changed

src/IndProp.lidr

Lines changed: 44 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,14 @@ recursive occurrence of the property in question.
321321
Let's try our current lemma again:
322322

323323
> 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+
>
330332

331333
Here, we can see that Idris produced an `IH` that corresponds to `E'`, the single
332334
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:
925927

926928
> in_app_iff : (In a (l++l')) <-> (In a l `Either` In a l')
927929
> 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+
>
944947

945948
\todo[inline]{Some unfortunate implicit plumbing}
946949

@@ -1193,11 +1196,11 @@ repeated any number of times and the result, when combined with \idr{s1} and
11931196
the empty string, this gives us a (constructive!) way to generate strings
11941197
matching \idr{re} that are as long as we like.
11951198

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+
> ))
12011204

12021205
\todo[inline]{Edit hint}
12031206

@@ -1305,12 +1308,11 @@ the second).
13051308

13061309
> beq_nat_true_iff : (n1, n2 : Nat) -> (beq_nat n1 n2 = True) <-> (n1 = n2)
13071310
> 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
13141316
>
13151317
> iff_sym : (p <-> q) -> (q <-> p)
13161318
> iff_sym (pq, qp) = (qp, pq)
@@ -1333,14 +1335,18 @@ case of the destruct.)
13331335
> filter_not_empty_In' {l=[]} contra = contra Refl
13341336
> filter_not_empty_In' {n} {l=(x::xs)} contra with (beq_natP {n} {m=x})
13351337
> 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
13371340

13381341
\todo[inline]{How to rewrite more neatly here?}
13391342

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'
13441350
>
13451351

13461352

0 commit comments

Comments
 (0)