In mathematics, a basic semialgebraic set is a set defined by polynomial equalities and polynomial inequalities, and a semialgebraic set is a finite union of basic semialgebraic sets. A semialgebraic function is a function with a semialgebraic graph. Such sets and functions are mainly studied in real algebraic geometry which is the appropriate framework for algebraic geometry over the real numbers.
 Let 
  
    
      
        
          F
        
      
    
    {\displaystyle \mathbb {F} }
  
 be a real closed field. (For example 
  
    
      
        
          F
        
      
    
    {\displaystyle \mathbb {F} }
  
 could be the field of real numbers 
  
    
      
        
          R
        
      
    
    {\displaystyle \mathbb {R} }
  
.)
A subset 
  
    
      
        S
      
    
    {\displaystyle S}
  
 of 
  
    
      
        
          
            F
          
          
            n
          
        
      
    
    {\displaystyle \mathbb {F} ^{n}}
  
 is a semialgebraic set if it is a finite union of sets defined by polynomial equalities of the form 
  
    
      
        {
        (
        
          x
          
            1
          
        
        ,
        .
        .
        .
        ,
        
          x
          
            n
          
        
        )
        ∈
        
          
            F
          
          
            n
          
        
        ∣
        P
        (
        
          x
          
            1
          
        
        ,
        .
        .
        .
        ,
        
          x
          
            n
          
        
        )
        =
        0
        }
      
    
    {\displaystyle \{(x_{1},...,x_{n})\in \mathbb {F} ^{n}\mid P(x_{1},...,x_{n})=0\}}
  
 and of sets defined by polynomial inequalities of the form 
  
    
      
        {
        (
        
          x
          
            1
          
        
        ,
        .
        .
        .
        ,
        
          x
          
            n
          
        
        )
        ∈
        
          
            F
          
          
            n
          
        
        ∣
        P
        (
        
          x
          
            1
          
        
        ,
        .
        .
        .
        ,
        
          x
          
            n
          
        
        )
        >
        0
        }
        .
      
    
    {\displaystyle \{(x_{1},...,x_{n})\in \mathbb {F} ^{n}\mid P(x_{1},...,x_{n})>0\}.}
  

 Similarly to algebraic subvarieties, finite unions and intersections of semialgebraic sets are still semialgebraic sets. Furthermore, unlike subvarieties, the complement of a semialgebraic set is again semialgebraic. Finally, and most importantly, the Tarski–Seidenberg theorem says that they are also closed under the projection operation: in other words a semialgebraic set projected onto a linear subspace yields another semialgebraic set (as is the case for quantifier elimination).  These properties together mean that semialgebraic sets form an o-minimal structure on R.
 A semialgebraic set (or function) is said to be defined over a subring A of R if there is some description as in the definition, where the polynomials can be chosen to have coefficients in A.
 On a dense open subset of the semialgebraic set S, it  is (locally) a submanifold. One can define the dimension of S to be the largest dimension at points at which it is a submanifold. It is not hard to see that a semialgebraic set lies inside an algebraic subvariety of the same dimension.