Prolog is a logic based programming language, which means that it is based on a formal system of deductive reasoning. Prolog is unique among programming languages in that it uses a declarative programming paradigm, which is a style of programming that is focused on stating the desired results, rather than specifying the steps needed to achieve those results. Prolog is also known for its use of Horn clauses, which are a type of logical formula that is used to express facts and rules about a problem domain.
Some of the major features of Prolog include:
Declarative programming: Prolog is a declarative programming language, which means that programs are written as a series of declarative sentences, or facts and rules. This style of programming is in contrast to imperative programming, which focuses on specifying the steps needed to achieve a desired result.
Horn clauses: Prolog is based on Horn clauses, which are a type of logical formula that is used to express facts and rules about a problem domain. Horn clauses are made up of two parts: a head, which is a predicate, and a body, which is a series of subgoals. Horn clauses are used to represent knowledge in Prolog programs.
Resolution: Prolog uses a rule-based system of deduction called resolution. Resolution is a process of inferring new information from existing information. In Prolog, resolution is used to find a proof for a given goal. A goal is proved by finding a sequence of Horn clauses that can be used to infer the goal from a given set of facts.
Logic variables: Prolog programs contain variables that can be used to represent logic values. Logic variables are different from variables in other programming languages in that they can have multiple values. Logic variables are used to represent information that is unknown or can change during the course of a Prolog program.
Unification: Unification is a process of making two expressions the same. In Prolog, unification is used to match structures, or terms, that have different names but the same structure. Unification is used to solve goals by finding substitutions that make the goal and all of its subgoals true.
backtracking: Backtracking is a process of undoing the effects of previous choices when a goal cannot be proved. In Prolog, backtracking is used to find alternative proofs for a given goal. Backtracking allows Prolog programs to be written in a declarative style, without specifying the order in which the goals should be solved.