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

'No infinite descent' for (Accessible elements of) WellFounded relations #2126

Merged
merged 64 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
63d6ca0
basic result
jamesmckinna Oct 7, 2023
d549c62
added missing lemma; is there a better name for this?
jamesmckinna Oct 7, 2023
60d22e6
renamed lemma
jamesmckinna Oct 7, 2023
ec09669
final tidying up; `CHANGELOG`
jamesmckinna Oct 7, 2023
26dfcc5
final tidying up
jamesmckinna Oct 7, 2023
00e0083
missing `CHANGELOG` entry
jamesmckinna Oct 7, 2023
c1b3ed9
`InfiniteDescent` definition and proof
jamesmckinna Oct 8, 2023
d310349
revised `InfiniteDescent` definition and proof
jamesmckinna Oct 8, 2023
b028dc9
major revision: renames things, plus additional corollaries
jamesmckinna Oct 9, 2023
8dec2ee
spacing
jamesmckinna Oct 9, 2023
17cc4b4
added `NoSmallestCounterExample` principles for `Stable` predicates
jamesmckinna Oct 15, 2023
fb8480b
refactoring; move `Stable` to `Relation.Unary`
jamesmckinna Oct 15, 2023
96175ed
refactoring; remove explicit definition of `CounterExample`
jamesmckinna Oct 15, 2023
e37fe2a
refactoring; rename qualified `import`
jamesmckinna Oct 15, 2023
596aac2
[fixes #2130] Moving `Properties.HeytingAlgebra` from `Relation.Binar…
jamesmckinna Oct 11, 2023
e06c02a
[fixes #2127] Fixes #1930 `import` bug (#2128)
jamesmckinna Oct 11, 2023
eee9f58
[fixes #1214] Add negated ordering relation symbols systematically to…
jamesmckinna Oct 12, 2023
81a7b28
Refactoring (inversion) properties of `_<_` on `Nat`, plus consequenc…
jamesmckinna Oct 12, 2023
d39b849
Bump CI tests to Agda-2.6.4 (#2134)
MatthewDaggitt Oct 12, 2023
cb92af1
Remove `Algebra.Ordered` (#2133)
MatthewDaggitt Oct 12, 2023
135951f
[ fix ] missing name in LICENCE file (#2139)
gallais Oct 12, 2023
a843d0d
Add new blocking primitives to `Reflection.TCM` (#1972)
plt-amy Oct 13, 2023
aa6ef23
Change definition of `IsStrictTotalOrder` (#2137)
MatthewDaggitt Oct 13, 2023
6e375c2
Add _<$>_ operator for Function bundle (#2144)
MatthewDaggitt Oct 14, 2023
222c238
[ fix #2086 ] new web deployment strategy (#2147)
gallais Oct 14, 2023
347a079
[ admin ] fix sorting logic (#2151)
gallais Oct 15, 2023
d91e21d
Add coincidence law to modules (#1898)
Taneb Oct 16, 2023
010498b
Make reasoning modular by adding new `Reasoning.Syntax` module (#2152)
MatthewDaggitt Oct 16, 2023
9bf34e0
Fixes typos identified in #2154 (#2158)
jamesmckinna Oct 16, 2023
b0c95bc
tackles #2124 as regards `case_return_of_` (#2157)
jamesmckinna Oct 16, 2023
ef66f77
Rename preorder ~ relation reasoning combinators (#2156)
MatthewDaggitt Oct 16, 2023
33811e5
Move ≡-Reasoning from Core to Properties and implement using syntax (…
MatthewDaggitt Oct 17, 2023
cc0749c
Add consistent deprecation warnings to old function hierarchy (#2163)
MatthewDaggitt Oct 18, 2023
fe5fddc
Rename symmetric reasoning combinators. Minimal set of changes (#2160)
MatthewDaggitt Oct 19, 2023
6367fd5
Restore 'return' as an alias for 'pure' (#2164)
MatthewDaggitt Oct 19, 2023
ce4bd12
[ fix #2153 ] Properly re-export specialised combinators (#2161)
gallais Oct 19, 2023
c5a3693
Connect `LeftInverse` with (`Split`)`Surjection` (#2054)
laMudri Oct 19, 2023
eb5f308
Added remaining flipped and negated relations to binary relation bund…
MatthewDaggitt Oct 19, 2023
aeed7d5
Tidy up CHANGELOG in preparation for release candidate (#2165)
MatthewDaggitt Oct 19, 2023
d2e94ef
Spellcheck CHANGELOG (#2167)
jamesmckinna Oct 20, 2023
0befc0d
Fixed Agda version typo in README (#2176)
jamesmckinna Oct 21, 2023
cd34417
Fixed in deprecation warning for `<-transˡ` (#2173)
jamesmckinna Oct 21, 2023
496eded
Bump Haskell CI (original!) to latest minor GHC versions (#2187)
andreasabel Nov 1, 2023
2fda34d
[fixes #2175] Documentation misc. typos etc. for RC1 (#2183)
jamesmckinna Nov 1, 2023
188f74c
[fixes #2178] regularise and specify/systematise, the conventions for…
jamesmckinna Nov 1, 2023
200ef72
Move `T?` to `Relation.Nullary.Decidable.Core` (#2189)
MatthewDaggitt Nov 1, 2023
9be7cea
Make decidable versions of sublist functions the default (#2186)
MatthewDaggitt Nov 3, 2023
8270e59
Merge branch 'master' into NoInfiniteDescent
jamesmckinna Nov 4, 2023
a45f04d
new `CHANGELOG`
jamesmckinna Dec 14, 2023
10fa8ed
Merge branch 'master' into NoInfiniteDescent
jamesmckinna Dec 14, 2023
fe3123d
Merge branch 'master' into NoInfiniteDescent
jamesmckinna Dec 14, 2023
0c2288f
resolved merge conflict
jamesmckinna Dec 17, 2023
d074a0d
resolved merge conflict, this time
jamesmckinna Dec 17, 2023
5e66965
revised in line with review comments
jamesmckinna Dec 31, 2023
9de7d0f
Merge branch 'master' into NoInfiniteDescent
jamesmckinna Dec 31, 2023
2f1fa64
tweaked `export`s; does that fix things now?
jamesmckinna Dec 31, 2023
0295bb7
Merge branch 'master' into NoInfiniteDescent
jamesmckinna Jan 31, 2024
cc280a4
Merge branch 'master' into NoInfiniteDescent
MatthewDaggitt Feb 25, 2024
4518858
Fix merge mistake
MatthewDaggitt Feb 25, 2024
f84d319
Refactored to remove a indirection and nested modules
MatthewDaggitt Feb 25, 2024
7bc76dd
Touch up names
MatthewDaggitt Feb 25, 2024
88452ff
Reintroduce anonymous module for descent
MatthewDaggitt Feb 25, 2024
07f1a00
cosmetics asper final comment
jamesmckinna Feb 26, 2024
e3fa327
Merge branch 'master' into NoInfiniteDescent
MatthewDaggitt Mar 16, 2024
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
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ New modules

* `Algebra.Module.Bundles.Raw`: raw bundles for module-like algebraic structures

* Consequences of 'infinite descent' for (accessible elements of) well-founded relations:
```agda
Induction.InfiniteDescent
```

* Nagata's construction of the "idealization of a module":
```agda
Algebra.Module.Construct.Idealization
Expand Down Expand Up @@ -166,6 +171,15 @@ Additions to existing modules
* Added new functions in `Data.String.Base`:
```agda
map : (Char → Char) → String → String

* Added new definition in `Relation.Binary.Construct.Closure.Transitive`
```
transitive⁻ : Transitive _∼_ → TransClosure _∼_ ⇒ _∼_
```

* Added new definition in `Relation.Unary`
```
Stable : Pred A ℓ → Set _
```

* In `Function.Bundles`, added `_⟶ₛ_` as a synonym for `Func` that can
Expand Down
189 changes: 189 additions & 0 deletions src/Induction/InfiniteDescent.agda
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
------------------------------------------------------------------------
-- The Agda standard library
--
-- A standard consequence of accessibility/well-foundedness:
-- the impossibility of 'infinite descent' from any (accessible)
-- element x satisfying P to 'smaller' y also satisfying P
------------------------------------------------------------------------

{-# OPTIONS --cubical-compatible --safe #-}

module Induction.InfiniteDescent where

open import Data.Nat.Base as ℕ using (ℕ; zero; suc)
open import Data.Nat.Properties as ℕ
open import Data.Product.Base using (_,_; proj₁; ∃-syntax; _×_)
open import Function.Base using (_∘_)
open import Induction.WellFounded
using (WellFounded; Acc; acc; acc-inverse; module Some)
open import Level using (Level)
open import Relation.Binary.Core using (Rel)
open import Relation.Binary.Construct.Closure.Transitive
open import Relation.Binary.PropositionalEquality.Core
open import Relation.Nullary.Negation.Core as Negation using (¬_)
open import Relation.Unary
using (Pred; ∁; _∩_; _⊆_; _⇒_; Universal; IUniversal; Stable; Empty)

private
variable
a r ℓ : Level
A : Set a
f : ℕ → A
_<_ : Rel A r
P : Pred A ℓ

------------------------------------------------------------------------
-- Definitions

InfiniteDescendingSequence : Rel A r → (ℕ → A) → Set _
InfiniteDescendingSequence _<_ f = ∀ n → f (suc n) < f n

InfiniteDescendingSequenceFrom : Rel A r → (ℕ → A) → Pred A _
InfiniteDescendingSequenceFrom _<_ f x = f zero ≡ x × InfiniteDescendingSequence _<_ f

InfiniteDescendingSequence⁺ : Rel A r → (ℕ → A) → Set _
InfiniteDescendingSequence⁺ _<_ f = ∀ {m n} → m ℕ.< n → TransClosure _<_ (f n) (f m)

InfiniteDescendingSequenceFrom⁺ : Rel A r → (ℕ → A) → Pred A _
InfiniteDescendingSequenceFrom⁺ _<_ f x = f zero ≡ x × InfiniteDescendingSequence⁺ _<_ f

DescentFrom : Rel A r → Pred A ℓ → Pred A _
DescentFrom _<_ P x = P x → ∃[ y ] y < x × P y

Descent : Rel A r → Pred A ℓ → Set _
Descent _<_ P = ∀ {x} → DescentFrom _<_ P x

InfiniteDescentFrom : Rel A r → Pred A ℓ → Pred A _
InfiniteDescentFrom _<_ P x = P x → ∃[ f ] InfiniteDescendingSequenceFrom _<_ f x × ∀ n → P (f n)

InfiniteDescent : Rel A r → Pred A ℓ → Set _
InfiniteDescent _<_ P = ∀ {x} → InfiniteDescentFrom _<_ P x

InfiniteDescentFrom⁺ : Rel A r → Pred A ℓ → Pred A _
InfiniteDescentFrom⁺ _<_ P x = P x → ∃[ f ] InfiniteDescendingSequenceFrom⁺ _<_ f x × ∀ n → P (f n)

InfiniteDescent⁺ : Rel A r → Pred A ℓ → Set _
InfiniteDescent⁺ _<_ P = ∀ {x} → InfiniteDescentFrom⁺ _<_ P x

NoSmallestCounterExample : Rel A r → Pred A ℓ → Set _
NoSmallestCounterExample _<_ P = ∀ {x} → Acc _<_ x → DescentFrom (TransClosure _<_) (∁ P) x

------------------------------------------------------------------------
-- We can swap between transitively closed and non-transitively closed
-- definitions

sequence⁺ : InfiniteDescendingSequence (TransClosure _<_) f →
InfiniteDescendingSequence⁺ _<_ f
sequence⁺ {_<_ = _<_} {f = f} seq[f] = seq⁺[f]′ ∘ ℕ.<⇒<′
where
seq⁺[f]′ : ∀ {m n} → m ℕ.<′ n → TransClosure _<_ (f n) (f m)
seq⁺[f]′ ℕ.<′-base = seq[f] _
seq⁺[f]′ (ℕ.<′-step m<′n) = seq[f] _ ++ seq⁺[f]′ m<′n

sequence⁻ : InfiniteDescendingSequence⁺ _<_ f →
InfiniteDescendingSequence (TransClosure _<_) f
sequence⁻ seq[f] = seq[f] ∘ n<1+n

------------------------------------------------------------------------
-- Results about unrestricted descent

module _ (descent : Descent _<_ P) where

descent∧acc⇒infiniteDescentFrom : (Acc _<_) ⊆ (InfiniteDescentFrom _<_ P)
descent∧acc⇒infiniteDescentFrom {x} =
Some.wfRec (InfiniteDescentFrom _<_ P) rec x
where
rec : _
rec y rec[y] py
with z , z<y , pz ← descent py
with g , (g0≡z , g<P) , Π[P∘g] ← rec[y] z<y pz
= h , (h0≡y , h<P) , Π[P∘h]
where
h : ℕ → _
h zero = y
h (suc n) = g n

h0≡y : h zero ≡ y
h0≡y = refl

h<P : ∀ n → h (suc n) < h n
h<P zero rewrite g0≡z = z<y
h<P (suc n) = g<P n

Π[P∘h] : ∀ n → P (h n)
Π[P∘h] zero rewrite g0≡z = py
Π[P∘h] (suc n) = Π[P∘g] n

descent∧wf⇒infiniteDescent : WellFounded _<_ → InfiniteDescent _<_ P
descent∧wf⇒infiniteDescent wf = descent∧acc⇒infiniteDescentFrom (wf _)

descent∧acc⇒unsatisfiable : Acc _<_ ⊆ ∁ P
descent∧acc⇒unsatisfiable {x} = Some.wfRec (∁ P) rec x
where
rec : _
rec y rec[y] py = let z , z<y , pz = descent py in rec[y] z<y pz

descent∧wf⇒empty : WellFounded _<_ → Empty P
descent∧wf⇒empty wf x = descent∧acc⇒unsatisfiable (wf x)

------------------------------------------------------------------------
-- Results about descent only from accessible elements

module _ (accDescent : Acc _<_ ⊆ DescentFrom _<_ P) where

private
descent∩ : Descent _<_ (P ∩ Acc _<_)
descent∩ (px , acc[x]) =
let y , y<x , py = accDescent acc[x] px
in y , y<x , py , acc-inverse acc[x] y<x

accDescent∧acc⇒infiniteDescentFrom : Acc _<_ ⊆ InfiniteDescentFrom _<_ P
accDescent∧acc⇒infiniteDescentFrom acc[x] px =
let f , sequence[f] , Π[[P∩Acc]∘f] = descent∧acc⇒infiniteDescentFrom descent∩ acc[x] (px , acc[x])
in f , sequence[f] , proj₁ ∘ Π[[P∩Acc]∘f]

accDescent∧wf⇒infiniteDescent : WellFounded _<_ → InfiniteDescent _<_ P
accDescent∧wf⇒infiniteDescent wf = accDescent∧acc⇒infiniteDescentFrom (wf _)

accDescent∧acc⇒unsatisfiable : Acc _<_ ⊆ ∁ P
accDescent∧acc⇒unsatisfiable acc[x] px = descent∧acc⇒unsatisfiable descent∩ acc[x] (px , acc[x])

wf⇒empty : WellFounded _<_ → Empty P
wf⇒empty wf x = accDescent∧acc⇒unsatisfiable (wf x)

------------------------------------------------------------------------
-- Results about transitively-closed descent only from accessible elements

module _ (accDescent⁺ : Acc _<_ ⊆ DescentFrom (TransClosure _<_) P) where

private
descent : Acc (TransClosure _<_) ⊆ DescentFrom (TransClosure _<_) P
descent = accDescent⁺ ∘ accessible⁻ _

accDescent⁺∧acc⇒infiniteDescentFrom⁺ : Acc _<_ ⊆ InfiniteDescentFrom⁺ _<_ P
accDescent⁺∧acc⇒infiniteDescentFrom⁺ acc[x] px
with f , (f0≡x , sequence[f]) , Π[P∘f]
← accDescent∧acc⇒infiniteDescentFrom descent (accessible _ acc[x]) px
= f , (f0≡x , sequence⁺ sequence[f]) , Π[P∘f]

accDescent⁺∧wf⇒infiniteDescent⁺ : WellFounded _<_ → InfiniteDescent⁺ _<_ P
accDescent⁺∧wf⇒infiniteDescent⁺ wf = accDescent⁺∧acc⇒infiniteDescentFrom⁺ (wf _)

accDescent⁺∧acc⇒unsatisfiable : Acc _<_ ⊆ ∁ P
accDescent⁺∧acc⇒unsatisfiable = accDescent∧acc⇒unsatisfiable descent ∘ accessible _

accDescent⁺∧wf⇒empty : WellFounded _<_ → Empty P
accDescent⁺∧wf⇒empty = wf⇒empty descent ∘ (wellFounded _)

------------------------------------------------------------------------
-- Finally: the (classical) no smallest counterexample principle itself

module _ (stable : Stable P) (noSmallest : NoSmallestCounterExample _<_ P) where

noSmallestCounterExample∧acc⇒satisfiable : Acc _<_ ⊆ P
noSmallestCounterExample∧acc⇒satisfiable =
stable _ ∘ accDescent⁺∧acc⇒unsatisfiable noSmallest

noSmallestCounterExample∧wf⇒universal : WellFounded _<_ → Universal P
noSmallestCounterExample∧wf⇒universal wf =
stable _ ∘ accDescent⁺∧wf⇒empty noSmallest wf
4 changes: 4 additions & 0 deletions src/Relation/Binary/Construct/Closure/Transitive.agda
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ module _ (_∼_ : Rel A ℓ) where
transitive : Transitive _∼⁺_
transitive = _++_

transitive⁻ : Transitive _∼_ → _∼⁺_ ⇒ _∼_
transitive⁻ trans [ x∼y ] = x∼y
transitive⁻ trans (x∼y ∷ x∼⁺y) = trans x∼y (transitive⁻ trans x∼⁺y)

accessible⁻ : ∀ {x} → Acc _∼⁺_ x → Acc _∼_ x
accessible⁻ = ∼⊆∼⁺.accessible

Expand Down
5 changes: 3 additions & 2 deletions src/Relation/Unary.agda
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ open import Data.Product.Base using (_×_; _,_; Σ-syntax; ∃; uncurry; swap)
open import Data.Sum.Base using (_⊎_; [_,_])
open import Function.Base using (_∘_; _|>_)
open import Level using (Level; _⊔_; 0ℓ; suc; Lift)
open import Relation.Nullary as Nullary using (¬_; Dec; True)
open import Relation.Nullary.Decidable.Core using (Dec; True)
open import Relation.Nullary as Nullary using (¬_)
open import Relation.Binary.PropositionalEquality.Core using (_≡_)

private
Expand Down Expand Up @@ -173,7 +174,7 @@ Irrelevant P = ∀ {x} → Nullary.Irrelevant (P x)
Recomputable : Pred A ℓ → Set _
Recomputable P = ∀ {x} → Nullary.Recomputable (P x)

-- Weak Decidability
-- Stability - instances of P are stable wrt double negation

Stable : Pred A ℓ → Set _
Stable P = ∀ x → Nullary.Stable (P x)
MatthewDaggitt marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading