-
Notifications
You must be signed in to change notification settings - Fork 248
'No infinite descent' for (Acc
essible elements of) WellFounded
relations
#2126
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
Merged
Merged
Changes from 55 commits
Commits
Show all changes
64 commits
Select commit
Hold shift + click to select a range
63d6ca0
basic result
jamesmckinna d549c62
added missing lemma; is there a better name for this?
jamesmckinna 60d22e6
renamed lemma
jamesmckinna ec09669
final tidying up; `CHANGELOG`
jamesmckinna 26dfcc5
final tidying up
jamesmckinna 00e0083
missing `CHANGELOG` entry
jamesmckinna c1b3ed9
`InfiniteDescent` definition and proof
jamesmckinna d310349
revised `InfiniteDescent` definition and proof
jamesmckinna b028dc9
major revision: renames things, plus additional corollaries
jamesmckinna 8dec2ee
spacing
jamesmckinna 17cc4b4
added `NoSmallestCounterExample` principles for `Stable` predicates
jamesmckinna fb8480b
refactoring; move `Stable` to `Relation.Unary`
jamesmckinna 96175ed
refactoring; remove explicit definition of `CounterExample`
jamesmckinna e37fe2a
refactoring; rename qualified `import`
jamesmckinna 596aac2
[fixes #2130] Moving `Properties.HeytingAlgebra` from `Relation.Binar…
jamesmckinna e06c02a
[fixes #2127] Fixes #1930 `import` bug (#2128)
jamesmckinna eee9f58
[fixes #1214] Add negated ordering relation symbols systematically to…
jamesmckinna 81a7b28
Refactoring (inversion) properties of `_<_` on `Nat`, plus consequenc…
jamesmckinna d39b849
Bump CI tests to Agda-2.6.4 (#2134)
MatthewDaggitt cb92af1
Remove `Algebra.Ordered` (#2133)
MatthewDaggitt 135951f
[ fix ] missing name in LICENCE file (#2139)
gallais a843d0d
Add new blocking primitives to `Reflection.TCM` (#1972)
plt-amy aa6ef23
Change definition of `IsStrictTotalOrder` (#2137)
MatthewDaggitt 6e375c2
Add _<$>_ operator for Function bundle (#2144)
MatthewDaggitt 222c238
[ fix #2086 ] new web deployment strategy (#2147)
gallais 347a079
[ admin ] fix sorting logic (#2151)
gallais d91e21d
Add coincidence law to modules (#1898)
Taneb 010498b
Make reasoning modular by adding new `Reasoning.Syntax` module (#2152)
MatthewDaggitt 9bf34e0
Fixes typos identified in #2154 (#2158)
jamesmckinna b0c95bc
tackles #2124 as regards `case_return_of_` (#2157)
jamesmckinna ef66f77
Rename preorder ~ relation reasoning combinators (#2156)
MatthewDaggitt 33811e5
Move ≡-Reasoning from Core to Properties and implement using syntax (…
MatthewDaggitt cc0749c
Add consistent deprecation warnings to old function hierarchy (#2163)
MatthewDaggitt fe5fddc
Rename symmetric reasoning combinators. Minimal set of changes (#2160)
MatthewDaggitt 6367fd5
Restore 'return' as an alias for 'pure' (#2164)
MatthewDaggitt ce4bd12
[ fix #2153 ] Properly re-export specialised combinators (#2161)
gallais c5a3693
Connect `LeftInverse` with (`Split`)`Surjection` (#2054)
laMudri eb5f308
Added remaining flipped and negated relations to binary relation bund…
MatthewDaggitt aeed7d5
Tidy up CHANGELOG in preparation for release candidate (#2165)
MatthewDaggitt d2e94ef
Spellcheck CHANGELOG (#2167)
jamesmckinna 0befc0d
Fixed Agda version typo in README (#2176)
jamesmckinna cd34417
Fixed in deprecation warning for `<-transˡ` (#2173)
jamesmckinna 496eded
Bump Haskell CI (original!) to latest minor GHC versions (#2187)
andreasabel 2fda34d
[fixes #2175] Documentation misc. typos etc. for RC1 (#2183)
jamesmckinna 188f74c
[fixes #2178] regularise and specify/systematise, the conventions for…
jamesmckinna 200ef72
Move `T?` to `Relation.Nullary.Decidable.Core` (#2189)
MatthewDaggitt 9be7cea
Make decidable versions of sublist functions the default (#2186)
MatthewDaggitt 8270e59
Merge branch 'master' into NoInfiniteDescent
jamesmckinna a45f04d
new `CHANGELOG`
jamesmckinna 10fa8ed
Merge branch 'master' into NoInfiniteDescent
jamesmckinna fe3123d
Merge branch 'master' into NoInfiniteDescent
jamesmckinna 0c2288f
resolved merge conflict
jamesmckinna d074a0d
resolved merge conflict, this time
jamesmckinna 5e66965
revised in line with review comments
jamesmckinna 9de7d0f
Merge branch 'master' into NoInfiniteDescent
jamesmckinna 2f1fa64
tweaked `export`s; does that fix things now?
jamesmckinna 0295bb7
Merge branch 'master' into NoInfiniteDescent
jamesmckinna cc280a4
Merge branch 'master' into NoInfiniteDescent
MatthewDaggitt 4518858
Fix merge mistake
MatthewDaggitt f84d319
Refactored to remove a indirection and nested modules
MatthewDaggitt 7bc76dd
Touch up names
MatthewDaggitt 88452ff
Reintroduce anonymous module for descent
MatthewDaggitt 07f1a00
cosmetics asper final comment
jamesmckinna e3fa327
Merge branch 'master' into NoInfiniteDescent
MatthewDaggitt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,235 @@ | ||
------------------------------------------------------------------------ | ||
-- 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.NoInfiniteDescent 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) | ||
|
||
private | ||
variable | ||
a r ℓ : Level | ||
A : Set a | ||
|
||
------------------------------------------------------------------------ | ||
-- Definitions | ||
|
||
module _ (f : ℕ → A) where | ||
|
||
module _ (_<_ : Rel A r) where | ||
|
||
InfiniteDescendingSequence : Set _ | ||
InfiniteDescendingSequence = ∀ n → f (suc n) < f n | ||
|
||
InfiniteSequenceFrom : Pred A _ | ||
InfiniteSequenceFrom x = f zero ≡ x × InfiniteDescendingSequence | ||
|
||
module _ (_<_ : Rel A r) where | ||
|
||
private | ||
|
||
_<⁺_ = TransClosure _<_ | ||
|
||
InfiniteDescendingSequence⁺ : Set _ | ||
InfiniteDescendingSequence⁺ = ∀ {m n} → m ℕ.< n → f n <⁺ f m | ||
|
||
InfiniteSequence⁺From : Pred A _ | ||
InfiniteSequence⁺From x = f zero ≡ x × InfiniteDescendingSequence⁺ | ||
|
||
sequence⁺ : InfiniteDescendingSequence _<⁺_ → InfiniteDescendingSequence⁺ | ||
sequence⁺ seq[f] = seq⁺[f]′ ∘ ℕ.<⇒<′ | ||
where | ||
seq⁺[f]′ : ∀ {m n} → m ℕ.<′ n → f n <⁺ f m | ||
seq⁺[f]′ ℕ.<′-base = seq[f] _ | ||
seq⁺[f]′ (ℕ.<′-step m<′n) = seq[f] _ ++ seq⁺[f]′ m<′n | ||
|
||
sequence⁻ : InfiniteDescendingSequence⁺ → InfiniteDescendingSequence _<⁺_ | ||
sequence⁻ seq[f] = seq[f] ∘ n<1+n | ||
|
||
module InfiniteDescent (_<_ : Rel A r) (P : Pred A ℓ) where | ||
|
||
DescentAt : Pred A _ | ||
DescentAt x = P x → ∃[ y ] y < x × P y | ||
|
||
Acc⇒Descent : Set _ | ||
Acc⇒Descent = ∀ {x} → Acc _<_ x → DescentAt x | ||
|
||
Descent : Set _ | ||
Descent = ∀ {x} → DescentAt x | ||
|
||
InfiniteDescentAt : Pred A _ | ||
InfiniteDescentAt x = P x → ∃[ f ] InfiniteSequenceFrom f _<_ x × ∀ z → P (f z) | ||
|
||
Acc⇒InfiniteDescent : Set _ | ||
Acc⇒InfiniteDescent = ∀ {x} → Acc _<_ x → InfiniteDescentAt x | ||
|
||
InfiniteDescent : Set _ | ||
InfiniteDescent = ∀ {x} → InfiniteDescentAt x | ||
|
||
------------------------------------------------------------------------ | ||
-- Basic lemmas: assume unrestricted descent | ||
|
||
module Lemmas (descent : Descent) where | ||
|
||
acc⇒infiniteDescent : Acc⇒InfiniteDescent | ||
acc⇒infiniteDescent {x} = Some.wfRec InfiniteDescentAt 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 | ||
= f , (f0≡y , f<P) , Π[P∘f] | ||
where | ||
f : ℕ → A | ||
f zero = y | ||
f (suc n) = g n | ||
|
||
f0≡y : f zero ≡ y | ||
f0≡y = refl | ||
|
||
f<P : ∀ n → f (suc n) < f n | ||
f<P zero rewrite g0≡z = z<y | ||
f<P (suc n) = g<P n | ||
|
||
Π[P∘f] : ∀ n → P (f n) | ||
Π[P∘f] zero rewrite g0≡z = py | ||
Π[P∘f] (suc n) = Π[P∘g] n | ||
|
||
wf⇒infiniteDescent : WellFounded _<_ → InfiniteDescent | ||
wf⇒infiniteDescent wf = acc⇒infiniteDescent (wf _) | ||
|
||
acc⇒noInfiniteDescent : ∀ {x} → Acc _<_ x → ¬ P x | ||
acc⇒noInfiniteDescent {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 | ||
|
||
wf⇒noInfiniteDescent : WellFounded _<_ → ∀ {x} → ¬ P x | ||
wf⇒noInfiniteDescent wf = acc⇒noInfiniteDescent (wf _) | ||
|
||
------------------------------------------------------------------------ | ||
-- Corollaries: assume descent only for Acc _<_ elements | ||
|
||
module _ (_<_ : Rel A r) (P : Pred A ℓ) where | ||
|
||
open InfiniteDescent _<_ P | ||
|
||
module Corollaries (descent : Acc⇒Descent) where | ||
|
||
private | ||
|
||
P∩Acc : Pred A _ | ||
P∩Acc = P ∩ (Acc _<_) | ||
|
||
module ID∩ = InfiniteDescent _<_ P∩Acc | ||
|
||
descent∩ : ID∩.Descent | ||
descent∩ (px , acc[x]) = | ||
let y , y<x , py = descent acc[x] px | ||
in y , y<x , py , acc-inverse acc[x] y<x | ||
|
||
module Lemmas∩ = ID∩.Lemmas descent∩ | ||
|
||
acc⇒infiniteDescent : Acc⇒InfiniteDescent | ||
acc⇒infiniteDescent acc[x] px = | ||
let f , sequence[f] , Π[[P∩Acc]∘f] = Lemmas∩.acc⇒infiniteDescent acc[x] (px , acc[x]) | ||
in f , sequence[f] , proj₁ ∘ Π[[P∩Acc]∘f] | ||
|
||
wf⇒infiniteDescent : WellFounded _<_ → InfiniteDescent | ||
wf⇒infiniteDescent wf = acc⇒infiniteDescent (wf _) | ||
|
||
acc⇒noInfiniteDescent : ∀ {x} → Acc _<_ x → ¬ P x | ||
acc⇒noInfiniteDescent acc[x] px = Lemmas∩.acc⇒noInfiniteDescent acc[x] (px , acc[x]) | ||
|
||
wf⇒noInfiniteDescent : WellFounded _<_ → ∀ {x} → ¬ P x | ||
wf⇒noInfiniteDescent wf = acc⇒noInfiniteDescent (wf _) | ||
|
||
|
||
------------------------------------------------------------------------ | ||
-- Further corollaries: assume _<⁺_ descent only for Acc _<⁺_ elements | ||
|
||
module FurtherCorollaries (_<_ : Rel A r) (P : Pred A ℓ) where | ||
|
||
private | ||
|
||
_<⁺_ = TransClosure _<_ | ||
|
||
module ID⁺ = InfiniteDescent _<⁺_ P | ||
|
||
DescentAt⁺ = ID⁺.DescentAt | ||
Descent⁺ = ID⁺.Descent | ||
|
||
Acc⇒Descent⁺ : Set _ | ||
Acc⇒Descent⁺ = ∀ {x} → Acc _<_ x → DescentAt⁺ x | ||
|
||
InfiniteDescentAt⁺ : Pred A _ | ||
InfiniteDescentAt⁺ x = P x → ∃[ f ] InfiniteSequence⁺From f _<_ x × ∀ z → P (f z) | ||
|
||
Acc⇒InfiniteDescent⁺ : Set _ | ||
Acc⇒InfiniteDescent⁺ = ∀ {x} → Acc _<_ x → InfiniteDescentAt⁺ x | ||
|
||
InfiniteDescent⁺ : Set _ | ||
InfiniteDescent⁺ = ∀ {x} → InfiniteDescentAt⁺ x | ||
|
||
module _ (descent⁺ : Acc⇒Descent⁺) where | ||
|
||
private | ||
descent : ID⁺.Acc⇒Descent | ||
descent = descent⁺ ∘ (accessible⁻ _) | ||
|
||
module Corollaries⁺ = Corollaries _ _ descent | ||
|
||
acc⇒infiniteDescent⁺ : Acc⇒InfiniteDescent⁺ | ||
acc⇒infiniteDescent⁺ acc[x] px | ||
with f , (f0≡x , sequence[f]) , Π[P∘f] ← Corollaries⁺.acc⇒infiniteDescent (accessible _ acc[x]) px | ||
= f , (f0≡x , sequence⁺ _ _ sequence[f]) , Π[P∘f] | ||
|
||
wf⇒infiniteDescent⁺ : WellFounded _<_ → InfiniteDescent⁺ | ||
wf⇒infiniteDescent⁺ wf = acc⇒infiniteDescent⁺ (wf _) | ||
|
||
acc⇒noInfiniteDescent⁺ : ∀ {x} → Acc _<_ x → ¬ P x | ||
acc⇒noInfiniteDescent⁺ = Corollaries⁺.acc⇒noInfiniteDescent ∘ (accessible _) | ||
|
||
wf⇒noInfiniteDescent⁺ : WellFounded _<_ → ∀ {x} → ¬ P x | ||
wf⇒noInfiniteDescent⁺ = Corollaries⁺.wf⇒noInfiniteDescent ∘ (wellFounded _) | ||
|
||
------------------------------------------------------------------------ | ||
-- Finally: the (classical) 'no smallest counterexample' principle itself | ||
|
||
module _ (_<_ : Rel A r) {P : Pred A ℓ} (stable : Stable P) where | ||
|
||
open FurtherCorollaries _<_ (∁ P) | ||
using (acc⇒noInfiniteDescent⁺; wf⇒noInfiniteDescent⁺) | ||
renaming (Acc⇒Descent⁺ to NoSmallestCounterExample) | ||
|
||
acc⇒noSmallestCounterExample : NoSmallestCounterExample → ∀ {x} → Acc _<_ x → P x | ||
acc⇒noSmallestCounterExample noSmallest = stable _ ∘ acc⇒noInfiniteDescent⁺ noSmallest | ||
|
||
wf⇒noSmallestCounterExample : WellFounded _<_ → NoSmallestCounterExample → ∀ {x} → P x | ||
wf⇒noSmallestCounterExample wf noSmallest = stable _ (wf⇒noInfiniteDescent⁺ noSmallest wf) | ||
|
||
------------------------------------------------------------------------ | ||
-- Exports | ||
|
||
open InfiniteDescent public | ||
open Corollaries public | ||
open FurtherCorollaries public | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.