Parsing a family tree

Now that we are more familiar with logic programming, let's use it to solve an interesting problem. Consider the following family tree:

Parsing a family tree

John and Megan have three sons - William, David, and Adam. The wives of William, David, and Adam are Emma, Olivia, and Lily respectively. William and Emma have two children - Chris and Stephanie. David and Olivia have five children - Wayne, Tiffany, Julie, Neil, and Peter. Adam and Lily have one child - Sophia. Based on these facts, we can create a program that can tell us the name of Wayne's grandfather or  Sophia's uncles are. Even though we have not explicitly specified anything about the ...

Get Artificial Intelligence with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.