0% found this document useful (0 votes)
1K views6 pages

Prolog Viva Questions

The document provides a list of 50 unique viva questions and answers related to Prolog, covering fundamentals, syntax, input/output, conditional logic, applications, text manipulation, program-based concepts, output interpretation, advanced concepts, and miscellaneous topics. Each question is accompanied by a concise answer and an explanation to enhance understanding. This resource serves as a study guide for individuals preparing for a viva on Prolog and its applications in artificial intelligence.

Uploaded by

ashmeeton27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views6 pages

Prolog Viva Questions

The document provides a list of 50 unique viva questions and answers related to Prolog, covering fundamentals, syntax, input/output, conditional logic, applications, text manipulation, program-based concepts, output interpretation, advanced concepts, and miscellaneous topics. Each question is accompanied by a concise answer and an explanation to enhance understanding. This resource serves as a study guide for individuals preparing for a viva on Prolog and its applications in artificial intelligence.

Uploaded by

ashmeeton27
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Prolog Viva Questions

i have a viva tommorow from this file provide me 50unique viva question and answer from this file
that can be asked and give explanation of answer

Here are 50 unique viva questions with answers and explanations based on your Artificial
Intelligence Practical File that includes Prolog programs and concepts:

✅ Fundamentals of Prolog
1. Q: What is Prolog?

A: Prolog is a logic programming language used in AI and computational linguistics.

Explanation: It's declarative, meaning you describe what you want, not how to do it.
2. Q: What are the basic building blocks of a Prolog program?

A: Facts, Rules, and Queries.

Explanation: Facts state truths, rules define logic, and queries ask questions.

3. Q: What does the `:-` symbol signify in Prolog?

A: It means "if".

Explanation: It's used in rules to define logical implications.

4. Q: How does Prolog differ from imperative languages?

A: Prolog uses logic, not sequences of commands.

Explanation: It solves problems via logical reasoning.

5. Q: What is a predicate in Prolog?


A: A predicate defines a relationship between terms.
Explanation: It's similar to a function but based on logic.

✅ Syntax and Concepts


6. Q: How do you define a fact in Prolog?

A: `likes(ram, mango).`
Explanation: A statement declaring a relation between two constants.

7. Q: What is unification in Prolog?


A: Matching variables with values.

Explanation: It's how Prolog answers queries.


8. Q: What is backtracking in Prolog?

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/6
A: The process of trying alternative paths if one fails.
Explanation: Ensures all possible answers are explored.
9. Q: What is the use of the `!` (cut) operator?

A: To prevent backtracking past a certain point.


Explanation: Used for optimization and control.

10. Q: What is the output of:


`likes(john, music). likes(john, reading). ?- likes(john, X).`

A: `X = music ; X = reading.`

Explanation: It shows both matches due to backtracking.

✅ Prolog Input/Output
11. Q: How do you write output in Prolog?

A: Using `write()`.
Explanation: It prints to the console.

12. Q: How do you read user input in Prolog?

A: Using `read()`.

Explanation: It waits for input from the console.

13. Q: What does `atom_chars(Word, List)` do?

A: Converts a word to a list of characters.

Explanation: Useful in text processing.

14. Q: What does `atom_codes(Word, List)` do?

A: Converts a word to a list of ASCII values.

Explanation: Useful in encoding/decoding.

15. Q: Why is input/output important in Prolog?

A: For interacting with users and testing.

Explanation: Especially vital in dynamic applications.

✅ Conditional and Arithmetic Logic


16. Q: How do you find if a number is even or odd in Prolog?

A: Using mod operator in conditions.

Explanation: Check if number mod 2 = 0.

17. Q: How is the factorial of a number calculated in Prolog?

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/6
A: Using recursion.

Explanation: Base case + recursive call.

18. Q: What is the output of `max(X, Y, X) :- X >= Y, !.` rule?

A: Returns the maximum of two numbers.


Explanation: Uses cut to skip alternative matches.

19. Q: How do you find the minimum in a list?

A: Recursively compare head with rest.

Explanation: Use conditional rules.

20. Q: What does the if-else logic in Prolog look like?

A: `Condition -> Action1 ; Action2.`

Explanation: Executes based on the truth value.

✅ Applications and Programs


21. Q: What is the 4-Queen problem?

A: Placing 4 queens on a board without conflict.

Explanation: Classic AI constraint satisfaction problem.

22. Q: How is BFS implemented in Prolog?

A: Using a queue to explore nodes level-by-level.

Explanation: Ensures shortest path in graph traversal.

23. Q: What is the water jug problem?

A: Find steps to measure exact water using two jugs.

Explanation: Problem-solving via state-space.

24. Q: How do you check for a palindrome in Prolog?

A: Reverse the list/word and compare.

Explanation: If same, it’s a palindrome.

25. Q: What does the TIC-TAC-TOE program simulate?

A: A game between two players.


Explanation: Demonstrates logic for game moves and winning conditions.

✅ Text Manipulation
26. Q: How do you remove punctuation in a string in Prolog?

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/6
A: Filter out non-alphabet characters.

Explanation: Use predicates to exclude unwanted symbols.

27. Q: How do you sort a sentence alphabetically in Prolog?

A: Convert to list, use sort, and rejoin.


Explanation: Uses list manipulation.

28. Q: What Prolog feature helps in symbolic computation?

A: Rules and unification.


Explanation: Handles abstract symbols and logic.

29. Q: What’s an expert system?

A: A rule-based AI decision-making system.


Explanation: Prolog is ideal for building such systems.

30. Q: How does Prolog help in NLP?

A: By parsing sentences based on grammar rules.

Explanation: Useful in syntax trees and language understanding.

✅ Program-Based Conceptual Questions


31. Q: How do Prolog rules support recursion?

A: A rule can call itself.


Explanation: Essential for loops and traversals.

32. Q: Why is Prolog suitable for AI?

A: It handles logic and inference well.


Explanation: Matches the core of intelligent behavior.

33. Q: Can Prolog do mathematical calculations?

A: Yes, using `is/2`.

Explanation: Evaluates arithmetic expressions.

34. Q: What’s the use of `member(X, List)`?

A: Checks if `X` is in `List`.

Explanation: Common in list operations.

35. Q: What happens if a Prolog query fails?

A: It backtracks.

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 4/6
Explanation: Looks for alternative paths.

✅ Output Interpretation
36. Q: Why do we get multiple outputs in some Prolog queries?

A: Due to backtracking.
Explanation: It checks all possible matches.

37. Q: What does the `;` in Prolog output mean?

A: Indicates another possible answer.

Explanation: User can explore more solutions.

38. Q: What’s the difference between `=` and `is`?

A: `=` matches terms, `is` evaluates.


Explanation: `is` is for arithmetic.

39. Q: What is a goal in Prolog?

A: A query to be satisfied.
Explanation: Like a function call.

40. Q: Can you explain the Prolog search strategy?

A: Depth-first with backtracking.


Explanation: Explores deep before wide.

✅ Advanced Concepts
41. Q: What are knowledge bases in Prolog?

A: Collection of facts and rules.

Explanation: Basis of AI decision-making.

42. Q: Can Prolog handle graphs?

A: Yes, using predicates and facts.


Explanation: Represent edges and nodes as relations.

43. Q: How is Prolog used in symbolic reasoning?

A: To manipulate symbols with logic.


Explanation: No need for numeric computation.

44. Q: What’s a recursive list definition in Prolog?

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 5/6
A: A list is a head and a tail list.
Explanation: Foundation for list operations.

45. Q: What does `fail` do in Prolog?

A: Forces failure to test alternatives.

Explanation: Used for control flow.

✅ Miscellaneous
46. Q: What is a variable in Prolog?

A: A symbol starting with uppercase.


Explanation: Can take any value during unification.

47. Q: Why use `not` or `\+` in Prolog?

A: To represent negation.
Explanation: Useful in logical constraints.

48. Q: What does `true.` mean in Prolog output?

A: The query succeeded.


Explanation: No further answers.

49. Q: What is meant by declarative programming?

A: You declare facts/rules, not control flow.

Explanation: The system figures out execution.

50. Q: Is Prolog case-sensitive?

A: Yes.

Explanation: `Ram` and `ram` are different.

Would you like a printable version or PDF of this Q&A sheet?

Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 6/6

You might also like