|
| 1 | +{-# OPTIONS --safe --without-K #-} |
| 2 | + |
| 3 | +-- Buchholz extended order — shared-binder lex cases. |
| 4 | +-- |
| 5 | +-- This module sits on top of `Ordinal.Buchholz.Order._<ᵇ_` and adds |
| 6 | +-- the two shared-binder lex constructors that the comment block at |
| 7 | +-- the top of `Order.agda` flagged as "the next follow-up on top of |
| 8 | +-- WF-0": |
| 9 | +-- |
| 10 | +-- * `<ᵇ⁺-ψα` : `bpsi ν α <ᵇ⁺ bpsi ν β` whenever `α <ᵇ β` |
| 11 | +-- (lex on the ψ-argument, same Ω-index). |
| 12 | +-- * `<ᵇ⁺-+2` : `bplus x y₁ <ᵇ⁺ bplus x y₂` whenever `y₁ <ᵇ y₂` |
| 13 | +-- (lex on the right summand, same left summand). |
| 14 | +-- |
| 15 | +-- Why a separate relation `_<ᵇ⁺_` instead of adding to `_<ᵇ_`. |
| 16 | +-- Adding the constructors directly to `_<ᵇ_` would break the |
| 17 | +-- existing `Ordinal.Buchholz.WellFounded.wf-<ᵇ` proof — the |
| 18 | +-- per-Ω-index bundle that proof uses recurses on `Acc _<Ω_ μ` and |
| 19 | +-- has no Acc on the ψ-argument or the right summand to thread |
| 20 | +-- through the new shared-binder cases. The bundle would have to |
| 21 | +-- expand to `Acc _<Ω_ μ × Acc _<ᵇ_ α` (and a sibling pair for |
| 22 | +-- bplus), with `wf-<ᵇ` mutual with the bundle to supply the |
| 23 | +-- `Acc _<ᵇ_ α` side via BT structural recursion. That restructure |
| 24 | +-- compiles in scope but Agda's termination checker cannot verify |
| 25 | +-- the cycle through `wf-<ᵇ` calls inside `pred-bpsi-from`. We keep |
| 26 | +-- the constructor and well-foundedness workstreams separated here |
| 27 | +-- so the WF gap is named explicitly. |
| 28 | +-- |
| 29 | +-- K-restriction handling. Both new constructors carry an explicit |
| 30 | +-- equality witness for the shared binder rather than letting the |
| 31 | +-- shape `bpsi ν α <ᵇ bpsi ν β` (or `bplus x y₁ <ᵇ bplus x y₂`) |
| 32 | +-- bind `ν` (or `x`) on both sides: |
| 33 | +-- |
| 34 | +-- <ᵇ⁺-ψα : ∀ {ν₁ ν₂ α β} → ν₁ ≡ ν₂ → α <ᵇ β → bpsi ν₁ α <ᵇ⁺ bpsi ν₂ β |
| 35 | +-- <ᵇ⁺-+2 : ∀ {x₁ x₂ y₁ y₂} → x₁ ≡ y₁ → x₂ <ᵇ y₂ → bplus x₁ x₂ <ᵇ⁺ bplus y₁ y₂ |
| 36 | +-- |
| 37 | +-- The implicit binders are pairwise distinct, so when the |
| 38 | +-- irreflexivity proof unifies the LHS and RHS of `_<ᵇ⁺_` to a |
| 39 | +-- shared carrier, no reflexive `ν = ν` (or `x = x`) equation is |
| 40 | +-- forced through. The equality argument is left as a held hypothesis |
| 41 | +-- and not pattern-matched on `refl` in irrefl (which would itself |
| 42 | +-- trigger the K-restriction once the carrier identification has |
| 43 | +-- fired); we thread it as `_` and use the strict-decrease witness |
| 44 | +-- directly. |
| 45 | +-- |
| 46 | +-- Status (2026-04-28): |
| 47 | +-- |
| 48 | +-- * `<ᵇ⁺` includes every `<ᵇ` constructor verbatim plus the two |
| 49 | +-- shared-binder cases. |
| 50 | +-- * `<ᵇ⁺-irrefl`, `<ᵇ⁺-trans` are proved. |
| 51 | +-- * Well-foundedness for `_<ᵇ⁺_` is OPEN — see |
| 52 | +-- `docs/echo-types/buchholz-extended-wf.md` for the design |
| 53 | +-- direction (single-mutual `wf` with `Acc _<ᵇ_ α` threaded |
| 54 | +-- through a widened bundle, or rank-embedding via Brouwer |
| 55 | +-- ordinals). |
| 56 | + |
| 57 | +module Ordinal.Buchholz.OrderExtended where |
| 58 | + |
| 59 | +open import Data.Empty using (⊥) |
| 60 | +open import Relation.Binary.PropositionalEquality using (_≡_; refl) |
| 61 | + |
| 62 | +open import Ordinal.OmegaMarkers using |
| 63 | + ( OmegaIndex |
| 64 | + ; _≤Ω_ |
| 65 | + ; _<Ω_ |
| 66 | + ; ω |
| 67 | + ; ω≤ω |
| 68 | + ; fin |
| 69 | + ; <Ω-irrefl |
| 70 | + ; <Ω-trans |
| 71 | + ; <Ω→≤Ω |
| 72 | + ; ≤Ω-trans |
| 73 | + ; ≤Ω-<Ω-trans |
| 74 | + ; <Ω-≤Ω-trans |
| 75 | + ) |
| 76 | +open import Ordinal.Buchholz.Syntax using (BT; bzero; bOmega; bplus; bpsi) |
| 77 | +open import Ordinal.Buchholz.Order using |
| 78 | + ( _<ᵇ_ |
| 79 | + ; <ᵇ-0-Ω; <ᵇ-0-+; <ᵇ-0-ψ |
| 80 | + ; <ᵇ-ΩΩ; <ᵇ-Ωψ |
| 81 | + ; <ᵇ-ψΩ; <ᵇ-ψΩ≤ |
| 82 | + ; <ᵇ-Ω+; <ᵇ-ψ+ |
| 83 | + ; <ᵇ-+Ω; <ᵇ-+ψ |
| 84 | + ; <ᵇ-+1 |
| 85 | + ; <ᵇ-irrefl; <ᵇ-trans |
| 86 | + ) |
| 87 | + |
| 88 | +---------------------------------------------------------------------- |
| 89 | +-- The extended order |
| 90 | +---------------------------------------------------------------------- |
| 91 | + |
| 92 | +data _<ᵇ⁺_ : BT → BT → Set where |
| 93 | + -- Lift every constructor of `_<ᵇ_` verbatim. |
| 94 | + <ᵇ⁺-base : ∀ {x y} → x <ᵇ y → x <ᵇ⁺ y |
| 95 | + |
| 96 | + -- Shared-binder lex cases. The equality witness keeps all four |
| 97 | + -- implicits pairwise distinct so the K-free unifier never has to |
| 98 | + -- eliminate a reflexive `ν = ν` (or `x = x`) equation on its own. |
| 99 | + <ᵇ⁺-ψα : ∀ {ν₁ ν₂ α β} → ν₁ ≡ ν₂ → α <ᵇ β → bpsi ν₁ α <ᵇ⁺ bpsi ν₂ β |
| 100 | + <ᵇ⁺-+2 : ∀ {x₁ x₂ y₁ y₂} → x₁ ≡ y₁ → x₂ <ᵇ y₂ → bplus x₁ x₂ <ᵇ⁺ bplus y₁ y₂ |
| 101 | + |
| 102 | +infix 4 _<ᵇ⁺_ |
| 103 | + |
| 104 | +---------------------------------------------------------------------- |
| 105 | +-- Irreflexivity |
| 106 | +---------------------------------------------------------------------- |
| 107 | + |
| 108 | +-- The lifted `_<ᵇ_` part discharges via the existing `<ᵇ-irrefl`. |
| 109 | +-- The two shared-binder cases recurse into `<ᵇ-irrefl` on the |
| 110 | +-- strict-decrease witness; the equality argument is discarded |
| 111 | +-- (matching it on `refl` would re-trigger the K-restricted |
| 112 | +-- reflexive elimination once the LHS and RHS of `<ᵇ⁺` have |
| 113 | +-- already been unified to a common carrier). |
| 114 | + |
| 115 | +<ᵇ⁺-irrefl : ∀ {x} → x <ᵇ⁺ x → ⊥ |
| 116 | +<ᵇ⁺-irrefl (<ᵇ⁺-base x<x) = <ᵇ-irrefl x<x |
| 117 | +<ᵇ⁺-irrefl (<ᵇ⁺-ψα _ α<α) = <ᵇ-irrefl α<α |
| 118 | +<ᵇ⁺-irrefl (<ᵇ⁺-+2 _ y<y) = <ᵇ-irrefl y<y |
| 119 | + |
| 120 | +---------------------------------------------------------------------- |
| 121 | +-- Transitivity (via four extension helpers) |
| 122 | +---------------------------------------------------------------------- |
| 123 | + |
| 124 | +-- Helper extending the RHS of a base witness from `bpsi ν α` to |
| 125 | +-- `bpsi ν β` when α <ᵇ β. The base constructors that put bpsi on |
| 126 | +-- the RHS (<ᵇ-0-ψ, <ᵇ-Ωψ, <ᵇ-ψΩ, <ᵇ-+ψ) do not constrain the |
| 127 | +-- ψ-argument α, so we can swap it for β by re-applying the |
| 128 | +-- constructor at β. |
| 129 | +private |
| 130 | + bpsi-extend-rhs : ∀ {ν α β x} → α <ᵇ β → x <ᵇ bpsi ν α → x <ᵇ bpsi ν β |
| 131 | + bpsi-extend-rhs _ <ᵇ-0-ψ = <ᵇ-0-ψ |
| 132 | + bpsi-extend-rhs _ (<ᵇ-Ωψ μ<ν) = <ᵇ-Ωψ μ<ν |
| 133 | + bpsi-extend-rhs _ (<ᵇ-ψΩ μ<ν) = <ᵇ-ψΩ μ<ν |
| 134 | + bpsi-extend-rhs p (<ᵇ-+ψ q) = <ᵇ-+ψ (bpsi-extend-rhs p q) |
| 135 | + |
| 136 | +-- Helper extending the LHS of a base witness from `bpsi ν β` to |
| 137 | +-- `bpsi ν α` when α <ᵇ β. The base constructors that put bpsi on |
| 138 | +-- the LHS (<ᵇ-ψΩ, <ᵇ-ψΩ≤, <ᵇ-ψ+) do not constrain the ψ-argument |
| 139 | +-- of the LHS, so we can swap β for α by re-applying. |
| 140 | + bpsi-extend-lhs : ∀ {ν α β z} → α <ᵇ β → bpsi ν β <ᵇ z → bpsi ν α <ᵇ z |
| 141 | + bpsi-extend-lhs _ (<ᵇ-ψΩ μ<ν) = <ᵇ-ψΩ μ<ν |
| 142 | + bpsi-extend-lhs _ (<ᵇ-ψΩ≤ ν≤μ) = <ᵇ-ψΩ≤ ν≤μ |
| 143 | + bpsi-extend-lhs p (<ᵇ-ψ+ q) = <ᵇ-ψ+ (bpsi-extend-lhs p q) |
| 144 | + |
| 145 | +-- Same helpers for bplus. The base constructors that put bplus on |
| 146 | +-- one side leave the right summand of the bplus on that side |
| 147 | +-- unconstrained, so we can swap it freely. |
| 148 | + bplus-extend-rhs : ∀ {x y z w} → y <ᵇ z → w <ᵇ bplus x y → w <ᵇ bplus x z |
| 149 | + bplus-extend-rhs _ <ᵇ-0-+ = <ᵇ-0-+ |
| 150 | + bplus-extend-rhs _ (<ᵇ-Ω+ q) = <ᵇ-Ω+ q |
| 151 | + bplus-extend-rhs _ (<ᵇ-ψ+ q) = <ᵇ-ψ+ q |
| 152 | + bplus-extend-rhs _ (<ᵇ-+1 q) = <ᵇ-+1 q |
| 153 | + |
| 154 | + bplus-extend-lhs : ∀ {x y z w} → y <ᵇ z → bplus x z <ᵇ w → bplus x y <ᵇ w |
| 155 | + bplus-extend-lhs _ (<ᵇ-+Ω q) = <ᵇ-+Ω q |
| 156 | + bplus-extend-lhs _ (<ᵇ-+ψ q) = <ᵇ-+ψ q |
| 157 | + bplus-extend-lhs _ (<ᵇ-+1 q) = <ᵇ-+1 q |
| 158 | + |
| 159 | +<ᵇ⁺-trans : ∀ {x y z} → x <ᵇ⁺ y → y <ᵇ⁺ z → x <ᵇ⁺ z |
| 160 | +-- Both legs in the base relation: route through `<ᵇ-trans`. |
| 161 | +<ᵇ⁺-trans (<ᵇ⁺-base p) (<ᵇ⁺-base q) = <ᵇ⁺-base (<ᵇ-trans p q) |
| 162 | +-- Left leg base, right leg shared-ψ: extend p's RHS from bpsi ν α |
| 163 | +-- to bpsi ν β via `bpsi-extend-rhs`. |
| 164 | +<ᵇ⁺-trans (<ᵇ⁺-base p) (<ᵇ⁺-ψα refl q) = <ᵇ⁺-base (bpsi-extend-rhs q p) |
| 165 | +-- Left leg base, right leg shared-+2: extend p's RHS from bplus x y |
| 166 | +-- to bplus x z via `bplus-extend-rhs`. |
| 167 | +<ᵇ⁺-trans (<ᵇ⁺-base p) (<ᵇ⁺-+2 refl q) = <ᵇ⁺-base (bplus-extend-rhs q p) |
| 168 | +-- Left leg shared-ψ, right leg base: extend q's LHS from bpsi ν β |
| 169 | +-- to bpsi ν α. |
| 170 | +<ᵇ⁺-trans (<ᵇ⁺-ψα refl p) (<ᵇ⁺-base q) = <ᵇ⁺-base (bpsi-extend-lhs p q) |
| 171 | +-- Left leg shared-+2, right leg base: extend q's LHS from bplus x z |
| 172 | +-- to bplus x y. |
| 173 | +<ᵇ⁺-trans (<ᵇ⁺-+2 refl p) (<ᵇ⁺-base q) = <ᵇ⁺-base (bplus-extend-lhs p q) |
| 174 | +-- Both legs shared-ψ at the same Ω-index: chain the strict-decrease. |
| 175 | +<ᵇ⁺-trans (<ᵇ⁺-ψα refl p) (<ᵇ⁺-ψα refl q) = <ᵇ⁺-ψα refl (<ᵇ-trans p q) |
| 176 | +-- Both legs shared-+2 at the same left summand: chain the right strict-decrease. |
| 177 | +<ᵇ⁺-trans (<ᵇ⁺-+2 refl p) (<ᵇ⁺-+2 refl q) = <ᵇ⁺-+2 refl (<ᵇ-trans p q) |
| 178 | + |
| 179 | +---------------------------------------------------------------------- |
| 180 | +-- Convenience wrappers for the new shared-binder lex cases. |
| 181 | +---------------------------------------------------------------------- |
| 182 | + |
| 183 | +-- Shared Ω-index ψ lex: `bpsi ν α <ᵇ⁺ bpsi ν β` whenever `α <ᵇ β`. |
| 184 | +-- Use this rather than building `<ᵇ⁺-ψα refl ...` directly when |
| 185 | +-- the Ω-index is concretely the same. |
| 186 | + |
| 187 | +<ᵇ⁺-ψα-refl : ∀ {ν α β} → α <ᵇ β → bpsi ν α <ᵇ⁺ bpsi ν β |
| 188 | +<ᵇ⁺-ψα-refl p = <ᵇ⁺-ψα refl p |
| 189 | + |
| 190 | +-- Shared left-summand bplus lex. |
| 191 | + |
| 192 | +<ᵇ⁺-+2-refl : ∀ {x y₁ y₂} → y₁ <ᵇ y₂ → bplus x y₁ <ᵇ⁺ bplus x y₂ |
| 193 | +<ᵇ⁺-+2-refl q = <ᵇ⁺-+2 refl q |
0 commit comments