Answer set programming (ASP) is a form of declarative programming oriented towards difficult search problems. ASP is an outgrowth of research on the use of nonmonotonic reasoning in knowledge representation and reasoning. It is particularly useful in knowledge-intensive applications, and is widely adopted also in industrial settings. ASP in fact offers a fully declarative, intuitive language for modelling and problem encoding, and efficient highly optimized inference engines ("solvers") which are freely available. The course covers both theory and practice, proposing significant case-studies.