I want to introduce (dependent) type theory to some friends having background in mathematical logic and set theory. To make this introduction easy I would like to give an informal presentation that describes types as collection and terms as elements of the types.
My plan was to present type systems as algebraic systems where types are sorts, constructors and eliminators are operations between these sorts and $\beta$ and $\eta$-reductions are equations that these algebras are required to satisfy.
Unfortunately I'm facing the following problem: I can find a way to describe $\lambda$-abstraction (the constructor for function types) in this algebraic framework. The reason is that the inference rule describing $\lambda$-abstraction, is in the form $$\begin{array}{c} \Gamma, x \colon A \vdash y : B \\ \hline \Gamma \vdash \lambda x \colon A. y \colon A \to B\end{array}$$ that uses terms with non empty context $\Gamma, x \colon A \vdash y \colon B$.
The problem lies in how to (intuitively) interpret terms with nonempty context in this algebraic framework: constant terms, i.e. terms with empty context, can be interpreted very naturally as the elements of the types.
So the question is:
What could be an intuitive interpretation of terms with non empty context in an algebraic framework as the one outlined above?
After having spent sometime thinking about this problem I've found the solution (this solution came to my mind after thinking to the semantics of type theory in categories):
With this interpretation in mind the $\lambda$-abstraction becomes an higher-order operator that takes operations of the form $\Gamma, x \colon A \vdash t \colon B$ into operations of the form $\Gamma \vdash \lambda x \colon A. t \colon A \to B$.
Of course one have to keep in mind the distinction between a term in context $x \colon A \vdash t \colon B$ (that in this interpretation would be an operation between the types $A$ and $B$) and the term $\vdash\lambda x \colon A. t \colon A \to B$ that is a constant.
From a programming perspective the term $x \colon A \vdash t \colon B$ is a function that takes as input a value of type $A$ and return a value of type $B$ while the term $\lambda x \colon A. t \colon A \to B$ is a value of the type $A \to B$ that represents the function $t$ internally to the programming language (it is the code of the function $t$).