Created
February 23, 2026 14:38
-
-
Save clayrat/85cc967dccb3c234901136823b0ae139 to your computer and use it in GitHub Desktop.
GOI-unification
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module GOI where | |
| open import Prelude | |
| open import Data.Nat | |
| open import Data.List renaming (_++_ to _++β_) | |
| open import Data.List.Correspondences.Binary.Prefix | |
| open import Data.Fin.Inductive | |
| open import Data.Vec.Inductive | |
| open import Data.Vec.Inductive.Operations as Vec | |
| open import Data.Star | |
| open import Data.Sum | |
| -- from Honsell, Lenisa, Scagnetto, [2024] "Two Views on Unification: Terms as Strategies" | |
| record Signature : π°β where | |
| field | |
| Symbol : π° | |
| arity : Symbol β β | |
| module Theory (Var : π°) β¦ d : is-discrete Var β¦ (Sig : Signature) where | |
| open Signature Sig | |
| -- Definition 1(i): Terms TΞ£ | |
| data Term : π° where | |
| var : Var β Term | |
| con : (f : Symbol) | |
| β Vec Term (arity f) | |
| β Term | |
| -- Definition 1(iii-iv): Paths and Occurrences OΞ£ | |
| -- A Step is a constructor and the index of the subtree | |
| record Step : π° where | |
| constructor step | |
| field | |
| f : Symbol | |
| k : Fin (arity f) | |
| OPath : π° | |
| OPath = List Step | |
| record Occurrence : π° where | |
| constructor _o[_] | |
| field | |
| opath : OPath | |
| ovar : Var | |
| open Occurrence public | |
| -- Helper: Checking if an occurrence is in a term | |
| data _ββ_ : Occurrence β Term β π° where | |
| here : {Ξ± : Var} | |
| β ([] o[ Ξ± ]) ββ var Ξ± | |
| there : {f : Symbol} {args : Vec Term (arity f)} {p : OPath} {Ξ± : Var} {i : Fin (arity f)} | |
| β ((p o[ Ξ± ]) ββ Vec.lookup args i) | |
| β ((step f i β· p) o[ Ξ± ]) ββ con f args | |
| -- Definition 4: From Terms to Strategies R(Ο) | |
| -- R(Ο) is the set of pairs of different occurrences of the same variable | |
| Strategy : π°β | |
| Strategy = Occurrence β Occurrence β π° | |
| R : Term β Strategy | |
| R Ο oβ oβ = (oβ ββ Ο) Γ (oβ ββ Ο) Γ (Occurrence.ovar oβ οΌ Occurrence.ovar oβ) Γ (oβ β oβ) | |
| -- Definition 12: Occ-substitution M | |
| -- An occ-substitution M is induced by M_Var : Variable β Occurrence | |
| -- It maps u[Ξ±] to (u ++ path(M_Var Ξ±))[variable(M_Var Ξ±)] | |
| OccSubst : π° | |
| OccSubst = Var β Occurrence | |
| -- TODO sketchy | |
| ap-subst : OccSubst β Occurrence β Occurrence | |
| ap-subst M (u o[ Ξ± ]) with M Ξ± | |
| ... | (w o[ Ξ² ]) = (u ++β w) o[ Ξ² ] | |
| OccUnifier : OccSubst β Occurrence β Occurrence β π° | |
| OccUnifier M u v = ap-subst M u οΌ ap-subst M v | |
| {- | |
| lemma13-to : {M : OccSubst} {u v : Occurrence} | |
| β OccUnifier M u v | |
| β Prefix (u .opath) (v .opath) β Prefix (v .opath) (u .opath) | |
| lemma13-to {u = u o[ Ξ± ]} {v = v o[ Ξ² ]} e = | |
| {!!} | |
| -} | |
| -- Definition 14(ii): Inclusion up to substitution (βΜ) | |
| -- Sβ βΜ Sβ if every pair in Sβ is an instance of a pair in Sβ | |
| _βΜ_ : Strategy β Strategy β π° | |
| Sβ βΜ Sβ = | |
| β {uβ vβ} | |
| β Sβ uβ vβ | |
| β Ξ£[ uβ κ Occurrence ] | |
| Ξ£[ vβ κ Occurrence ] | |
| Ξ£[ M κ OccSubst ] | |
| (Sβ uβ vβ Γ OccUnifier M uβ uβ Γ OccUnifier M vβ vβ) | |
| -- Definition 14(i): Composition up to substitution (β¨ΎΜ) | |
| _β¨ΎΜ_ : Strategy β Strategy β Strategy | |
| (Sβ β¨ΎΜ Sβ) u'' v'' = | |
| Ξ£[ uβ κ Occurrence ] | |
| Ξ£[ vβ κ Occurrence ] | |
| Ξ£[ uβ κ Occurrence ] | |
| Ξ£[ vβ κ Occurrence ] | |
| Ξ£[ M κ OccSubst ] | |
| (Sβ uβ vβ Γ Sβ uβ vβ Γ OccUnifier M vβ uβ Γ OccUnifier M u'' uβ Γ OccUnifier M v'' vβ) | |
| -- Definition 16: GoI-unification | |
| -- Ο and Ο GoI-unify if their variable strategies satisfy the execution formula | |
| GoI-unify : Term β Term β π° | |
| GoI-unify Ο Ο = | |
| (R Ο βΜ (R Ο β¨ΎΜ (Star (R Ο β¨ΎΜ R Ο)))) | |
| Γ (R Ο βΜ (R Ο β¨ΎΜ (Star (R Ο β¨ΎΜ R Ο)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment