Type-preserving compilation of polymorphic records
appendix sectionrules
Type-preserving compilation of polymorphic records
A record kind {{ℓ𝑖:𝜏𝑖}}𝑚𝑖=1 requires the listed distinct fields but does not fix the complete layout. Rule K-Rec checks both complete-record formation and finite-map inclusion:
K⊢{ℓ′𝑗:𝜐𝑗}𝑛𝑗=1::𝖴{ℓ𝑖:𝜏𝑖}𝑚𝑖=1⊆{ℓ′𝑗:𝜐𝑗}𝑛𝑗=1
K⊢{ℓ′𝑗:𝜐𝑗}𝑛𝑗=1::{{ℓ𝑖:𝜏𝑖}}𝑚𝑖=1
K-Rec
The source record and projection rules are
K;T⊢𝖱𝑀𝑖:𝜏𝑖(1≤𝑖≤𝑛)ℓ1,…,ℓ𝑛aredistinct
K;T⊢𝖱{ℓ𝑖=𝑀𝑖}𝑛𝑖=1:{ℓ𝑖:𝜏𝑖}𝑛𝑖=1
R-Record
K;T⊢𝖱𝑀:𝜏K⊢𝜏::{{ℓ:𝜐}}
K;T⊢𝖱𝑀.ℓ:𝜐
R-Dot
The variable 𝐼𝑡,ℓ belongs only to the pair (𝑡,ℓ). For a ground kind-respecting substitution 𝑆, the distinct numeral substitution is 𝜈𝑆(𝐼𝑡,ℓ)=posℓ(𝑆(𝑡)). The target rules distinguish vector selection 𝐶⟨𝐽⟩ from type application 𝐶[𝜏]:
K;L;T⊢𝖵𝐶:𝜏K⊢𝜏::{{ℓ:𝜐}}K;L⊢𝐽:𝗂𝖽𝗑(ℓ,𝜏)
K;L;T⊢𝖵𝐶⟨𝐽⟩:𝜐
V-Nth
K;L,𝐼:𝗂𝖽𝗑(ℓ,𝜏);T⊢𝖵𝐶:𝜐
K;L;T⊢𝖵𝜆𝗂𝐼.𝐶:𝗂𝖽𝗑(ℓ,𝜏)⇒𝗂𝜐
V-IAbs
K;L;T⊢𝖵𝐶:𝗂𝖽𝗑(ℓ,𝜏)⇒𝗂𝜐K;L⊢𝐽:𝗂𝖽𝗑(ℓ,𝜏)
K;L;T⊢𝖵𝐶@𝐽:𝜐
V-IApp
The contextual judgment K;L;T⊢𝑀⇝𝗋𝖾𝖼𝐶:𝜎 uses C-Record to compile records to vectors in increasing label order and C-Dot to compile projection as 𝑀.ℓ⇝𝗋𝖾𝖼𝐶⟨𝐽⟩. Rule C-TAbsRec inserts 𝜆𝗂𝐼𝑡,ℓ1⋯𝜆𝗂𝐼𝑡,ℓ𝑚 in canonical label order; C-TAppRec supplies the certified positions. Source call-by-value has term beta, type beta, and record projection. Target call-by-value has term beta, type beta, and the two additional roots [𝐴1,…,𝐴𝑛]⟨𝑖⟩⇝0𝐴𝑖,(𝜆𝗂𝐼.𝐶)@𝑖⇝0𝐶[𝑖/𝐼].