Skip to content

Commit 5680458

Browse files
jamesmckinnaMatthewDaggittgallaisplt-amyTaneb
committedJul 10, 2024
'No infinite descent' for (Accessible elements of) WellFounded relations (#2126)
* basic result * added missing lemma; is there a better name for this? * renamed lemma * final tidying up; `CHANGELOG` * final tidying up * missing `CHANGELOG` entry * `InfiniteDescent` definition and proof * revised `InfiniteDescent` definition and proof * major revision: renames things, plus additional corollaries * spacing * added `NoSmallestCounterExample` principles for `Stable` predicates * refactoring; move `Stable` to `Relation.Unary` * refactoring; remove explicit definition of `CounterExample` * refactoring; rename qualified `import` * [fixes #2130] Moving `Properties.HeytingAlgebra` from `Relation.Binary` to `Relation.Binary.Lattice` (#2131) * [fixes #2127] Fixes #1930 `import` bug (#2128) * [fixes #1214] Add negated ordering relation symbols systematically to `Relation.Binary.*` (#2095) * Refactoring (inversion) properties of `_<_` on `Nat`, plus consequences (#2000) * Bump CI tests to Agda-2.6.4 (#2134) * Remove `Algebra.Ordered` (#2133) * [ fix ] missing name in LICENCE file (#2139) * Add new blocking primitives to `Reflection.TCM` (#1972) * Change definition of `IsStrictTotalOrder` (#2137) * Add _<$>_ operator for Function bundle (#2144) * [ fix #2086 ] new web deployment strategy (#2147) * [ admin ] fix sorting logic (#2151) With the previous script we were sorting entries of the form html/vX.Y.Z/index.html but the order is such that vX.Y/ < vX.Y.Z/ and so we were ending up with v1.7 coming after v1.7.3. This fixes that by using sed to get rid of the html/ prefix and the /index.html suffix before the sorting phase. * Add coincidence law to modules (#1898) * Make reasoning modular by adding new `Reasoning.Syntax` module (#2152) * Fixes typos identified in #2154 (#2158) * tackles #2124 as regards `case_return_of_` (#2157) * Rename preorder ~ relation reasoning combinators (#2156) * Move ≡-Reasoning from Core to Properties and implement using syntax (#2159) * Add consistent deprecation warnings to old function hierarchy (#2163) * Rename symmetric reasoning combinators. Minimal set of changes (#2160) * Restore 'return' as an alias for 'pure' (#2164) * [ fix #2153 ] Properly re-export specialised combinators (#2161) * Connect `LeftInverse` with (`Split`)`Surjection` (#2054) * Added remaining flipped and negated relations to binary relation bundles (#2162) * Tidy up CHANGELOG in preparation for release candidate (#2165) * Spellcheck CHANGELOG (#2167) * spellcheck; `fix-whitespace`; unfixed: a few alignment issues; typo `predications` to `predicates` in `Relation.Unary.Relation.Binary.Equality` * Fixed Agda version typo in README (#2176) * Fixed in deprecation warning for `<-transˡ` (#2173) * Bump Haskell CI (original!) to latest minor GHC versions (#2187) * [fixes #2175] Documentation misc. typos etc. for RC1 (#2183) * missing comma! * corrected reference to `README.Design.Decidability` * typo: capitalisation * updated `installation-guide` * added word to `NonZero` section heading * Run workflows on any PR * Add merge-group trigger to workflows --------- Co-authored-by: MatthewDaggitt <[email protected]> * [fixes #2178] regularise and specify/systematise, the conventions for symbol usage (#2185) * regularise and specify/systematise, the conventions for symbol usage * typos/revisions * Move `T?` to `Relation.Nullary.Decidable.Core` (#2189) * Move `T?` to `Relation.Nullary.Decidable.Core` * Var name fix * Some refactoring * Fix failing tests and address remaining comments * Fix style-guide * Make decidable versions of sublist functions the default (#2186) * Make decdable versions of sublist functions the default * Remove imports Bool.Properties * Address comments * new `CHANGELOG` * resolved merge conflict * resolved merge conflict, this time * revised in line with review comments * tweaked `export`s; does that fix things now? * Fix merge mistake * Refactored to remove a indirection and nested modules * Touch up names * Reintroduce anonymous module for descent * cosmetics asper final comment --------- Co-authored-by: MatthewDaggitt <[email protected]> Co-authored-by: G. Allais <[email protected]> Co-authored-by: Amélia <[email protected]> Co-authored-by: Nathan van Doorn <[email protected]> Co-authored-by: James Wood <[email protected]> Co-authored-by: Andreas Abel <[email protected]>
1 parent dd5d382 commit 5680458

File tree

4 files changed

+210
-2
lines changed

4 files changed

+210
-2
lines changed
 

‎CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ New modules
5050
-----------
5151
* `Algebra.Module.Bundles.Raw`: raw bundles for module-like algebraic structures
5252

53+
* Consequences of 'infinite descent' for (accessible elements of) well-founded relations:
54+
```agda
55+
Induction.InfiniteDescent
56+
```
57+
5358
* The unique morphism from the initial, resp. terminal, algebra:
5459
```agda
5560
Algebra.Morphism.Construct.Initial
@@ -254,6 +259,15 @@ Additions to existing modules
254259
* Added new functions in `Data.String.Base`:
255260
```agda
256261
map : (Char → Char) → String → String
262+
263+
* Added new definition in `Relation.Binary.Construct.Closure.Transitive`
264+
```
265+
transitive⁻ : Transitive _∼_ → TransClosure _∼_ ⇒ _∼_
266+
```
267+
268+
* Added new definition in `Relation.Unary`
269+
```
270+
Stable : Pred A ℓ → Set _
257271
```
258272
259273
* In `Function.Bundles`, added `_⟶ₛ_` as a synonym for `Func` that can

‎src/Induction/InfiniteDescent.agda

+189
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
------------------------------------------------------------------------
2+
-- The Agda standard library
3+
--
4+
-- A standard consequence of accessibility/well-foundedness:
5+
-- the impossibility of 'infinite descent' from any (accessible)
6+
-- element x satisfying P to 'smaller' y also satisfying P
7+
------------------------------------------------------------------------
8+
9+
{-# OPTIONS --cubical-compatible --safe #-}
10+
11+
module Induction.InfiniteDescent where
12+
13+
open import Data.Nat.Base as ℕ using (ℕ; zero; suc)
14+
open import Data.Nat.Properties as ℕ
15+
open import Data.Product.Base using (_,_; proj₁; ∃-syntax; _×_)
16+
open import Function.Base using (_∘_)
17+
open import Induction.WellFounded
18+
using (WellFounded; Acc; acc; acc-inverse; module Some)
19+
open import Level using (Level)
20+
open import Relation.Binary.Core using (Rel)
21+
open import Relation.Binary.Construct.Closure.Transitive
22+
open import Relation.Binary.PropositionalEquality.Core
23+
open import Relation.Nullary.Negation.Core as Negation using (¬_)
24+
open import Relation.Unary
25+
using (Pred; ∁; _∩_; _⊆_; _⇒_; Universal; IUniversal; Stable; Empty)
26+
27+
private
28+
variable
29+
a r ℓ : Level
30+
A : Set a
31+
f : A
32+
_<_ : Rel A r
33+
P : Pred A ℓ
34+
35+
------------------------------------------------------------------------
36+
-- Definitions
37+
38+
InfiniteDescendingSequence : Rel A r (ℕ A) Set _
39+
InfiniteDescendingSequence _<_ f = n f (suc n) < f n
40+
41+
InfiniteDescendingSequenceFrom : Rel A r (ℕ A) Pred A _
42+
InfiniteDescendingSequenceFrom _<_ f x = f zero ≡ x × InfiniteDescendingSequence _<_ f
43+
44+
InfiniteDescendingSequence⁺ : Rel A r (ℕ A) Set _
45+
InfiniteDescendingSequence⁺ _<_ f = {m n} m ℕ.< n TransClosure _<_ (f n) (f m)
46+
47+
InfiniteDescendingSequenceFrom⁺ : Rel A r (ℕ A) Pred A _
48+
InfiniteDescendingSequenceFrom⁺ _<_ f x = f zero ≡ x × InfiniteDescendingSequence⁺ _<_ f
49+
50+
DescentFrom : Rel A r Pred A ℓ Pred A _
51+
DescentFrom _<_ P x = P x ∃[ y ] y < x × P y
52+
53+
Descent : Rel A r Pred A ℓ Set _
54+
Descent _<_ P = {x} DescentFrom _<_ P x
55+
56+
InfiniteDescentFrom : Rel A r Pred A ℓ Pred A _
57+
InfiniteDescentFrom _<_ P x = P x ∃[ f ] InfiniteDescendingSequenceFrom _<_ f x × n P (f n)
58+
59+
InfiniteDescent : Rel A r Pred A ℓ Set _
60+
InfiniteDescent _<_ P = {x} InfiniteDescentFrom _<_ P x
61+
62+
InfiniteDescentFrom⁺ : Rel A r Pred A ℓ Pred A _
63+
InfiniteDescentFrom⁺ _<_ P x = P x ∃[ f ] InfiniteDescendingSequenceFrom⁺ _<_ f x × n P (f n)
64+
65+
InfiniteDescent⁺ : Rel A r Pred A ℓ Set _
66+
InfiniteDescent⁺ _<_ P = {x} InfiniteDescentFrom⁺ _<_ P x
67+
68+
NoSmallestCounterExample : Rel A r Pred A ℓ Set _
69+
NoSmallestCounterExample _<_ P = {x} Acc _<_ x DescentFrom (TransClosure _<_) (∁ P) x
70+
71+
------------------------------------------------------------------------
72+
-- We can swap between transitively closed and non-transitively closed
73+
-- definitions
74+
75+
sequence⁺ : InfiniteDescendingSequence (TransClosure _<_) f
76+
InfiniteDescendingSequence⁺ _<_ f
77+
sequence⁺ {_<_ = _<_} {f = f} seq[f] = seq⁺[f]′ ∘ ℕ.<⇒<′
78+
where
79+
seq⁺[f]′ : {m n} m ℕ.<′ n TransClosure _<_ (f n) (f m)
80+
seq⁺[f]′ ℕ.<′-base = seq[f] _
81+
seq⁺[f]′ (ℕ.<′-step m<′n) = seq[f] _ ++ seq⁺[f]′ m<′n
82+
83+
sequence⁻ : InfiniteDescendingSequence⁺ _<_ f
84+
InfiniteDescendingSequence (TransClosure _<_) f
85+
sequence⁻ seq[f] = seq[f] ∘ n<1+n
86+
87+
------------------------------------------------------------------------
88+
-- Results about unrestricted descent
89+
90+
module _ (descent : Descent _<_ P) where
91+
92+
descent∧acc⇒infiniteDescentFrom : (Acc _<_) ⊆ (InfiniteDescentFrom _<_ P)
93+
descent∧acc⇒infiniteDescentFrom {x} =
94+
Some.wfRec (InfiniteDescentFrom _<_ P) rec x
95+
where
96+
rec : _
97+
rec y rec[y] py
98+
with z , z<y , pz descent py
99+
with g , (g0≡z , g<P) , Π[P∘g] rec[y] z<y pz
100+
= h , (h0≡y , h<P) , Π[P∘h]
101+
where
102+
h : _
103+
h zero = y
104+
h (suc n) = g n
105+
106+
h0≡y : h zero ≡ y
107+
h0≡y = refl
108+
109+
h<P : n h (suc n) < h n
110+
h<P zero rewrite g0≡z = z<y
111+
h<P (suc n) = g<P n
112+
113+
Π[P∘h] : n P (h n)
114+
Π[P∘h] zero rewrite g0≡z = py
115+
Π[P∘h] (suc n) = Π[P∘g] n
116+
117+
descent∧wf⇒infiniteDescent : WellFounded _<_ InfiniteDescent _<_ P
118+
descent∧wf⇒infiniteDescent wf = descent∧acc⇒infiniteDescentFrom (wf _)
119+
120+
descent∧acc⇒unsatisfiable : Acc _<_ ⊆ ∁ P
121+
descent∧acc⇒unsatisfiable {x} = Some.wfRec (∁ P) rec x
122+
where
123+
rec : _
124+
rec y rec[y] py = let z , z<y , pz = descent py in rec[y] z<y pz
125+
126+
descent∧wf⇒empty : WellFounded _<_ Empty P
127+
descent∧wf⇒empty wf x = descent∧acc⇒unsatisfiable (wf x)
128+
129+
------------------------------------------------------------------------
130+
-- Results about descent only from accessible elements
131+
132+
module _ (accDescent : Acc _<_ ⊆ DescentFrom _<_ P) where
133+
134+
private
135+
descent∩ : Descent _<_ (P ∩ Acc _<_)
136+
descent∩ (px , acc[x]) =
137+
let y , y<x , py = accDescent acc[x] px
138+
in y , y<x , py , acc-inverse acc[x] y<x
139+
140+
accDescent∧acc⇒infiniteDescentFrom : Acc _<_ ⊆ InfiniteDescentFrom _<_ P
141+
accDescent∧acc⇒infiniteDescentFrom acc[x] px =
142+
let f , sequence[f] , Π[[P∩Acc]∘f] = descent∧acc⇒infiniteDescentFrom descent∩ acc[x] (px , acc[x])
143+
in f , sequence[f] , proj₁ ∘ Π[[P∩Acc]∘f]
144+
145+
accDescent∧wf⇒infiniteDescent : WellFounded _<_ InfiniteDescent _<_ P
146+
accDescent∧wf⇒infiniteDescent wf = accDescent∧acc⇒infiniteDescentFrom (wf _)
147+
148+
accDescent∧acc⇒unsatisfiable : Acc _<_ ⊆ ∁ P
149+
accDescent∧acc⇒unsatisfiable acc[x] px = descent∧acc⇒unsatisfiable descent∩ acc[x] (px , acc[x])
150+
151+
wf⇒empty : WellFounded _<_ Empty P
152+
wf⇒empty wf x = accDescent∧acc⇒unsatisfiable (wf x)
153+
154+
------------------------------------------------------------------------
155+
-- Results about transitively-closed descent only from accessible elements
156+
157+
module _ (accDescent⁺ : Acc _<_ ⊆ DescentFrom (TransClosure _<_) P) where
158+
159+
private
160+
descent : Acc (TransClosure _<_) ⊆ DescentFrom (TransClosure _<_) P
161+
descent = accDescent⁺ ∘ accessible⁻ _
162+
163+
accDescent⁺∧acc⇒infiniteDescentFrom⁺ : Acc _<_ ⊆ InfiniteDescentFrom⁺ _<_ P
164+
accDescent⁺∧acc⇒infiniteDescentFrom⁺ acc[x] px
165+
with f , (f0≡x , sequence[f]) , Π[P∘f]
166+
accDescent∧acc⇒infiniteDescentFrom descent (accessible _ acc[x]) px
167+
= f , (f0≡x , sequence⁺ sequence[f]) , Π[P∘f]
168+
169+
accDescent⁺∧wf⇒infiniteDescent⁺ : WellFounded _<_ InfiniteDescent⁺ _<_ P
170+
accDescent⁺∧wf⇒infiniteDescent⁺ wf = accDescent⁺∧acc⇒infiniteDescentFrom⁺ (wf _)
171+
172+
accDescent⁺∧acc⇒unsatisfiable : Acc _<_ ⊆ ∁ P
173+
accDescent⁺∧acc⇒unsatisfiable = accDescent∧acc⇒unsatisfiable descent ∘ accessible _
174+
175+
accDescent⁺∧wf⇒empty : WellFounded _<_ Empty P
176+
accDescent⁺∧wf⇒empty = wf⇒empty descent ∘ (wellFounded _)
177+
178+
------------------------------------------------------------------------
179+
-- Finally: the (classical) no smallest counterexample principle itself
180+
181+
module _ (stable : Stable P) (noSmallest : NoSmallestCounterExample _<_ P) where
182+
183+
noSmallestCounterExample∧acc⇒satisfiable : Acc _<_ ⊆ P
184+
noSmallestCounterExample∧acc⇒satisfiable =
185+
stable _ ∘ accDescent⁺∧acc⇒unsatisfiable noSmallest
186+
187+
noSmallestCounterExample∧wf⇒universal : WellFounded _<_ Universal P
188+
noSmallestCounterExample∧wf⇒universal wf =
189+
stable _ ∘ accDescent⁺∧wf⇒empty noSmallest wf

‎src/Relation/Binary/Construct/Closure/Transitive.agda

+4
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ module _ (_∼_ : Rel A ℓ) where
7070
transitive : Transitive _∼⁺_
7171
transitive = _++_
7272

73+
transitive⁻ : Transitive _∼_ _∼⁺_ ⇒ _∼_
74+
transitive⁻ trans [ x∼y ] = x∼y
75+
transitive⁻ trans (x∼y ∷ x∼⁺y) = trans x∼y (transitive⁻ trans x∼⁺y)
76+
7377
accessible⁻ : {x} Acc _∼⁺_ x Acc _∼_ x
7478
accessible⁻ = ∼⊆∼⁺.accessible
7579

‎src/Relation/Unary.agda

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ open import Data.Product.Base using (_×_; _,_; Σ-syntax; ∃; uncurry; swap)
1414
open import Data.Sum.Base using (_⊎_; [_,_])
1515
open import Function.Base using (_∘_; _|>_)
1616
open import Level using (Level; _⊔_; 0ℓ; suc; Lift)
17-
open import Relation.Nullary as Nullary using (¬_; Dec; True)
17+
open import Relation.Nullary.Decidable.Core using (Dec; True)
18+
open import Relation.Nullary as Nullary using (¬_)
1819
open import Relation.Binary.PropositionalEquality.Core using (_≡_)
1920

2021
private
@@ -173,7 +174,7 @@ Irrelevant P = ∀ {x} → Nullary.Irrelevant (P x)
173174
Recomputable : Pred A ℓ Set _
174175
Recomputable P = {x} Nullary.Recomputable (P x)
175176

176-
-- Weak Decidability
177+
-- Stability - instances of P are stable wrt double negation
177178

178179
Stable : Pred A ℓ Set _
179180
Stable P = x Nullary.Stable (P x)

0 commit comments

Comments
 (0)
Please sign in to comment.