Kan Extensions Skill (ERGODIC 0)
Universal schema migration via left/right Kan extensions
Trit: 0 (ERGODIC)
Color: #26D826 (Green)
Role: Coordinator/Transporter
Kan extensions are the "best approximation" to extending a functor along another:
F
C โโโโโ D
โ โ
K โ โ Lan_K F (left Kan extension)
โ โ Ran_K F (right Kan extension)
C'
Adjunction: Lan_K โฃ Res_K โฃ Ran_K
(Lan_K F)(d) = colim_{(c,f: K(c)โd)} F(c)
(Ran_K F)(d) = lim_{(c,f: dโK(c))} F(c)
using Catlab, DataMigrations
# Schema migration via Kan extension
# K: SchemaOld โ SchemaNew
# F: SchemaOld โ Set (instance)
# Lan_K F: SchemaNew โ Set (migrated instance)
function left_kan_migrate(K::DataMigration, instance::ACSet)
# Compute colimit for each new object
return colimit_representables(K, instance)
end
function right_kan_migrate(K::DataMigration, instance::ACSet)
# Compute limit for each new object
return limit_representables(K, instance)
end
@migration SchemaV1 SchemaV2 begin
# Lan extends forward
NewTable => @join begin
old::OldTable
# computed from old structure
end
end
@migration SchemaV2 SchemaV1 begin
# Ran projects backward
OldTable => @join begin
new::NewTable
# projected from new structure
end
end
For any H: C' โ D with natural transformation ฮฑ: F โ H โ K
โ! ฮฒ: Lan_K F โ H such that ฮฑ = ฮฒ โ K โ ฮท
sheaf-cohomology (-1) โ kan-extensions (0) โ free-monad-gen (+1) = 0 โ
temporal-coalgebra (-1) โ kan-extensions (0) โ operad-compose (+1) = 0 โ
persistent-homology (-1) โ kan-extensions (0) โ topos-generate (+1) = 0 โ
# Migrate schema forward (Lan)
just kan-migrate-forward old.json new_schema
# Migrate schema backward (Ran)
just kan-migrate-backward new.json old_schema
# Check universal property
just kan-universal K F H
| Concept | As Kan Extension |
|---|---|
| Colimit | Lan along ! : C โ 1 |
| Limit | Ran along ! : C โ 1 |
| Yoneda | Ran along 1_C |
| Adjoint | Lan/Ran along identity |
| End | Ran along ฮ |
| Coend | Lan along ฮ |
Part of: para-mensch-commons.