We present in this paper a formal theory of reasoning by analogy. We are mainly concerned with three subjects : a formal definition of analogy, a formalization of the reasoning in terms of deduction, and a method for realizing the reasoning in a logic programming system. First we assume that each domain for the reasoning is the least model for logic program. Then we consider an analogy as a partial identity between the models. Secondly we introduce a notion of rule transformation which transforms rules in one domain into those in the other. Then we can formalize the reasoning as a system with three inference rules : instantiation of rules, modus ponens, and the rule transformation. Finally, based on the formalization, we present an extended...