# Class (knowledge representation)

In knowledge representation, a class is a collection of individuals or individuals objects. A class can be defined either by extension (specifying members), or by intension (specifying conditions), using what is called in some ontology languages like OWL. According to the type–token distinction, the ontology is divided into individuals, who are real worlds objects, or events, and types, or classes, who are sets of real world objects. Class expressions or definitions gives the properties that the individuals must fulfill to be members of the class. Individuals that fulfill the property are called Instances.

## Examples

Some examples of classes:
* Person, the class of all people, or the abstract object that can be described by the criteria for being a person.
* Vehicle, the class of all vehicles, or the abstract object that can be described by the criteria for being a vehicle.
* Car, the class of all cars, or the abstract object that can be described by the criteria for being a car.
* Class, representing the class of all classes, or the abstract object that can be described by the criteria for being a class.
* Thing, representing the class of all things, or the abstract object that can be described by the criteria for being a thing (and not nothing).

## Definition

Classes – concepts that are also called type, sort, category, and kind – can be defined as an extension or an intension. According to an extensional definition, they are abstract groups, sets, or collections of objects. According to an intensional definition, they are abstract objects that are defined by values of aspects that are constraints for being member of the class. The first definition of class results in ontologies in which a class is a subclass of collection. The second definition of class results in ontologies in which collections and classes are more fundamentally different. Classes may classify individuals, other classes, or a combination of both.

### Extensional or intensional definitions

The classes of an ontology may be extensional or intensional in nature. A class is extensional if and only if it is characterized solely by its membership. More precisely, a class C is extensional if and only if for any class C', if C' has exactly the same members as C, then C and C' are identical. If a class does not satisfy this condition, then it is intensional. While extensional classes are more well-behaved and well understood mathematically, as well as less problematic philosophically, they do not permit the fine grained distinctions that ontologies often need to make. For example, an ontology may want to distinguish between the class of all creatures with a kidney and the class of all creatures with a heart, even if these classes happen to have exactly the same members. In most upper ontologies, the classes are defined intensionally. Intensionally defined classes usually have necessary conditions associated with membership in each class. Some classes may also have sufficient conditions, and in those cases the combination of necessary and sufficient conditions make that class a fully defined class.

## Instantiation

The instantiation relationship is a relation between objects and classes. We say that an object O, say Harry the eagle is an instance of a class, say Eagle. Harry the eagle has all the properties that we can attribute to an eagle, for example his parents were eagles, he is a bird, he is a meat eater and so on. It is a special kind of is a relationship. Its noted Concept assertion ($:$) in Description logics, a family of logic based on classes, class assertion

## Relationships

Ontologies vary on whether classes can contain other classes, whether a class can belong to itself, whether there is a universal class (that is, a class containing everything), etc. Sometimes restrictions along these lines are made in order to avoid certain well-known paradoxes.

### Subsumption and subclassing

Classes can subsume each other. We say usually that if A and B are classes, and all A instances are also B instances, then B subsumes A, or A is a subclass of B, for example in the OWL Language it is called 'subclassof'.
Importantly, a class can subsume or be subsumed by other classes; a class subsumed by another is called a subclass (or subtype) of the subsuming class (or supertype). For example, Vehicle subsumes Car, since (necessarily) anything that is a member of the latter class is a member of the former. The subsumption relation is used to create a hierarchy of classes, typically with a maximally general class like Anything at the top, and very specific classes like 2002 Ford Explorer at the bottom. The critically important consequence of the subsumption relation is the inheritance of properties from the parent (subsuming) class to the child (subsumed) class. Thus, anything that is necessarily true of a parent class is also necessarily true of all of its subsumed child classes. In some ontologies, a class is only allowed to have one parent (single inheritance), but in most ontologies, classes are allowed to have any number of parents (multiple inheritance), and in the latter case all necessary properties of each parent are inherited by the subsumed child class. Thus a particular class of animal (HouseCat) may be a child of the class Cat and also a child of the class Pet.

### Partition

A partition is a set of related classes and associated rules that allow objects to be classified by the appropriate subclass. The rules correspond with the aspect values that distinguish the subclasses from the superclasses. For example, to the right is the partial diagram of an ontology that has a partition of the Car class into the classes 2-Wheel Drive Car and 4-Wheel Drive Car. The partition rule (or subsumption rule) determines if a particular car is classified by the 2-Wheel Drive Car or the 4-Wheel Drive Car class.
If the partition rule(s) guarantee that a single Car cannot be in both classes, then the partition is called a disjoint partition. If the partition rules ensure that every concrete object in the super-class is an instance of at least one of the partition classes, then the partition is called an exhaustive partition.