A
dependent intersection type, denoted (x : \sigma) \cap \tau, is a
dependent type in which the type \tau may depend on the term variable x. In particular, if a term M has the dependent intersection type (x : \sigma) \cap \tau, then the term M has
both the type \sigma and the type \tau[x := M], where \tau[x := M] is the type which results from replacing all occurrences of the term variable x in \tau by the term M.
Scala example Scala supports type declarations as object members. This allows a type of an object member to depend on the value of another member, which is called a
path-dependent type. For example, the following program text defines a Scala trait Witness, which can be used to implement the
singleton pattern. trait Witness { type T val value: T {} } The above trait Witness declares the member T, which can be assigned a
type as its value, and the member value, which can be assigned a value of type T. The following program text defines an object booleanWitness as instance of the above trait Witness . The object booleanWitness defines the type T as Boolean and the value value as true. For example, executing System.out.println(booleanWitness.value) prints true on the console. object booleanWitness extends Witness { type T = Boolean val value = true } Let \langle \textsf{x} : \sigma \rangle be the type (specifically, a
record type) of objects having the member \textsf{x} of type \sigma. In the above example, the object booleanWitness can be assigned the dependent intersection type (x : \langle \textsf{T} : \text{Type} \rangle) \cap \langle \textsf{value} : x.\textsf{T} \rangle. The reasoning is as follows. The object booleanWitness has the member T that is assigned the type Boolean as its value. Since Boolean is a type, the object booleanWitness has the type \langle \textsf{T} : \text{Type} \rangle. Additionally, the object booleanWitness has the member value that is assigned the value true of type Boolean. Since the value of booleanWitness.T is Boolean, the object booleanWitness has the type \langle \textsf{value} : \textsf{booleanWitness.T} \rangle. Overall, the object booleanWitness has the intersection type \langle \textsf{T} : \text{Type} \rangle \cap \langle \textsf{value} : \textsf{booleanWitness.T} \rangle. Therefore, presenting self-reference as dependency, the object booleanWitness has the dependent intersection type (x : \langle \textsf{T} : \text{Type} \rangle) \cap \langle \textsf{value} : x.\textsf{T} \rangle. Alternatively, the above minimalistic example can be described using
dependent record types. In comparison to dependent intersection types, dependent record types constitute a strictly more specialized type theoretic concept. == Intersection of a type family ==