1 / 11

Prolog

Prolog. Prolog is a logic programming language. It is a general purpose language often associated with artificial intelligence and computational linguistics . It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features. Prolog. Data Types. Term.

varana
Download Presentation

Prolog

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Prolog Prolog is a logic programming language. It is a general purpose language often associated with artificial intelligence and computational linguistics. It has a purely logical subset, called "pure Prolog", as well as a number of extralogical features.

  2. Prolog Data Types

  3. Term • Prolog has only one data type called Term. Terms can be classified as follows. • Atom • Number • Variable • Compound Term

  4. Atom • A general-purpose name with no inherent meaning. • This is normally composed of alphanumeric characters, together with ‘_’, beginning in the lower-case letter. • Any sequence of special characters such as + - * / < > = ` ~ : . / ? @ # $ & can also be used to form atoms, however, they should be enclosed in single quotes. • A sequence of any characters at all is accepted as an atom if the whole is delimited by single quotes.

  5. Atom • Atoms beginning with a capital letter must also be quoted, to distinguish them from the variables. • The following are also, by convention, atoms: ! ; [] { } • Be careful with the use of square brackets because it can denote an atom (‘]’ or ‘[‘) or an empty list ([]).

  6. Atom • Examples: • x • blue • ‘Taco’ • ‘some atom’ • [ ] --- empty list

  7. Number • One example that follows implementation-dependent rules because it can be floats or integers but some implementations also provide unbounded integers and rational numbers. • Most also allow decimals and exponent notation. • Integers can be often expressed in bases from 2 to 9. i.e. 5’132 represents 42

  8. Variable • Normally composed of alphanumeric characters plus ‘_’, beginning with an upper-case letter or ‘_’. • Closely resemble variables in logic in that they are placeholders for arbitrary terms. • A variable can become instantiated (bound to a specific term) via unification.

  9. Variable • A single ‘_’ denotes an anonymous variable and means “any term”. • Unlike other variables, the underscore does not represent the same value everywhere it occurs. • Any other variable name has as its scope the clause in which it appears, or to be more precise the instance of the clause in which it appears, and within a clause each occurrence of a variable name stands for the same non-variable term.

  10. Compound Term • Usually referred to by its principal functor. • Functor – distinguished by its two components: name and arity (alias number of arguments) • The arguments are also terms. • Atoms are functors of arity 0.

  11. Compound Term • Written in the form: • functor_name(arg1, arg2, …, argN) • where the principal functor is referred to in writing as functor_name/N • take note that there is no space between the functor name and the opening bracket

More Related