การหาคำศัพท์แลมบ์ดาที่มีประเภทยูเนี่ยน


29

หนังสือเรียนจำนวนมากครอบคลุมประเภทของจุดตัดในแลมบ์ดา - แคลคูลัส กฎการพิมพ์สำหรับการแยกสามารถกำหนดได้ดังต่อไปนี้ (ด้านบนของแลมบ์ดาแคลคูลัสที่พิมพ์ด้วยการพิมพ์ย่อย):

Γ⊢M:T1Γ⊢M:T2Γ⊢M:T1∧T2(∧I)Γ⊢M:⊤(⊤I)

ประเภทแยกมีคุณสมบัติที่น่าสนใจเกี่ยวกับการทำให้เป็นมาตรฐาน:

  • คำแลมบ์ดาสามารถพิมพ์ได้โดยไม่ต้องใช้⊤Iกฎถ้ามันเป็นมาตรฐานอย่างยิ่ง
  • คำแลมบ์ดายอมรับประเภทที่ไม่มี⊤ iff ซึ่งมีรูปแบบปกติ

ถ้าหากแทนที่จะเพิ่มทางแยกเราจะเพิ่มสหภาพ

Γ⊢M:T1Γ⊢M:T1∨T2(∨I1)Γ⊢M:T2Γ⊢M:T1∨T2(∨I2)

แลมบ์ดาแคลคูลัสมีประเภทย่อยและสหภาพที่เรียบง่ายมีคุณสมบัติคล้ายกันที่น่าสนใจหรือไม่? ข้อกำหนดที่สามารถพิมพ์ด้วยสหภาพได้อย่างไร


คำถามที่น่าสนใจ คุณสามารถพูดได้ว่าอินเตอร์เฟสจาก OOP นั้นสอดคล้องกับสิ่งนี้หรือไม่?
— ราฟาเอล

คำตอบ:


11

ในระบบแรกสิ่งที่คุณเรียกการพิมพ์ย่อยคือกฎสองข้อนี้:

Γ,x:T1⊢M:SΓ,x:T1∧T2⊢M:S(∧E1)Γ,x:T2⊢M:SΓ,x:T1∧T2⊢M:S(∧E2)

∧∧ is more or less useless.

∨→⊥

Γ,x:T1⊢M:SΓ,x:T2⊢M:SΓ,x:T1∨T2⊢M:S(∨E)Γ,x:⊥⊢M:S(⊥E)

For what it's worth, this system allows to type (λx.I)Ω:A→A (using the ⊥E rule), which cannot be typed with just simple types, which has a normal form, but is not strongly normalizing.


Random thoughts: (maybe this is worth asking on TCS)

This leads me to conjecture that the related properties are something like:

  • a λ-term M admits a type not containing ⊥ iff MN has a normal form for all N which has a normal form. (δ fails both tests, but the above λ-term pass them)
  • a λ-term M can be typed without using the ⊥E rule iff MN is strongly normalizing for all strongly normalizing N.

Exercise: prove me wrong.

Also it seems to be a degenerated case, maybe we should consider adding this guy into the picture. As far as I remember, it would allow to obtain A∨(A→⊥)?


Good point about the subtyping rules, they show that union types aren't nearly as natural as intersections (which get typed orthogonally to arrows). About the second part I need to think some more.
— Gilles 'SO- stop being evil'

I think M=(λx.xx)(λy.y) answers the exercise, if you are talking about union types.
— jmad

About call/cc: it needs more than just lambda-terms (like lambda-mu-terms or another framework) but type systems are more complex, logic systems, in which union types may be irrelevant.
— jmad

@jmad: Indeed, intersection types are needed to type this term :-( Maybe considering unions and intersections together would be interesting?
— Stéphane Gimenez

I would be interested in a λ-term one can type with union types (rs. with intersection types) but not with simple types (rs. with intersection types).
— jmad

16

I just want to explain why intersection types are well-suited to characterize classes of normalization (strong, head or weak), whereas other type systems can not. (simply-typed or system F).

The key difference is that you have to say: "if I can type M2 and M1→M2 then I can type M1". This is often not true in non-intersection types because a term can be duplicated:

(λx.Mxx)N→MNN

and then typing MNN means that you can type both occurrences of N but not with the same type, for example

M:T1→T2→T3N:T1N:T2
With intersection types you can transform this into:
M:T1∧T2→T1∧T2→T3N:T1∧T2
and then the crucial step is now really easy:
(λx.Mxx):T1∧T2→T3N:T1∧T2
so (λx.Mxx)N can by typed with intersection types.

Now about union types: suppose you can type (λx.xx)(λy.y) with some union type, then you can also type λx.xx and then get for some types S,T1,…

x:T1∨T2∨⋯∨Tn⊢xx:S
But you still have to prove that for every i, x:Ti⊢xx:S which seems impossible even is S is an union type.

This is why I don't think there is an easy characterization about normalization for union types.

โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.