The -substitution operators
DefinitionMSKleene_SubstThe -substitution operators on languages of the free many-sorted algebra (Definition 3.20).
Given a sort v, a variable z ∈ X_v, and a language L ⊆ T_Σ(X)_v:
substAssign z Lis the -sorted map sendingz ↦ Land every other variabley ↦ {y};substHom z Lis the induced homomorphism ;substP z L s Kis its completely additive extension .
Formalization Note substAssign uses classical decidability for the sort- and variable-equality tests, so the definitions are noncomputable; this is immaterial to the mathematics.
/-
The `z`-substitution operators on languages of the free many-sorted algebra
(Definition 3.20).
Given a sort `v`, a variable `z ∈ X_v`, and a language `L ⊆ T_Σ(X)_v`:
* `substAssign z L` is the `S`-sorted map `X → T_Σ(X)^℘` sending `z ↦ L` and
every other variable `y ↦ {y}`;
* `substHom z L = (substAssign z L)^♯` is the induced homomorphism
`T_Σ(X) → T_Σ(X)^℘` (written `⟨z/L⟩^♯` in the paper);
* `substP z L s K` is its completely additive extension
`⟨z/L⟩^♯ᵖ_s (K) = ⋃_{P ∈ K} ⟨z/L⟩^♯_s(P)`.
-/
import Definitions.Def_MSKleene_Term
import Definitions.Def_MSKleene_Power
import Mathlib.Data.Set.Lattice
namespace MSKleene
universe u
variable {S : Type u} {sig : Signature S} {X : SSet S}
open scoped Classical in
/-- The substitution assignment `⟨z/L⟩ : X → T_Σ(X)^℘` (Definition 3.20):
`z ↦ L`, and `y ↦ {y}` for every other variable. -/
noncomputable def substAssign {v : S} (z : X v) (L : Set (Term sig X v)) :
SMap X (powerAlgebra (freeAlgebra sig X)).carrier := fun t y =>
show Set (Term sig X t) from
if h : t = v then
(by subst h; exact if y = z then L else {(Term.var y : Term sig X t)})
else ({(Term.var y : Term sig X t)} : Set (Term sig X t))
/-- The homomorphism `⟨z/L⟩^♯ : T_Σ(X) → T_Σ(X)^℘` induced by `substAssign`
(Definition 3.20). -/
noncomputable def substHom {v : S} (z : X v) (L : Set (Term sig X v)) :
Hom (freeAlgebra sig X) (powerAlgebra (freeAlgebra sig X)) :=
evalHom (powerAlgebra (freeAlgebra sig X)) (substAssign z L)
/-- The completely additive extension `⟨z/L⟩^♯ᵖ_s : T_Σ(X)^℘_s → T_Σ(X)^℘_s`,
`K ↦ ⋃_{P ∈ K} ⟨z/L⟩^♯_s(P)` (Definition 3.20). -/
noncomputable def substP {v : S} (z : X v) (L : Set (Term sig X v)) (s : S)
(K : Set (Term sig X s)) : Set (Term sig X s) :=
⋃ P ∈ K, (substHom z L).toFun s P
end MSKleene
Read-back
What the Lean code literally says, in plain math · claude-sonnet-5
substAssign
Fix a universe level, a type whose elements are called sorts, a signature over (for every list of argument sorts and every result sort , is the type of operation symbols of that profile), and an -indexed family of types playing the role of typed variables ( is the type of variables of sort ). Write for the type of well-sorted terms of sort : a term is either for some , or where with and each is a term of sort . The data , , and a further sort are implicit arguments; the explicit arguments are a variable and an arbitrary set of terms of sort (no restriction: may be empty, may contain , etc.). The declaration substAssign z L is a sort-indexed function that assigns, to every sort and every variable , a set of terms of sort , namely
The two comparisons involved (the sort equality , and after identifying with the variable equality ) are decided using classical logic, and the definition is marked noncomputable. Its stated codomain is the carrier, at sort , of the power algebra of the free term algebra, which is definitionally .
substHom
With the same implicit data and the same explicit arguments and , this declaration produces a homomorphism of -algebras
where is the free term algebra (carrier , with operation ), and is the power algebra over it: its carrier at sort is , and for with and a tuple of sets with its operation is the complex product
The homomorphism is defined as the canonical evaluation homomorphism out of the free algebra induced by the assignment . It bundles two pieces of data. First, an underlying sort-indexed function , characterized by structural recursion:
- , i.e. when and , and otherwise;
- for , .
Second, a proof of the homomorphism law: for every operation symbol and every tuple of argument terms , equals the power-algebra operation applied to the tuple of images . The construction is noncomputable and uses classical logic (inherited from ).
substP
With the same implicit data , the explicit arguments are a variable , a set , a sort , and a set . The result substP z L s K is the set of terms of sort obtained as the indexed union, over all terms lying in , of the sets produced by the map from substHom:
where is the recursively-defined function described above. In particular, if the union is the empty set. No hypotheses beyond the stated typing are imposed on any argument, and the definition is noncomputable.
Confirmed by the mission captain (proposal self-audit).