Terms and Conditions:
Peter Hancox wrote:These notes are publically accessible and we know they are used by students learning at other universities. If you are a tutor and want to use these notes for group teaching, please ask for a copy rather than using our World-Wide Web server.
Excerpts from the Introduction:
The topic of logic programming and the language most generally associated with it, Prolog
, are markedly different from the languages normally taught to first year Software Engineers and Computer Scientists. Logic programming languages aren't widely used beyond research applications, whereas languages like COBOL, Fortran and C are widely used. This begs the question:
Why is Logic Programming important for Software Engineering?
Software Engineering and Computer Science are concerned with producing products. This is obvious: a teenage game hacker is interested in producing software that will run. Many human activities are concerned with building things, for instance bridges, engines or hydraulic cylinder systems. One of the many differences between teenage computer addicts and competent mechanical engineers (as an example) is that the the former produce games based on a combination of intuition, inspiration and experience, whereas the latter have also to prove their design is going to work safely and reliably over an expected life span.
languages, as their name suggests, rely on logic to provide the framework for their meaning. Logic itself was invented as an aid to human thought, allowing knowledge to be set out and reasoned about. It would therefore seem natural to attempt to use it in programming computers. In practice, first order predicate calculus is used, or at least a subset of it. It is not necessary to understand predicate calculus before learning a logic programming language. Indeed, this course takes the view that it is better to learn Prolog, a practical example of a logic programming language, before learning about the underpinning of theory.
Organization of this course:
This course starts with Prolog, because it is believed that it is easier to learn the theory if you have an idea of how it might relate to a practical instance of the theory.
The Prolog course starts with data types and structures. Alongside these, the logic variable is introduced. Variables in logic programming work differently than variables in procedural and functional languages. This comes out most clearly when matching takes place, for logic programming uses a far more powerful matching technique (called unification
) than other languages do.
Having mastered data types, structures and matching, the other main topic is the building of programs. Unlike languages like Pascal which use iteration (with loop constructs like for
), Prolog has no iteration as such but uses recursion. This part of the course is concerned with showing and analysing a variety of different examples so that you can learn to identify the pattern of recursion that would best solve the problem in hand.