# Can type information be encoded in the untyped lambda calculus?

I'm going to take the few pieces of knowledge I have about lambda calculi and ask a pair of very uninformed questions :-)

Is it possible to "embed" the corners of the lambda cube within the untyped lambda calculus?

It would seem that this might lead to a language where the programmer implements the type system in the language, rather than having it already implemented in the compiler. Also, maybe the concept of type system could be generalized to "any arbitrary compile-time or run-time constraint checking". Does such a language already exist?

• The question is a bit unclear. You can take typed $\lambda$-calculus of any kind and just delete the types. That "embeds" it into the untyped $\lambda$-calculus. But you must be talking about something else. What exactly? – Andrej Bauer Jan 16 '14 at 23:03
• I may be totally wrong but doesn't typed lambda calculus implement the type system in the language of untyped lambda calculus, and it is the use of syntactic sugar which makes typed language calculus look like a new language. My understanding is that typed lambda calculus can be implemented from just untyped lambda calculus. – Guy Coder Jan 17 '14 at 14:03
• @AndrejBauer Hmm, perhaps I am confusing the type system in a lambda with a particular implementation of it (within a programming language) that performs type checking. I mean to express the constraints that a type system implies using the untyped lambda calculus. From Guy Coder's comment, maybe this is already the case and I just didn't realize it. – Aaron Jan 17 '14 at 15:21
• @GuyCoder Interesting, you may very well be right- I don't understand enough to say either way. Do you mean that type information is encoded in untyped lambda terms in a similar way to Church numerals, etc? (That would relate it to something I understand.) – Aaron Jan 17 '14 at 15:23
• I was hoping that @AndrejBauer would comment on my comment otherwise I will have to make is a new separate question. With regards to your statement, I believe so. Take a look at "An Introduction To Functional Programming Through Lambda Calculus by Greg Michaelson" which I added as link to the Lambda Calculus tag. It will take you some reading to understand, but it should have enough detail to answer your question. – Guy Coder Jan 17 '14 at 15:34