In mathematics, a cap set is a subset of (an -dimensional affine space over a three-element field) with no three elements in a line. The cap set problem is the problem of finding the size of the largest possible cap set, as a function of . Cap sets may be defined more generally as subsets of finite affine or projective spaces with no three in line, where these objects are simply called caps.
An example of this problem comes from the game Set, a card game in which each card has four features (its number, symbol, shading, and color), each of which can take one of three values. The cards of this game can be interpreted as representing points of the four-dimensional affine space , where each coordinate of a point specifies the value of one of the features. A line, in this space, is a triple of cards that, in each feature, are either all the same as each other or all different from each other. The game play consists of finding and collecting lines among the cards that are currently face up, and a cap set describes an array of face-up cards in which no lines may be collected.