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

WellFounded proofs for transitive closure #2082

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2929,6 +2929,13 @@ Other minor changes
f Preserves₂ ≈₁ ⟶ ≈₁ ⟶ ≈₂
```

* Added new proofs to `Relation.Binary.Construct.Closure.Transitive`:
```
accessible⁻ : ∀ {x} → Acc _∼⁺_ x → Acc _∼_ x
wellFounded⁻ : WellFounded _∼⁺_ → WellFounded _∼_
accessible : ∀ {x} → Acc _∼_ x → Acc _∼⁺_ x
```

* Added new operations in `Relation.Binary.PropositionalEquality.Properties`:
```
J : (B : (y : A) → x ≡ y → Set b) (p : x ≡ y) → B x refl → B y p
Expand Down
23 changes: 14 additions & 9 deletions src/Relation/Binary/Construct/Closure/Transitive.agda
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ module _ {_∼_ : Rel A ℓ} where
module _ (_∼_ : Rel A ℓ) where
private
_∼⁺_ = TransClosure _∼_
module ∼⊆∼⁺ = Subrelation {_<₂_ = _∼⁺_} [_]

reflexive : Reflexive _∼_ → Reflexive _∼⁺_
reflexive refl = [ refl ]
Expand All @@ -69,17 +70,21 @@ module _ (_∼_ : Rel A ℓ) where
transitive : Transitive _∼⁺_
transitive = _++_

wellFounded : WellFounded _∼_ → WellFounded _∼⁺_
wellFounded wf = λ x → acc (accessible′ (wf x))
where
downwardsClosed : ∀ {x y} → Acc _∼⁺_ y → x ∼ y → Acc _∼⁺_ x
downwardsClosed (acc rec) x∼y = acc (λ z z∼x → rec z (z∼x ∷ʳ x∼y))
accessible⁻ : ∀ {x} → Acc _∼⁺_ x → Acc _∼_ x
accessible⁻ = ∼⊆∼⁺.accessible

accessible′ : ∀ {x} → Acc _∼_ x → WfRec _∼⁺_ (Acc _∼⁺_) x
accessible′ (acc rec) y [ y∼x ] = acc (accessible′ (rec y y∼x))
accessible′ acc[x] y (y∼z ∷ z∼⁺x) =
downwardsClosed (accessible′ acc[x] _ z∼⁺x) y∼z
wellFounded⁻ : WellFounded _∼⁺_ → WellFounded _∼_
wellFounded⁻ = ∼⊆∼⁺.wellFounded

accessible : ∀ {x} → Acc _∼_ x → Acc _∼⁺_ x
accessible acc[x] = acc (wf-acc acc[x])
where
wf-acc : ∀ {x} → Acc _∼_ x → WfRec _∼⁺_ (Acc _∼⁺_) x
wf-acc (acc rec) _ [ y∼x ] = acc (wf-acc (rec _ y∼x))
wf-acc acc[x] _ (y∼z ∷ z∼⁺x) = acc-inverse (wf-acc acc[x] _ z∼⁺x) _ [ y∼z ]

wellFounded : WellFounded _∼_ → WellFounded _∼⁺_
wellFounded wf x = accessible (wf x)


------------------------------------------------------------------------
Expand Down