Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An alternative to #1698 #1709

Merged
merged 45 commits into from
Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e0ebddd
added new lemma m<1+n⇒m<n∨m≡n
jamesmckinna Jan 29, 2022
f2c61dd
proof of WF based on new lemma
jamesmckinna Jan 29, 2022
df98374
tweaked stmt of <-wellFounded′
jamesmckinna Jan 30, 2022
1346dec
narrowed the imports from Induction.WellFounded
jamesmckinna Feb 3, 2022
9685a22
extended riff on PR #1698; still work to do on the deprecations/modif…
jamesmckinna Feb 3, 2022
b3f17cc
fix whitespace...
jamesmckinna Feb 3, 2022
fc58d5f
sharpened some proofs with as-patterns
jamesmckinna Feb 4, 2022
22dbe04
added patterns for _<_; deprecated Properties.Core; added some additi…
jamesmckinna Feb 6, 2022
d51832a
more systematic use of the pattern idiom ofor _<_
jamesmckinna Feb 6, 2022
3c967b5
narrowed import interface
jamesmckinna Feb 7, 2022
c473b13
further tightenings
jamesmckinna Feb 7, 2022
8982eaa
further tightenings
jamesmckinna Feb 7, 2022
d67e49d
added patterns for _<′_; and then used them
jamesmckinna Feb 7, 2022
7af3b40
equivalence of `_<_` and `_<′_`; use in `Data.Nat.Induction`
jamesmckinna Feb 7, 2022
5027911
reverted changes regarding `Data.Fin.Properties.toℕ≤n`
jamesmckinna Feb 8, 2022
8c19672
more uncaught instances of the `_<_` patterns
jamesmckinna Feb 8, 2022
aeda1e1
cosmetic tweak of lemma
jamesmckinna Feb 8, 2022
d43f92d
revert a couple fo uses of the new patterns
jamesmckinna Feb 8, 2022
57b6767
reversion of line break in `Data.Fin.Induction`
jamesmckinna Feb 8, 2022
ec2ad2c
removed spurious implicit in `Data.Fin.Induction`
jamesmckinna Feb 8, 2022
ccbb62d
removed definitions from deprecated module `Data.Nat.Properties.Core`
jamesmckinna Feb 8, 2022
d646078
having the courage of my convictions
jamesmckinna Feb 8, 2022
eb15a97
Merge branch 'master' of https:/agda/agda-stdlib into pr1…
jamesmckinna Feb 8, 2022
3fa38f9
Merge branch 'agda:master' into pr1698-extended
jamesmckinna Feb 8, 2022
9ac3c64
Merge branch 'pr1698-extended' of https:/jamesmckinna/agd…
jamesmckinna Feb 8, 2022
97a332b
adding DEPRECATED to `Data.Nat.Properties.Core`
jamesmckinna Feb 8, 2022
2c31273
adding DEPRECATED to `Data.Nat.Properties.Core`
jamesmckinna Feb 8, 2022
bb714ec
yet another lemma `m<1+n⇒m≤n` relating the two ordering relations; pr…
jamesmckinna Feb 8, 2022
e66974c
put back definitions
jamesmckinna Feb 11, 2022
4c3cf29
removed need for as-patterns in `fromℕ<` and `inject≤`
jamesmckinna Feb 11, 2022
c7aa491
responding to reviews; some delicacy about the disjoint as-pattern idiom
jamesmckinna Feb 11, 2022
7c1f530
removed dot patterns
jamesmckinna Feb 11, 2022
c40cba0
chasing as-patterns
jamesmckinna Feb 11, 2022
3322f4a
minor additions; minor tweaks
jamesmckinna Feb 12, 2022
9824893
removed one more as-pattern
jamesmckinna Feb 12, 2022
3f9f635
renamed constructors of `_<′_`
jamesmckinna Feb 15, 2022
70bc731
renamed constructors of `_<′_` in `Data.Nat.Induction`
jamesmckinna Feb 15, 2022
96a9506
simplified `toℕ≤pred[n]` analyses; `toℕ-cancel*` properties are now t…
jamesmckinna Feb 15, 2022
390890a
consider deprecating `toℕ-cancel*` and `toℕ-mono*` properties
jamesmckinna Feb 15, 2022
a43f52d
resolved factorial conlfict; I think
jamesmckinna Feb 21, 2022
811fd05
someone else's whitespace needed fixing?
jamesmckinna Feb 21, 2022
e7a3f58
what is with these merge conflicts?
jamesmckinna Feb 22, 2022
cec361d
reverted some changes; removed mutual block; tidied up
jamesmckinna Feb 22, 2022
3e48ede
working on CHANGELOG
jamesmckinna Feb 22, 2022
a47e6ca
CHANGELOG uodated; tidied up
jamesmckinna Feb 22, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@ Deprecated modules
Relation.Binary.Properties.MeetSemilattice.agda ↦ Relation.Binary.Lattice.Properties.MeetSemilattice.agda
```

### Deprecation of `Data.Nat.Properties.Core`

* The module `Data.Nat.Properties.Core` has been deprecated, and its one entry moved to `Data.Nat.Properties`

Deprecated names
----------------

Expand Down Expand Up @@ -1003,6 +1007,8 @@ Other minor changes
combine-surjective : ∀ x → ∃₂ λ y z → combine y z ≡ x

lower₁-injective : lower₁ i n≢i ≡ lower₁ j n≢j → i ≡ j

i<1+i : i < suc i
```

* Added new functions in `Data.Integer.Base`:
Expand Down Expand Up @@ -1065,6 +1071,16 @@ Other minor changes
∷ʳ-++ : xs ∷ʳ a ++ ys ≡ xs ++ a ∷ ys
```

* Added new patterns and definitions to `Data.Nat.Base`:
```agda
pattern z<s {n} = s≤s (z≤n {n})
pattern s<s {m} {n} m<n = s≤s {m} {n} m<n

pattern <′-base = ≤′-refl
pattern <′-step {n} m<′n = ≤′-step {n} m<′n
```


* Added new definitions and proofs to `Data.Nat.Primality`:
```agda
Composite : ℕ → Set
Expand All @@ -1087,6 +1103,17 @@ Other minor changes
m*n≢0 : .{{_ : NonZero m}} .{{_ : NonZero n}} → NonZero (m * n)
m≤n⇒n∸m≤n : m ≤ n → n ∸ m ≤ n

≤-pred : suc m ≤ suc n → m ≤ n
s<s-injective : ∀ {p q : m < n} → s<s p ≡ s<s q → p ≡ q
<-pred : suc m < suc n → m < n
<-step : m < n → m < 1 + n
m<1+n⇒m<n∨m≡n : m < suc n → m < n ⊎ m ≡ n

z<′s : zero <′ suc n
s<′s : m <′ n → suc m <′ suc n
<⇒<′ : m < n → m <′ n
<′⇒< : m <′ n → m < n

1≤n! : 1 ≤ n !
_!≢0 : NonZero (n !)
_!*_!≢0 : NonZero (m ! * n !)
Expand Down
11 changes: 5 additions & 6 deletions src/Data/Fin/Base.agda
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
module Data.Fin.Base where

open import Data.Empty using (⊥-elim)
open import Data.Nat.Base as ℕ using (ℕ; zero; suc; z≤n; s≤s; _^_)
open import Data.Nat.Properties.Core using (≤-pred)
open import Data.Nat.Base as ℕ using (ℕ; zero; suc; z≤n; s≤s; z<s; s<s; _^_)
open import Data.Product as Product using (_×_; _,_; proj₁; proj₂)
open import Data.Sum.Base as Sum using (_⊎_; inj₁; inj₂; [_,_]′)
open import Function.Base using (id; _∘_; _on_; flip)
Expand Down Expand Up @@ -67,8 +66,8 @@ fromℕ (suc n) = suc (fromℕ n)
-- fromℕ< {m} _ = "m".

fromℕ< : ∀ {m n} → m ℕ.< n → Fin n
fromℕ< {zero} {suc n} m≤n = zero
fromℕ< {suc m} {suc n} m≤n = suc (fromℕ< (≤-pred m≤n))
fromℕ< {zero} {suc n} z<s = zero
fromℕ< {suc m} {suc n} (s<s m<n) = suc (fromℕ< m<n)

-- fromℕ<″ m _ = "m".

Expand Down Expand Up @@ -112,8 +111,8 @@ inject₁ zero = zero
inject₁ (suc i) = suc (inject₁ i)

inject≤ : ∀ {m n} → Fin m → m ℕ.≤ n → Fin n
inject≤ {_} {suc n} zero le = zero
inject≤ {_} {suc n} (suc i) le = suc (inject≤ i (≤-pred le))
inject≤ {_} {suc n} zero _ = zero
inject≤ {_} {suc n} (suc i) (s≤s m≤n) = suc (inject≤ i m≤n)

-- lower₁ "i" _ = "i".

Expand Down
10 changes: 5 additions & 5 deletions src/Data/Fin/Induction.agda
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

open import Data.Fin.Base
open import Data.Fin.Properties
open import Data.Nat.Base as ℕ using (ℕ; zero; suc; z≤n; s≤s; _∸_)
open import Data.Nat.Base as ℕ using (ℕ; zero; suc; _∸_)
import Data.Nat.Induction as ℕ
import Data.Nat.Properties as ℕ
open import Induction
Expand Down Expand Up @@ -46,15 +46,15 @@ open WF public using (Acc; acc)
induct : ∀ {i} → Acc _<_ i → P i
induct {zero} _ = P₀
induct {suc i} (acc rec) = Pᵢ⇒Pᵢ₊₁ i (induct (rec (inject₁ i) i<i+1))
where i<i+1 = s≤s (ℕ.≤-reflexive (toℕ-inject₁ i))
where i<i+1 = ℕ<⇒inject₁< (i<1+i i)

------------------------------------------------------------------------
-- Induction over _>_

private
acc-map : ∀ {x : Fin n} → Acc ℕ._<_ (n ∸ toℕ x) → Acc _>_ x
acc-map {n} (acc rs) = acc (λ y y>x →
acc-map (rs (n ∸ toℕ y) (ℕ.∸-monoʳ-< y>x (toℕ≤n y))))
acc-map {n} (acc rs) = acc λ y y>x →
acc-map (rs (n ∸ toℕ y) (ℕ.∸-monoʳ-< y>x (toℕ≤n y)))

>-wellFounded : WellFounded {A = Fin n} _>_
>-wellFounded {n} x = acc-map (ℕ.<-wellFounded (n ∸ toℕ x))
Expand All @@ -69,7 +69,7 @@ private
induct {i} (acc rec) with n ℕ.≟ toℕ i
... | yes n≡i = subst P (toℕ-injective (trans (toℕ-fromℕ n) n≡i)) Pₙ
... | no n≢i = subst P (inject₁-lower₁ i n≢i) (Pᵢ₊₁⇒Pᵢ _ Pᵢ₊₁)
where Pᵢ₊₁ = induct (rec _ (s≤s (ℕ.≤-reflexive (sym (toℕ-lower₁ i n≢i)))))
where Pᵢ₊₁ = induct (rec _ (ℕ.≤-reflexive (cong suc (sym (toℕ-lower₁ i n≢i)))))

------------------------------------------------------------------------
-- Induction over _≺_
Expand Down
Loading