|
| 1 | +{-# OPTIONS --safe --without-K #-} |
| 2 | + |
| 3 | +-- Budgeted recursive-surface descent. |
| 4 | +-- |
| 5 | +-- Each recursive same-binder step consumes a finite amount of budget |
| 6 | +-- determined by the depth of the direct recursive derivation. This |
| 7 | +-- exposes a well-founded carrier for the recursive surface route even |
| 8 | +-- before the final unbudgeted well-foundedness theorem is available. |
| 9 | + |
| 10 | +module Ordinal.Buchholz.RecursiveSurfaceBudget where |
| 11 | + |
| 12 | +open import Data.Nat.Base using (ℕ; zero; suc; _+_; _<_) |
| 13 | +open import Data.Nat.Induction as NatInd using (<-wellFounded) |
| 14 | +open import Data.Nat.Properties using (+-suc; m≤m+n) |
| 15 | +open import Data.Product.Base using (_×_; _,_; proj₁; proj₂) |
| 16 | +open import Function.Base using (_on_) |
| 17 | +open import Induction.WellFounded using (WellFounded; wf⇒asym; module Subrelation) |
| 18 | +open import Relation.Binary.Construct.On as On using (wellFounded) |
| 19 | +open import Relation.Binary.Core using (Rel; _⇒_) |
| 20 | +open import Relation.Binary.PropositionalEquality using (subst) |
| 21 | +open import Relation.Nullary using (¬_) |
| 22 | + |
| 23 | +open import Ordinal.Buchholz.Syntax using (BT) |
| 24 | +open import Ordinal.Buchholz.IteratedExtendedOrder using |
| 25 | + ( LiftedOrder |
| 26 | + ; LiftedOrder-lift |
| 27 | + ) |
| 28 | +open import Ordinal.Buchholz.RecursiveSurfaceOrder using |
| 29 | + ( _<ᵇʳᶠ_ |
| 30 | + ; <ᵇʳᶠ-depth |
| 31 | + ; <ᵇʳᶠ⇒lifted |
| 32 | + ) |
| 33 | + |
| 34 | +BudgetedBT : Set |
| 35 | +BudgetedBT = ℕ × BT |
| 36 | + |
| 37 | +infix 4 _<ᵇʳᶠᵇ_ |
| 38 | + |
| 39 | +data _<ᵇʳᶠᵇ_ : BudgetedBT → BudgetedBT → Set where |
| 40 | + spend : ∀ {n x y} (p : x <ᵇʳᶠ y) → (n , x) <ᵇʳᶠᵇ (suc (n + <ᵇʳᶠ-depth p) , y) |
| 41 | + |
| 42 | +BudgetOrder : Rel BudgetedBT _ |
| 43 | +BudgetOrder = _<_ on proj₁ |
| 44 | + |
| 45 | +<ᵇʳᶠᵇ⇒budget : _<ᵇʳᶠᵇ_ ⇒ BudgetOrder |
| 46 | +<ᵇʳᶠᵇ⇒budget (spend {n} p) = m≤m+n (suc n) (<ᵇʳᶠ-depth p) |
| 47 | + |
| 48 | +wf-<ᵇʳᶠᵇ : WellFounded _<ᵇʳᶠᵇ_ |
| 49 | +wf-<ᵇʳᶠᵇ = |
| 50 | + let module SR = Subrelation <ᵇʳᶠᵇ⇒budget |
| 51 | + in SR.wellFounded (On.wellFounded proj₁ NatInd.<-wellFounded) |
| 52 | + |
| 53 | +<ᵇʳᶠᵇ-irreflexive : ∀ {s} → ¬ (s <ᵇʳᶠᵇ s) |
| 54 | +<ᵇʳᶠᵇ-irreflexive {s} p = wf⇒asym wf-<ᵇʳᶠᵇ p p |
| 55 | + |
| 56 | +LiftedOrder-raise-by |
| 57 | + : ∀ (k : ℕ) {n x y} |
| 58 | + → LiftedOrder n x y |
| 59 | + → LiftedOrder (k + n) x y |
| 60 | +LiftedOrder-raise-by zero p = p |
| 61 | +LiftedOrder-raise-by (suc k) {n} p = |
| 62 | + LiftedOrder-lift (k + n) (LiftedOrder-raise-by k p) |
| 63 | + |
| 64 | +<ᵇʳᶠᵇ⇒lifted : ∀ {sx sy} → sx <ᵇʳᶠᵇ sy → LiftedOrder (proj₁ sy) (proj₂ sx) (proj₂ sy) |
| 65 | +<ᵇʳᶠᵇ⇒lifted {sx = n , x} {sy = .(suc (n + <ᵇʳᶠ-depth p)) , y} (spend {n} {x} {y} p) = |
| 66 | + subst (λ t → LiftedOrder t x y) |
| 67 | + (+-suc n (<ᵇʳᶠ-depth p)) |
| 68 | + (LiftedOrder-raise-by n (<ᵇʳᶠ⇒lifted p)) |
0 commit comments