  In classical logic, nonBoolean fluents, such as the location of an object,
can be naturally described by functions. However, this is not the case in
answer set programs, where the values of functions are pre-defined, and
nonmonotonicity of the semantics is related to minimizing the extents of
predicates but has nothing to do with functions. We extend the first-order
stable model semantics by Ferraris, Lee, and Lifschitz to allow intensional
functions -- functions that are specified by a logic program just like
predicates are specified. We show that many known properties of the stable
model semantics are naturally extended to this formalism and compare it with
other related approaches to incorporating intensional functions. Furthermore,
we use this extension as a basis for defining Answer Set Programming Modulo
Theories (ASPMT), analogous to the way that Satisfiability Modulo Theories
(SMT) is defined, allowing for SMT-like effective first-order reasoning in the
context of ASP. Using SMT solving techniques involving functions, ASPMT can be
applied to domains containing real numbers and alleviates the grounding
problem. We show that other approaches to integrating ASP and CSP/SMT can be
related to special cases of ASPMT in which functions are limited to
non-intensional ones.
