Skip to content

Subtyping

In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism.

Core Idea

Subtyping is treated here as the recurring computer science and information systems identity summarized by this source-grounded definition: In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism. In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism. A subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program elements (typically subroutines or functions), written to operate on elements of the supertype, can also operate on elements of the.

How would you explain it like I'm…

Fits Where the Big One Fits

Imagine a game that says 'any animal can play.' A puppy is a kind of animal, so a puppy can play too. Subtyping in computers is like that: if a program is built to work with one kind of thing, it can also safely work with a more specific kind of that thing.

Special Kinds Can Fill In

In programming, data comes in 'types,' like numbers, words, or shapes. Subtyping is when one type counts as a special kind of another type, so it can be used anywhere the more general type is expected. For example, if a program can draw any Shape, and a Circle is a subtype of Shape, the program can draw a Circle too. Each programming language has its own rules for what counts as a subtype, and because of these rules, one piece of data can belong to more than one type at once.

Type Substitutability

Subtyping is a kind of polymorphism in programming languages, meaning code that can work with values of more than one type. A type S is a subtype of a type T if any value of type S can safely be used wherever a value of type T is expected; T is called the supertype. For example, a function written to work on any 'Vehicle' can also accept a 'Car' if Car is a subtype of Vehicle. This idea is called substitutability. Exactly what 'safely used' and 'anywhere' mean depends on the particular language's type system, and some languages have almost no subtyping at all. Because of subtyping, a single value can have more than one type.

 

In programming language theory, subtyping, also called subtype polymorphism or inclusion polymorphism, is a form of type polymorphism. A subtype S is related to a supertype T by a notion of substitutability: program elements, typically functions or subroutines, written to operate on values of T can also operate on values of S. Formally, S <: T means that any term of type S can safely be used in any context where a term of type T is expected. The precise meaning depends on how a given type formalism or language defines 'safely used' and 'any context'; each type system thus defines its own subtyping relation, which may be trivial if the language supports little or no conversion. A consequence is that a term can belong to more than one type.

Scope of Application

  • Function types. In languages that allow side effects, like most object-oriented languages, subtyping is generally not sufficient to guarantee that a function can be safely used in the context of another.

  • Relationship with inheritance. By bottom-up application of the function subtyping rule, this means: S ≤: T and T ≤: S, which is only possible if S and T are the same.

  • Documented setting. Subtyping should not be confused with the notion of (class or object) inheritance from object-oriented languages; subtyping is a relation between types (interfaces in object-oriented parlance) whereas inheritance is a relation.

  • Origins. Reynolds in 1980 who used category theory to formalize implicit conversions, and Luca Cardelli (1985).

  • Examples. The UML notation is used in this diagram, with open-headed arrows showing the direction and type of the relationship between the supertype and its subtypes.

Clarity

A clear use of Subtyping names the carrier, the operative relation, and the conditions under which the source treats the identity as present. The minimal definition is In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism.

Manages Complexity

Subtyping compresses multiple computer science and information systems details into a stable diagnostic relation. The source shows both the central mechanism—the precise semantics of subtyping here crucially depends on the particulars of how "safely be used" and "any context" are defined by a given type formalism or programming language.—and the practical consequence—the set can be described extensionally by listing all the values, or it can be described.

Abstract Reasoning

  1. Type the carrier. Identify the computer science and information systems entities to which the claim applies.
  2. State the relation. Use the source-grounded identity: In programming language theory, subtyping (also called subtype polymorphism or inclusion polymorphism) is a form of type polymorphism.
  3. Check operation and conditions. Because it must consider mutable objects, the ideal notion of subtyping defined by Liskov and Jeannette Wing, called behavioral subtyping is considerably stronger than what can be implemented in a type checker.
  4. Demand recognition evidence.

Knowledge Transfer

Within the home domain. Knowledge about Subtyping transfers literally when a new case preserves the same carrier type, relation, and recognition test. In languages that allow side effects, like most object-oriented languages, subtyping is generally not sufficient to guarantee that a function can be safely used in the context of another. By bottom-up application of the function subtyping rule, this means: S ≤: T and T ≤: S, which is only possible if S and T are the same. Beyond the home domain. No canonical parent is asserted for Subtyping.

Relationships to Other Abstractions

Local relationship map for SubtypingParents appear above the current abstraction, mutual partners to the right, and children below. Node labels state whether each abstraction is prime or domain-specific; colors identify relation types.SubtypingDOMAINDomain-specific abstraction: Type System — presupposesType SystemDOMAINDomain-specific abstraction: Bottom Type — presupposesBottom TypeDOMAIN

Current abstraction Subtyping Domain-specific

Parents (1) — outgoing typed relations

  • Subtyping presupposes Type System Domain-specific

    Subtyping is defined through substitutability and ordering relations inside a type system.

Children (1) — abstractions linked here by typed relations

  • Bottom Type Domain-specific presupposes Subtyping

    A bottom type requires a subtyping relation in which it is below every admissible type.

Hierarchy paths (2) — routes to 2 parentless roots

Neighborhood in Abstraction Space

Subtyping sits in a moderately populated region (48th percentile for distinctiveness): it has near-neighbors but no dense thicket of look-alikes.

Family — Computation Models & Complexity Classes (37 abstractions)

Nearest neighbors

Computed from structural-signature embeddings · 2026-11-14