In algebra and in particular in algebraic combinatorics, a quasisymmetric function is any element in the ring of quasisymmetric functions which is in turn a subring of the formal power series ring with a countable number of variables. This ring generalizes the ring of symmetric functions. This ring can be realized as a specific limit of the rings of quasisymmetric polynomials in n variables, as n goes to infinity. This ring serves as universal structure in which relations between quasisymmetric polynomials can be expressed in a way independent of the number n of variables (but its elements are neither polynomials nor functions). Definitions The ring of quasisymmetric functions, denoted QSym, can be defined over any commutative ring R such as the integers. Quasisymmetric functions are power series of bounded degree in variables with coefficients in R, which are shift invariant in the sense that the coefficient of the monomial is equal to the coefficient of the monomial for any strictly increasing sequence of positive integers indexing the variables and any positive integer sequence of exponents. Much of the study of quasisymmetric functions is based on that of symmetric functions. A quasisymmetric function in finitely many variables is a quasisymmetric polynomial. Both symmetric and quasisymmetric polynomials may be characterized in terms of actions of the symmetric group on a polynomial ring in variables . One such action of permutes variables, changing a polynomial by iteratively swapping pairs of variables having consecutive indices. Those polynomials unchanged by all such swaps form the subring of symmetric polynomials. A second action of conditionally permutes variables, changing a polynomial by swapping pairs of variables except in monomials containing both variables. Those polynomials unchanged by all such conditional swaps form the subring of quasisymmetric polynomials. One quasisymmetric function in four variables is the polynomial The simplest symmetric function containing these monomials is Important bases QSym is a graded R-algebra, decomposing as where is the -span of all quasisymmetric functions that are homogeneous of degree . Two natural bases for are the monomial basis and the fundamental basis indexed by compositions of , denoted . The monomial basis consists of and all formal power series The fundamental basis consists and all formal power series where means we can obtain by adding together adjacent parts of , for example, (3,2,4,2) (3,1,1,1,2,1,2). Thus, when the ring is the ring of rational numbers, one has Then one can define the