Skip to content

Commit 84f7366

Browse files
authored
Changes explicit argument y to implicit in Induction.WellFounded.WfRec (#2084)
1 parent 20ab77f commit 84f7366

File tree

23 files changed

+158
-132
lines changed

23 files changed

+158
-132
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,21 @@ Non-backwards compatible changes
585585
Prime n = ∀ {d} → 2 ≤ d → d < n → d ∤ n
586586
```
587587

588+
### Change to the definition of `Induction.WellFounded.WfRec` (issue #2083)
589+
590+
* Previously, the following definition was adopted
591+
```agda
592+
WfRec : Rel A r → ∀ {ℓ} → RecStruct A ℓ _
593+
WfRec _<_ P x = ∀ y → y < x → P y
594+
```
595+
with the consequence that all arguments involving about accesibility and
596+
wellfoundedness proofs were polluted by almost-always-inferrable explicit
597+
arguments for the `y` position. The definition has now been changed to
598+
make that argument *implicit*, as
599+
```agda
600+
WfRec : Rel A r → ∀ {ℓ} → RecStruct A ℓ _
601+
WfRec _<_ P x = ∀ {y} → y < x → P y
602+
588603
### Change in the definition of `_≤″_` (issue #1919)
589604
590605
* The definition of `_≤″_` in `Data.Nat.Base` was previously:

README/Data/Nat/Induction.agda

+16-8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ open import Function.Base using (_∘_)
1414
open import Induction.WellFounded
1515
open import Relation.Binary.PropositionalEquality
1616

17+
private
18+
19+
n<′1+n : {n} n <′ suc n
20+
n<′1+n = ≤′-refl
21+
22+
n<′2+n : {n} n <′ suc (suc n)
23+
n<′2+n = ≤′-step ≤′-refl
24+
1725
-- Doubles its input.
1826

1927
twice :
@@ -46,7 +54,7 @@ mutual
4654
half₂-step = λ
4755
{ zero _ zero
4856
; (suc zero) _ zero
49-
; (suc (suc n)) rec suc (rec n (≤′-step ≤′-refl))
57+
; (suc (suc n)) rec suc (rec n<′2+n)
5058
}
5159

5260
half₂ :
@@ -92,21 +100,21 @@ half₂-2+ n = begin
92100

93101
half₂-step (2 + n) (<′-recBuilder _ half₂-step (2 + n)) ≡⟨⟩
94102

95-
1 + <′-recBuilder _ half₂-step (2 + n) n (≤′-step ≤′-refl) ≡⟨⟩
103+
1 + <′-recBuilder _ half₂-step (2 + n) n<′2+n ≡⟨⟩
96104

97105
1 + Some.wfRecBuilder _ half₂-step (2 + n)
98-
(<′-wellFounded (2 + n)) n (≤′-step ≤′-refl) ≡⟨⟩
106+
(<′-wellFounded (2 + n)) n<′2+n ≡⟨⟩
99107

100108
1 + Some.wfRecBuilder _ half₂-step (2 + n)
101-
(acc (<′-wellFounded′ (2 + n))) n (≤′-step ≤′-refl) ≡⟨⟩
109+
(acc (<′-wellFounded′ (2 + n))) n<′2+n ≡⟨⟩
102110

103111
1 + half₂-step n
104112
(Some.wfRecBuilder _ half₂-step n
105-
(<′-wellFounded′ (2 + n) n (≤′-step ≤′-refl))) ≡⟨⟩
113+
(<′-wellFounded′ (2 + n) n<′2+n)) ≡⟨⟩
106114

107115
1 + half₂-step n
108116
(Some.wfRecBuilder _ half₂-step n
109-
(<′-wellFounded′ (1 + n) n ≤′-refl)) ≡⟨⟩
117+
(<′-wellFounded′ (1 + n) n<′1+n)) ≡⟨⟩
110118

111119
1 + half₂-step n
112120
(Some.wfRecBuilder _ half₂-step n (<′-wellFounded n)) ≡⟨⟩
@@ -146,14 +154,14 @@ half₁-+₂ = <′-rec _ λ
146154
{ zero _ refl
147155
; (suc zero) _ refl
148156
; (suc (suc n)) rec
149-
cong (suc ∘ suc) (rec n (≤′-step ≤′-refl))
157+
cong (suc ∘ suc) (rec n<′2+n)
150158
}
151159

152160
half₂-+₂ : n half₂ (twice n) ≡ n
153161
half₂-+₂ = <′-rec _ λ
154162
{ zero _ refl
155163
; (suc zero) _ refl
156164
; (suc (suc n)) rec
157-
cong (suc ∘ suc) (rec n (≤′-step ≤′-refl))
165+
cong (suc ∘ suc) (rec n<′2+n)
158166
}
159167

src/Codata/Musical/Colist/Infinite-merge.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ Any-merge {P = P} xss = mk↔ₛ′ (proj₁ ∘ to xss) from to∘from (proj₂
195195
... | inj₂ q | P.refl | q≤p =
196196
Prod.map there
197197
(P.cong (there ∘ (Inverse.from (Any-⋎P xs)) ∘ inj₂))
198-
(rec (♭ xss , q) (s≤′s q≤p))
198+
(rec (s≤′s q≤p))
199199

200200
to∘from = λ p from-injective _ _ (proj₂ (to xss (from p)))
201201

src/Data/Bool/Properties.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ true <? _ = no (λ())
195195
<-wellFounded : WellFounded _<_
196196
<-wellFounded _ = acc <-acc
197197
where
198-
<-acc : {x} y y < x Acc _<_ y
199-
<-acc false f<t = acc (λ _ λ())
198+
<-acc : {x y} y < x Acc _<_ y
199+
<-acc f<t = acc λ ()
200200

201201
-- Structures
202202

src/Data/Digit.agda

+3-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ toNatDigits base@(suc (suc _)) n = aux (<-wellFounded-fast n) []
5656
aux {zero} _ xs = (0 ∷ xs)
5757
aux {n@(suc _)} (acc wf) xs with does (0 <? n / base)
5858
... | false = (n % base) ∷ xs
59-
... | true = aux (wf (n / base) q<n) ((n % base) ∷ xs)
59+
... | true = aux (wf q<n) ((n % base) ∷ xs)
6060
where
6161
q<n : n / base < n
6262
q<n = m/n<m n base (s<s z<s)
@@ -107,9 +107,8 @@ toDigits base@(suc (suc k)) n = <′-rec Pred helper n
107107

108108
helper : n <′-Rec Pred n Pred n
109109
helper n rec with n divMod base
110-
helper .(toℕ r + 0 * base) rec | result zero r refl = ([ r ] , refl)
111-
helper .(toℕ r + suc x * base) rec | result (suc x) r refl =
112-
cons r (rec (suc x) (lem x k (toℕ r)))
110+
... | result zero r eq = ([ r ] , P.sym eq)
111+
... | result (suc x) r refl = cons r (rec (lem x k (toℕ r)))
113112

114113
------------------------------------------------------------------------
115114
-- Showing digits

src/Data/Fin/Induction.agda

+11-12
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ open WF public using (Acc; acc)
6565
induct {suc j} (acc rs) (tri< (s≤s i≤j) _ _) _ = Pᵢ⇒Pᵢ₊₁ j P[1+j]
6666
where
6767
toℕj≡toℕinjJ = sym $ toℕ-inject₁ j
68-
P[1+j] = induct (rs _ (s≤s (subst (ℕ._≤ toℕ j) toℕj≡toℕinjJ ≤-refl)))
68+
P[1+j] = induct (rs (s≤s (subst (ℕ._≤ toℕ j) toℕj≡toℕinjJ ≤-refl)))
6969
(<-cmp i $ inject₁ j) (subst (toℕ i ℕ.≤_) toℕj≡toℕinjJ i≤j)
7070

7171
<-weakInduction : (P : Pred (Fin (suc n)) ℓ)
@@ -80,8 +80,7 @@ open WF public using (Acc; acc)
8080

8181
private
8282
acc-map : {x : Fin n} Acc ℕ._<_ (n ∸ toℕ x) Acc _>_ x
83-
acc-map {n} (acc rs) = acc λ y y>x
84-
acc-map (rs (n ∸ toℕ y) (ℕ.∸-monoʳ-< y>x (toℕ≤n y)))
83+
acc-map (acc rs) = acc λ y>x acc-map (rs (ℕ.∸-monoʳ-< y>x (toℕ≤n _)))
8584

8685
>-wellFounded : WellFounded {A = Fin n} _>_
8786
>-wellFounded {n} x = acc-map (ℕ.<-wellFounded (n ∸ toℕ x))
@@ -96,7 +95,7 @@ private
9695
induct {i} (acc rec) with n ℕ.≟ toℕ i
9796
... | yes n≡i = subst P (toℕ-injective (trans (toℕ-fromℕ n) n≡i)) Pₙ
9897
... | no n≢i = subst P (inject₁-lower₁ i n≢i) (Pᵢ₊₁⇒Pᵢ _ Pᵢ₊₁)
99-
where Pᵢ₊₁ = induct (rec _ (ℕ.≤-reflexive (cong suc (sym (toℕ-lower₁ i n≢i)))))
98+
where Pᵢ₊₁ = induct (rec (ℕ.≤-reflexive (cong suc (sym (toℕ-lower₁ i n≢i)))))
10099

101100
------------------------------------------------------------------------
102101
-- Well-foundedness of other (strict) partial orders on Fin
@@ -112,20 +111,20 @@ module _ {_≈_ : Rel (Fin n) ℓ} where
112111

113112
spo-wellFounded : {r} {_⊏_ : Rel (Fin n) r}
114113
IsStrictPartialOrder _≈_ _⊏_ WellFounded _⊏_
115-
spo-wellFounded {_} {_⊏_} isSPO i = go n i pigeon where
114+
spo-wellFounded {_} {_⊏_} isSPO i = go n pigeon where
116115

117116
module = IsStrictPartialOrder isSPO
118117

119-
go : m i
120-
((xs : Vec (Fin n) m) Linked (flip _⊏_) (i ∷ xs) WellFounded _⊏_)
118+
go : m {i}
119+
({xs : Vec (Fin n) m} Linked (flip _⊏_) (i ∷ xs) WellFounded _⊏_)
121120
Acc _⊏_ i
122-
go zero i k = k [] [-] i
123-
go (suc m) i k = acc $ λ j j⊏i go m j (λ xs i∷xs↑ k (j ∷ xs) (j⊏i ∷ i∷xs↑))
121+
go zero k = k [-] _
122+
go (suc m) k = acc λ j⊏i go m λ i∷xs↑ k (j⊏i ∷ i∷xs↑)
124123

125-
pigeon : (xs : Vec (Fin n) n) Linked (flip _⊏_) (i ∷ xs) WellFounded _⊏_
126-
pigeon xs i∷xs↑ =
124+
pigeon : {xs : Vec (Fin n) n} Linked (flip _⊏_) (i ∷ xs) WellFounded _⊏_
125+
pigeon {xs} i∷xs↑ =
127126
let (i₁ , i₂ , i₁<i₂ , xs[i₁]≡xs[i₂]) = pigeonhole (n<1+n n) (Vec.lookup (i ∷ xs)) in
128-
let xs[i₁]⊏xs[i₂] = Linkedₚ.lookup⁺ (Ord.transitive _⊏_ ⊏.trans) {xs = i ∷ xs} i∷xs↑ i₁<i₂ in
127+
let xs[i₁]⊏xs[i₂] = Linkedₚ.lookup⁺ (Ord.transitive _⊏_ ⊏.trans) i∷xs↑ i₁<i₂ in
129128
let xs[i₁]⊏xs[i₁] = ⊏.<-respʳ-≈ (⊏.Eq.reflexive xs[i₁]≡xs[i₂]) xs[i₁]⊏xs[i₂] in
130129
contradiction xs[i₁]⊏xs[i₁] (⊏.irrefl ⊏.Eq.refl)
131130

src/Data/Graph/Acyclic.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ module _ {ℓ e} {N : Set ℓ} {E : Set e} where
313313
expand n rec (c & g) =
314314
node (label c)
315315
(List.map
316-
(Prod.map id (λ i rec (n - suc i) (lemma n i) (g [ i ])))
316+
(Prod.map id (λ i rec (lemma n i) (g [ i ])))
317317
(successors c))
318318

319319
-- Performs the toTree expansion once for each node.

src/Data/List/Relation/Binary/Permutation/Setoid/Properties.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -384,15 +384,15 @@ split v as bs p = helper as bs p (<-wellFounded (steps p))
384384
helper (a ∷ []) bs (refl eq) _ = [ a ] , bs , eq
385385
helper (a ∷ b ∷ as) bs (refl eq) _ = a ∷ b ∷ as , bs , eq
386386
helper [] bs (prep v≈x _) _ = [] , _ , v≈x ∷ ≋-refl
387-
helper (a ∷ as) bs (prep eq as↭xs) (acc rec) with helper as bs as↭xs (rec _ ≤-refl)
387+
helper (a ∷ as) bs (prep eq as↭xs) (acc rec) with helper as bs as↭xs (rec ≤-refl)
388388
... | (ps , qs , eq₂) = a ∷ ps , qs , eq ∷ eq₂
389389
helper [] (b ∷ bs) (swap x≈b y≈v _) _ = [ b ] , _ , x≈b ∷ y≈v ∷ ≋-refl
390390
helper (a ∷ []) bs (swap x≈v y≈a ↭) _ = [] , a ∷ _ , x≈v ∷ y≈a ∷ ≋-refl
391-
helper (a ∷ b ∷ as) bs (swap x≈b y≈a as↭xs) (acc rec) with helper as bs as↭xs (rec _ ≤-refl)
391+
helper (a ∷ b ∷ as) bs (swap x≈b y≈a as↭xs) (acc rec) with helper as bs as↭xs (rec ≤-refl)
392392
... | (ps , qs , eq) = b ∷ a ∷ ps , qs , x≈b ∷ y≈a ∷ eq
393-
helper as bs (trans ↭₁ ↭₂) (acc rec) with helper as bs ↭₂ (rec _ (m<n+m (steps ↭₂) (0<steps ↭₁)))
393+
helper as bs (trans ↭₁ ↭₂) (acc rec) with helper as bs ↭₂ (rec (m<n+m (steps ↭₂) (0<steps ↭₁)))
394394
... | (ps , qs , eq) = helper ps qs (↭-respʳ-≋ eq ↭₁)
395-
(rec _ (subst (_< _) (sym (steps-respʳ eq ↭₁)) (m<m+n (steps ↭₁) (0<steps ↭₂))))
395+
(rec (subst (_< _) (sym (steps-respʳ eq ↭₁)) (m<m+n (steps ↭₁) (0<steps ↭₂))))
396396

397397
------------------------------------------------------------------------
398398
-- filter

src/Data/List/Sort/MergeSort.agda

+7-6
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,21 @@ open PermutationReasoning
4444
-- Definition
4545

4646
mergePairs : List (List A) List (List A)
47-
mergePairs (xs ∷ ys ∷ xss) = merge _≤?_ xs ys ∷ mergePairs xss
47+
mergePairs (xs ∷ ys ∷ yss) = merge _≤?_ xs ys ∷ mergePairs yss
4848
mergePairs xss = xss
4949

5050
private
51-
length-mergePairs : xs ys xss length (mergePairs (xs ∷ ys ∷ xss)) < length (xs ∷ ys ∷ xss)
51+
length-mergePairs : xs ys yss let zss = xs ∷ ys ∷ yss in
52+
length (mergePairs zss) < length zss
5253
length-mergePairs _ _ [] = s<s z<s
53-
length-mergePairs _ _ (xss ∷ []) = s<s (s<s z<s)
54-
length-mergePairs _ _ (xs ∷ ys ∷ xss) = s<s (m<n⇒m<1+n (length-mergePairs xs ys xss))
54+
length-mergePairs _ _ (xs ∷ []) = s<s (s<s z<s)
55+
length-mergePairs _ _ (xs ∷ ys ∷ yss) = s<s (m<n⇒m<1+n (length-mergePairs xs ys yss))
5556

5657
mergeAll : (xss : List (List A)) Acc _<_ (length xss) List A
5758
mergeAll [] _ = []
5859
mergeAll (xs ∷ []) _ = xs
59-
mergeAll (xs ∷ ys ∷ xss) (acc rec) = mergeAll
60-
(mergePairs (xs ∷ ys ∷ xss)) (rec _ (length-mergePairs xs ys xss))
60+
mergeAll xss@(xs ∷ ys ∷ yss) (acc rec) = mergeAll
61+
(mergePairs xss) (rec (length-mergePairs xs ys yss))
6162

6263
sort : List A List A
6364
sort xs = mergeAll (map [_] xs) (<-wellFounded-fast _)

src/Data/Nat/DivMod.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ m*n/m*o≡n/o m@(suc _) n o = helper (<-wellFounded n)
294294
... | no n≮o = begin-equality
295295
(m * n) / (m * o) ≡⟨ m/n≡1+[m∸n]/n (*-monoʳ-≤ m (≮⇒≥ n≮o)) ⟩
296296
1 + (m * n ∸ m * o) / (m * o) ≡˘⟨ cong (λ v 1 + v / (m * o)) (*-distribˡ-∸ m n o) ⟩
297-
1 + (m * (n ∸ o)) / (m * o) ≡⟨ cong suc (helper (rec (n ∸ o) n∸o<n)) ⟩
297+
1 + (m * (n ∸ o)) / (m * o) ≡⟨ cong suc (helper (rec n∸o<n)) ⟩
298298
1 + (n ∸ o) / o ≡˘⟨ cong₂ _+_ (n/n≡1 o) refl ⟩
299299
o / o + (n ∸ o) / o ≡˘⟨ +-distrib-/-∣ˡ (n ∸ o) (divides 1 ((sym (*-identityˡ o)))) ⟩
300300
(o + (n ∸ o)) / o ≡⟨ cong (_/ o) (m+[n∸m]≡n (≮⇒≥ n≮o)) ⟩

src/Data/Nat/GCD.agda

+13-13
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ open import Algebra.Definitions {A = ℕ} _≡_ as Algebra
4343

4444
gcd′ : m n Acc _<_ m n < m
4545
gcd′ m zero _ _ = m
46-
gcd′ m n@(suc _) (acc rec) n<m = gcd′ n (m % n) (rec _ n<m) (m%n<n m n)
46+
gcd′ m n@(suc _) (acc rec) n<m = gcd′ n (m % n) (rec n<m) (m%n<n m n)
4747

4848
gcd :
4949
gcd m n with <-cmp m n
@@ -55,15 +55,15 @@ gcd m n with <-cmp m n
5555
-- Core properties of gcd′
5656

5757
gcd′[m,n]∣m,n : {m n} rec n<m gcd′ m n rec n<m ∣ m × gcd′ m n rec n<m ∣ n
58-
gcd′[m,n]∣m,n {m} {zero} rec n<m = ∣-refl , m ∣0
59-
gcd′[m,n]∣m,n {m} {suc n} (acc rec) n<m
60-
with gcd∣n , gcd∣m%n gcd′[m,n]∣m,n (rec _ n<m) (m%n<n m (suc n))
58+
gcd′[m,n]∣m,n {m} {zero} rec n<m = ∣-refl , m ∣0
59+
gcd′[m,n]∣m,n {m} {n@(suc _)} (acc rec) n<m
60+
with gcd∣n , gcd∣m%n gcd′[m,n]∣m,n (rec n<m) (m%n<n m n)
6161
= ∣n∣m%n⇒∣m gcd∣n gcd∣m%n , gcd∣n
6262

6363
gcd′-greatest : {m n c} rec n<m c ∣ m c ∣ n c ∣ gcd′ m n rec n<m
64-
gcd′-greatest {m} {zero} rec n<m c∣m c∣n = c∣m
65-
gcd′-greatest {m} {suc n} (acc rec) n<m c∣m c∣n =
66-
gcd′-greatest (rec _ n<m) (m%n<n m (suc n)) c∣n (%-presˡ-∣ c∣m c∣n)
64+
gcd′-greatest {m} {zero} rec n<m c∣m c∣n = c∣m
65+
gcd′-greatest {m} {n@(suc _)} (acc rec) n<m c∣m c∣n =
66+
gcd′-greatest (rec n<m) (m%n<n m n) c∣n (%-presˡ-∣ c∣m c∣n)
6767

6868
------------------------------------------------------------------------
6969
-- Core properties of gcd
@@ -387,13 +387,13 @@ module Bézout where
387387
P (m , n) = Lemma m n
388388

389389
gcd″ : p (<′-Rec ⊗ <′-Rec) P p P p
390-
gcd″ (zero , n) rec = Lemma.base n
391-
gcd″ (suc m , zero) rec = Lemma.sym (Lemma.base (suc m))
392-
gcd″ (suc m , suc n) rec with compare m n
393-
... | equal m = Lemma.refl (suc m)
394-
... | less m k = Lemma.stepˡ $ proj₁ rec (suc k) (lem₁ k m)
390+
gcd″ (zero , n) rec = Lemma.base n
391+
gcd″ (m@(suc _) , zero) rec = Lemma.sym (Lemma.base m)
392+
gcd″ (m′@(suc m) , n′@(suc n)) rec with compare m n
393+
... | equal m = Lemma.refl m′
394+
... | less m k = Lemma.stepˡ $ proj₁ rec (lem₁ k m)
395395
-- "gcd (suc m) (suc k)"
396-
... | greater n k = Lemma.stepʳ $ proj₂ rec (suc k) (lem₁ k n) (suc n)
396+
... | greater n k = Lemma.stepʳ $ proj₂ rec (lem₁ k n) n′
397397
-- "gcd (suc k) (suc n)"
398398

399399
-- Bézout's identity can be recovered from the GCD.

src/Data/Nat/Induction.agda

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ cRec = build cRecBuilder
6767

6868
<′-wellFounded n = acc (<′-wellFounded′ n)
6969

70-
<′-wellFounded′ (suc n) n <′-base = <′-wellFounded n
71-
<′-wellFounded′ (suc n) m (<′-step m<n) = <′-wellFounded′ n m m<n
70+
<′-wellFounded′ (suc n) <′-base = <′-wellFounded n
71+
<′-wellFounded′ (suc n) (<′-step m<n) = <′-wellFounded′ n m<n
7272

7373
module _ {ℓ : Level} where
7474
open WF.All <′-wellFounded ℓ public
@@ -100,7 +100,7 @@ module _ {ℓ : Level} where
100100
<-wellFounded-skip : (k : ℕ) WellFounded _<_
101101
<-wellFounded-skip zero n = <-wellFounded n
102102
<-wellFounded-skip (suc k) zero = <-wellFounded 0
103-
<-wellFounded-skip (suc k) (suc n) = acc (λ m _ <-wellFounded-skip k m)
103+
<-wellFounded-skip (suc k) (suc n) = acc λ {m} _ <-wellFounded-skip k m
104104

105105
module _ {ℓ : Level} where
106106
open WF.All <-wellFounded ℓ public

src/Data/Nat/Logarithm/Core.agda

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ open import Data.Unit
2323
⌊log2⌋ : n Acc _<_ n
2424
⌊log2⌋ 0 _ = 0
2525
⌊log2⌋ 1 _ = 0
26-
⌊log2⌋ (suc n′@(suc n)) (acc rs) = 1 + ⌊log2⌋ (suc ⌊ n /2⌋) (rs _ (⌊n/2⌋<n n′))
26+
⌊log2⌋ (suc n′@(suc n)) (acc rs) = 1 + ⌊log2⌋ (suc ⌊ n /2⌋) (rs (⌊n/2⌋<n n′))
2727

2828

2929
-- Ceil version
3030

3131
⌈log2⌉ : n Acc _<_ n
3232
⌈log2⌉ 0 _ = 0
3333
⌈log2⌉ 1 _ = 0
34-
⌈log2⌉ (suc (suc n)) (acc rs) = 1 + ⌈log2⌉ (suc ⌈ n /2⌉) (rs _ (⌈n/2⌉<n n))
34+
⌈log2⌉ (suc (suc n)) (acc rs) = 1 + ⌈log2⌉ (suc ⌈ n /2⌉) (rs (⌈n/2⌉<n n))
3535

3636
------------------------------------------------------------------------
3737
-- Properties of ⌊log2⌋

src/Data/Nat/Properties.agda

+1-1
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ m<1+n⇒m≤n (s≤s m≤n) = m≤n
486486
∀[m<n⇒m≢o]⇒n≤o (suc n) (suc o) m<n⇒m≢o = s≤s (∀[m<n⇒m≢o]⇒n≤o n o rec)
487487
where
488488
rec : {m} m < n m ≢ o
489-
rec x<m refl = m<n⇒m≢o (s≤s x<m) refl
489+
rec o<n refl = m<n⇒m≢o (s<s o<n) refl
490490

491491
------------------------------------------------------------------------
492492
-- A module for reasoning about the _≤_ and _<_ relations

src/Data/Product/Relation/Binary/Lex/Strict.agda

+4-4
Original file line numberDiff line numberDiff line change
@@ -202,13 +202,13 @@ module _ {_≈₁_ : Rel A ℓ₁} {_<₁_ : Rel A ℓ₂} {_<₂_ : Rel B ℓ
202202
×-acc : {x y}
203203
Acc _<₁_ x Acc _<₂_ y
204204
WfRec _<ₗₑₓ_ (Acc _<ₗₑₓ_) (x , y)
205-
×-acc (acc rec₁) acc₂ (u , v) (inj₁ u<x)
206-
= acc (×-acc (rec₁ u u<x) (wf₂ v))
207-
×-acc acc₁ (acc rec₂) (u , v) (inj₂ (u≈x , v<y))
205+
×-acc (acc rec₁) acc₂ (inj₁ u<x)
206+
= acc (×-acc (rec₁ u<x) (wf₂ _))
207+
×-acc acc₁ (acc rec₂) (inj₂ (u≈x , v<y))
208208
= Acc-resp-flip-≈
209209
(×-respectsʳ {_<₁_ = _<₁_} {_<₂_ = _<₂_} trans resp (≡.respʳ _<₂_))
210210
(u≈x , ≡.refl)
211-
(acc (×-acc acc₁ (rec₂ v v<y)))
211+
(acc (×-acc acc₁ (rec₂ v<y)))
212212

213213

214214
module _ {_<₁_ : Rel A ℓ₁} {_<₂_ : Rel B ℓ₂} where

src/Data/Vec/Relation/Binary/Lex/Strict.agda

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ module _ {_≈_ : Rel A ℓ₁} {_≺_ : Rel A ℓ₂} where
134134
where
135135

136136
<-wellFounded : {n} WellFounded (_<_ {n})
137-
<-wellFounded {0} [] = acc λ ys ys<[] ⊥-elim (xs≮[] ys<[])
137+
<-wellFounded {0} [] = acc λ ys<[] ⊥-elim (xs≮[] ys<[])
138+
138139
<-wellFounded {suc n} xs = Subrelation.wellFounded <⇒uncons-Lex uncons-Lex-wellFounded xs
139140
where
140141
<⇒uncons-Lex : {xs ys : Vec A (suc n)} xs < ys (×-Lex _≈_ _≺_ _<_ on uncons) xs ys

0 commit comments

Comments
 (0)