  We construct topological defects in two-dimensional classical lattice models
and quantum chains. The defects satisfy local commutation relations
guaranteeing that the partition function is independent of their path. These
relations and their solutions are extended to allow defect lines to fuse,
branch and satisfy all the properties of a fusion category. We show how the
two-dimensional classical lattice models and their topological defects are
naturally described by boundary conditions of a Turaev-Viro-Barrett-Westbury
partition function. These defects allow Kramers-Wannier duality to be
generalized to a large class of models, explaining exact degeneracies between
non-symmetry-related ground states as well as in the low-energy spectrum. They
give a precise and general notion of twisted boundary conditions and the
universal behaviour under Dehn twists. Gluing a topological defect to a
boundary yields linear identities between partition functions with different
boundary conditions, allowing ratios of the universal g-factor to be computed
exactly on the lattice. We develop this construction in detail in a variety of
examples, including the Potts, parafermion and height models.
