What is ProLog?
Prolog is a Declarative or logical Language. Prolog is one of the first logic programming languages and it remains popular today. Prolog is a logic programming language from the 1970s that is still one of the main programming languages used in artificial intelligence and computational linguistics. Prolog is Turing complete and uses logic to answer complex questions. Prolog takes only facts and rules to arrive at goals.
Why Learn Prolog?
Learning prolog will certainly not always be as fruitful as learning C++, Java or Python. ProLog is most useful in the areas related to Artificial Intelligence research, such as problem solving, (path) planning or natural language interpretation. Some fields that are not strictly AI, such as parser building, can also benefit greatly from prolog.
Why Prolog language is stated as a Procedural Language?
In Prolog, procedures are referred as predicate. It is also known as a procedural language due to the two unusual aspects of prolog like prolog is non-deterministic and has assign- once variables.
Write a sample program in prolog language?
Here is an example. of Sample programming language by displaying the message “Hello”:
SOURCE CODE
// the main program (this is a comment)
Hello:-
NL,
Write (‘Hello!’).
}
Where you use + Operator in Prolog?
In prolog Operator + can be used to negate goals; these are either sub-goals in the body of a rule or sub-goals of a query. We cannot negate facts or the heads of rules.
What is unification in Prolog?
Unification: The way in which Prolog matches two terms is called unification. The unification algorithm in Prolog is roughly this: df:un Given two terms and which are to be unified: If and are constants (i.e. atoms or numbers) then if they are the same succeed.
What are some data types in prolog programming language?
Prolog is a single data type is the term. Terms are either atoms, numbers, variables or compound terms
Atom: An atom is a general-purpose name with no inherent meaning. Ex: x, red, ‘Taco’, and some atom.
Numbers: Numbers are like integers, float etc. Most of the major Prolog systems support arbitrary precision integer numbers.
Variables: Are denoted string consisting of letters, numbers, underscore characters, and beginning with an upper-case letter or underscore.
Compound Terms: A compound term is composed of an atom called a “functor” and a number of “arguments”, which are again terms. They are written by separating them by commas. Ex: truck year (‘Mazda’, 1986) and ‘Person Friends'(Zelda, [tom, Jim]).
What are the Applications of Prolog?
Some applications of Prolog are:
- Machine learning
- Intelligent data base retrieval
- Natural language understanding
- Expert systems
- Specification language
- Robot planning
- Automated reasoning
- Problem solving
What is List Structures in Prolog?
A list is an ordered sequence of elements that can have any length. Lists are a common data structure in computer programming. The data structure used to represent lists in Prolog has a functor (name) of “.”. Here the elements are variables, constant, structures, including other lists.
What is recursion in prolog?
In any language, a function that can call itself until the goal has been succeed is referred as recursion. In Prolog, recursion happens when a predicate contains a goal that refers to itself.
What is CLP? What are the important domains in CLP?
CLP means Constraint Logic Programming. Constraint logic programming is a form of constraint programming, in which logic programming is extended to include concepts from constraint satisfaction. A constraint logic program is a logic program that contains constraints in the body of clauses. CLP(X) stands for constraint logic programming over the domain X.
Plain Prolog can be regarded as CLP (H), where H stands for Her brand terms. Over this domain, =/2 and dif/2 are the most important constraints that express, respectively, equality and disequality of terms. Plain Prolog can thus be regarded as a special case of CLP.
There are dedicated constraint solvers for several important domains:
CLP (FD) for integers
CLP (B) for Boolean variables
CLP (Q) for rational numbers
CLP(R) for floating point numbers
What are the advantages of CLP on Prolog in practical applications?
CLP(X) uses “interpretable” domain X, e.g., reals, integers, strings, while pure Prolog is limited to “uninterpretable” Herbrand Universe. Also, Prolog uses unification as a main data operation while CLP allows declarative constraints which are more general than unification.
What is backtracking?
Prolog starts the process called backtracking. Backtracking is a process. When a sub goal fails, the Prolog system traces its steps backwards to the previous goal and tries to resatisfy it.This means that all variables that were bound to a value when that goal was satisfied are now made free again. Then the Prolog system tries to resatisfy that goal by matching with the next clause starting at the clause just after the one that matched the sub goal.
This continues until either the sub goal is satisfied, or until the program database has been exhausted, at which point Prolog backtracks yet again to the sub goal that was before the current sub goal.
How is a subgoal satisfied?
A subgoal can be satisfied in two ways:
By matching with a fact. If the matching occurs, the subgoal is satisfied.
By matching with the head of a rule. If matching occurs, the subgoal is only satisfied if all of the sub goals of the body of the rule can also be satisfied.
What is Recursivity?
Recursivity is a concept which we find again and again in computer science: In programming problems, in data structures, in definitions of programming constructs, in languages, etc.
Why we use prolog programming language?
- Prolog is interactive.
- SWI-Prolog is free, open-source, and very well maintained.
- It’s much easier to distribute SWI-Prolog applications than Java ones
- Prolog is much less verbose, which is helpful when during development.
- Prolog allows one to define any word or collection of “symbol characters” (e.g. >>, +, /, , //, :===/===:) as an infix, postfix, or prefix operator.
- In Prolog, you can treat data as programs.
What is SWI-Prolog?
SWI-Prolog is a versatile implementation of the Prolog language. Its robust multi-threading, extended data types, unbounded arithmetic and Unicode representation of text allow for natural representation of documents (e.g., XML, JSON, RDF) and exchange of data with other programming paradigms.
What is cut (!) in prolog and what is the advantage of ‘cut’ and ‘negation’?
Cut function is used in Prolog when you want to restrict Prolog from backtracking into certain choice points or sub goals, either because the alternatives would give wrong solutions or for efficiency reasons.
Advantage of using cut in Prolog is:
Through cut, we can often improve the efficiency of the program
We can specify exclusive rules using cut
Mention What Is The Difference Between = And = = In Prolog?
The “=” operator in Prolog is actually a predicate that stands for unification. This operator “= =” means the two terms are not identical. Unification does not take place even if this succeeds.
What kind of SWI is prolog especially useful for writing?
Prolog seems to be good for problems in which logic is intimately involved, or whose solutions have a logical characterization. Like other interactive, symbolic languages, Prolog is also good for rapid prototyping.
What are the major examples of use of prolog in 'real life' applications?
You can find PROLOG in areas like expert systems or theorem provers construction. The variant of PROLOG called DATALOG is used in database management.
What is the difference between bagof/3 and setof/3 predicate in prolog?
Setof/3 is similar to bagof/3 and the difference between is that bagof/3 leaves all repeated solutions while setof/3 removes them.
Will prolog withstand in competition with modern lp languages such as goedel?
The languages like Goedel, ALF, and LIFE etc. are currently more oriented to theory than to real-world applications. In real-life usage, we can give more chances to CLP which is sometimes assumed as a PROLOG lifesaver for practical applications.
What is a predicate in Prolog?
A Prolog program consists of predicate definitions. A predicate denotes a property or relationship between objects. Definitions consist of clauses. A clause has a head and a body (Rule) or just a head (Fact). A head consists of a predicate name and arguments.