ch15a - Programming Languages Tucker and Noonan 2e Chapter...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
Programming Languages Tucker and Noonan – 2e Chapter 15 – Part 1 Logic Programming “Q: How many legs does a dog have if you call its  tail a leg?  A: Four. Calling a tail a leg doesn’t make it one.”     Abraham Lincoln
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Prolog Prolog is a declarative language : Prolog programs specify what the computer should do (the goal ), not how it should be done (the steps). Procedural (imperative) languages, such as Java or Pascal or C, describe solution steps. It is also a logic programming language based on the predicate calculus, which is a form of symbolic logic.
Background image of page 2
Stating Program Goals Goals are described by assertions (rules) that state the characteristics of the goal. Declarative programming is sometimes called rule-based programming. The rules are formulated according to principles of symbolic logic
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Examples man(john). %Prolog facts man(jack). woman(ann). human(H):-man(H). %Prolog rules human(H):-woman(H). ?-human(ann). %Prolog queries ?-man(X).
Background image of page 4
Features Programs written in logic programming languages exhibit Non-determinism: There may be several solutions, or acceptable goal states Backtracking: the problem-solving mechanism built into Prolog
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background Developed in the 1970s Originated in the field of language processing Other important application areas: artificial intelligence, databases. AI programs, especially expert systems, are often structured as a knowledge base (collection of facts) and a set of rules of the form “if X then Y ”. Database programs also have a knowledge base of specific facts (the database) and a set of rules that express relations between entities.
Background image of page 6
Background SQL (Structured Query Language): a declarative language used in database applications is another well-known example in the declarative paradigm. Many of SQL’s elements (clauses, predicates, queries) also are found in Prolog SQL, however, is not Turing complete whereas Prolog is
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Logic Systems-Propositional Logic Propositional logic (PL) is a formal reasoning system based on propositions : assertions that are either true or false; Propositions are declarative statements; similar to sentences in natural languages composed of constants Propositions are combined using logical operators and, or, if/then, not PL is the basis for logic (boolean-valued) expressions in traditional programming languages.
Background image of page 8
Propositional Logic - Examples Examples of propositions: “Jane is a parent” = proposition p “John is a parent” = proposition q Combining propositions if (p && q) then . . .
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
without variables : parent(jane). parent(john).
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/21/2010 for the course CS 424 taught by Professor Weisskopf during the Spring '10 term at University of Alabama - Huntsville.

Page1 / 44

ch15a - Programming Languages Tucker and Noonan 2e Chapter...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online