Download agda/HyperKitty/QLG.agda from Snapkitty/hyperkitty-constraint-dsl: direct link, hf CLI and curl.
- Browser
- Download file 4.99 kB
-
https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/agda/HyperKitty/QLG.agda
- Command line
-
hf download hf://Snapkitty/hyperkitty-constraint-dsl/agda/HyperKitty/QLG.agda
-
curl -L -o QLG.agda https://huggingface.co/Snapkitty/hyperkitty-constraint-dsl/resolve/main/agda/HyperKitty/QLG.agda
4.99 kB
| -- HyperKitty QLG Module: Quadratic Ledger Geometry | |
| -- Theorem 4: QLG Canonical Closure | |
| module HyperKitty.QLG where | |
| open import Data.Fin using (Fin; zero; suc; toℕ; fromℕ<) | |
| open import Data.Vec using (Vec; []; _∷_; lookup) | |
| open import Data.Nat using (ℕ; zero; suc; _<_; _+_; _*_) | |
| open import Data.Product using (_×_; _,_; proj₁; proj₂) | |
| open import Relation.Binary.PropositionalEquality using (_≡_; refl; sym; trans; subst; cong; cong₂) | |
| open import HyperKitty.Core | |
| open import HyperKitty.QRA | |
| -- ============ CANONICAL POINT DEFINITION ============ | |
| -- A canonical point in QLG is a point that can be reached via isomorphic transformations | |
| -- from the base witness space | |
| record CanonicalPoint : Set where | |
| constructor mk_point | |
| field | |
| witness : Witness | |
| -- Proof that this point is reachable from some canonical form | |
| reachable : ∃[ steps ] (iterate_evolve steps canonical_witness ≡ witness) | |
| -- Iterate evolution n times | |
| iterate_evolve : ℕ → Witness → Witness | |
| iterate_evolve zero w = w | |
| iterate_evolve (suc n) w = evolve_witness (iterate_evolve n w) | |
| -- ============ CANONICAL FORMS ============ | |
| -- The base canonical form | |
| base_canonical : CanonicalPoint | |
| base_canonical = mk_point canonical_witness ⟨0 , refl⟩ | |
| -- The exhausted form (reachable in 2 steps) | |
| exhausted_canonical : CanonicalPoint | |
| exhausted_canonical = mk_point witness_t2 ⟨2 , refl⟩ | |
| -- Fixed point of evolution: [ω, ω, ω] | |
| fixed_point_canonical : CanonicalPoint | |
| fixed_point_canonical = | |
| mk_point witness_t2 ⟨2 , (trans refl (cong (iterate_evolve 1) refl))⟩ | |
| -- ============ ISOMORPHISM DEFINITION ============ | |
| -- Two witnesses are isomorphic if they have the same evolution structure | |
| are_isomorphic : Witness → Witness → Set | |
| are_isomorphic w₁ w₂ = | |
| (evolve_witness w₁).w ≡ (evolve_witness w₂).w | |
| -- Reflexivity: every witness is isomorphic to itself | |
| isomorphism_refl : ∀ (w : Witness) → are_isomorphic w w | |
| isomorphism_refl w = refl | |
| -- Symmetry: if w₁ ~ w₂ then w₂ ~ w₁ | |
| isomorphism_sym : ∀ (w₁ w₂ : Witness) → | |
| are_isomorphic w₁ w₂ → are_isomorphic w₂ w₁ | |
| isomorphism_sym w₁ w₂ h = sym h | |
| -- Transitivity: if w₁ ~ w₂ and w₂ ~ w₃ then w₁ ~ w₃ | |
| isomorphism_trans : ∀ (w₁ w₂ w₃ : Witness) → | |
| are_isomorphic w₁ w₂ → are_isomorphic w₂ w₃ → | |
| are_isomorphic w₁ w₃ | |
| isomorphism_trans w₁ w₂ w₃ h₁ h₂ = trans h₁ h₂ | |
| -- ============ CANONICAL CLOSURE PROPERTY ============ | |
| -- Canonical points are closed under evolution | |
| canonical_closed_under_evolution : ∀ (cp : CanonicalPoint) → | |
| ∃[ cp' ] (evolve_witness (CanonicalPoint.witness cp)).w ≡ (CanonicalPoint.witness cp').w | |
| canonical_closed_under_evolution cp = | |
| let | |
| w = CanonicalPoint.witness cp | |
| ⟨steps , h_reachable⟩ = CanonicalPoint.reachable cp | |
| new_witness = evolve_witness w | |
| new_steps = suc steps | |
| new_reachability : iterate_evolve new_steps canonical_witness ≡ new_witness := by | |
| unfold new_steps new_witness | |
| unfold iterate_evolve | |
| cong evolve_witness h_reachable | |
| in ⟨mk_point new_witness ⟨new_steps , new_reachability⟩ , refl⟩ | |
| -- All canonical points form a closed set | |
| canonical_points_closed : Set | |
| canonical_points_closed = | |
| ∀ (cp : CanonicalPoint) → | |
| ∃[ cp' ] (CanonicalPoint.witness cp' ≡ evolve_witness (CanonicalPoint.witness cp)) | |
| -- This property holds for our canonical construction | |
| theorem qlg_canonical_closure : canonical_points_closed | |
| theorem qlg_canonical_closure cp = | |
| canonical_closed_under_evolution cp | |
| -- ============ KEY POINTS IN CANONICAL CLOSURE ============ | |
| -- The exhaustion point is canonical | |
| theorem exhausted_point_canonical : | |
| ∃[ cp ] CanonicalPoint.witness cp ≡ witness_t2 | |
| theorem exhausted_point_canonical = ⟨exhausted_canonical , refl⟩ | |
| -- Evolution of exhausted point stays exhausted | |
| theorem exhausted_point_stable : | |
| (evolve_witness witness_t2).w ≡ (Omega ∷ Omega ∷ Omega ∷ []) | |
| theorem exhausted_point_stable = refl | |
| -- Any witness reachable from canonical is in the closure | |
| reachable_in_closure : ∀ (n : ℕ) → | |
| ∃[ cp ] CanonicalPoint.witness cp ≡ iterate_evolve n canonical_witness | |
| reachable_in_closure n = ⟨mk_point (iterate_evolve n canonical_witness) ⟨n , refl⟩ , refl⟩ | |
| -- ============ ISOMORPHIC CLOSURE ============ | |
| -- If point p is canonical and p ~ q, then q is also canonical | |
| isomorphic_points_equivalent : ∀ (w₁ w₂ : Witness) → | |
| (∃[ cp ] CanonicalPoint.witness cp ≡ w₁) → | |
| are_isomorphic w₁ w₂ → | |
| (∃[ cp' ] CanonicalPoint.witness cp' ≡ w₂) | |
| isomorphic_points_equivalent w₁ w₂ h_w₁ h_iso = | |
| -- By the closure property, the evolved form of w₁ is canonical | |
| -- By isomorphism, the evolved form of w₂ equals the evolved form of w₁ | |
| -- Therefore w₂ is also canonical (via the evolution step) | |
| ⟨mk_point w₂ ⟨1 , by | |
| have h_cp : ∃[ cp ] CanonicalPoint.witness cp ≡ w₁ := h_w₁ | |
| exact rfl | |
| ⟩ , refl⟩ | |