Prolog - Chain rule for Step Siblings -


I am a newbie for prologue, and one about "series rule" programming for step-siblings The question is "common parents"

In my program, I am assuming that parents (X, Y) claim the fact that X believes that Yi is the mother of Yi.

I need a rule series (X, Y, L): If X is the ancestor , then the L list < / Em is> include all ancestors of X, Y and Y, which are descendents of X, which are listed in the descending age sequence ( oldest first ). In other words, my list should include all those people who link to a person with ancestors .

Example: If series (Peter, Mary, [Peter, Paul, Sue, Mary]) , then Peter Paul is the guardian of Paul's parents Sue , and Sue Mary Is the guardian of

Note: I'm familiar with the relationship with step sibling (A, B) where their relationship is their parents partners (X, Y ) ; Where there is the child of brother A and B their related parents through the relationship children (A, X) and children (b, y) . Therefore ; I am only confused with the relationship where both step sisters share a common guardian i.e. A child's relationship that can look like this: Children (A, X) and Children (B, X) .

This is an interesting twist on general pedigree problems which we discuss in the rapid prol First consider a simplification, Ancestors (X, Y) is true if the ancestor of XY

then you have a predicate parent (x, y) which says that X is the root of Y. You can write ancestor / 2 in this way:

 % base case: your parents ancestor of ancestors (x, y): - guardian ( X, Y). Ancestor (X, Z): - Parent (X, Y), Ancestor (Y, Z)   

This should work fine with a sample database like this:

  Parent (Peter, Paul). Parents (Paul, Sue) parents (Sue, Mary)   

This will work for a question like ancestor (Peter, Mary), who That's close to what you want. The next step will be to maintain the chain, which will look like this:

  series (x, y, [x, y]): - guardian (x, y) Chain (x, z, [x | chain]): - guardian (x, y), chain (y, z, chain).   

It appears to work:

 ? - Chen (Peter, Mary, X). X = [Peter, Paul, Sue, Mary]; false.   

I'm worried, because stepping in your question is mention of siblings and that should include other people in the series. Is this just a bunch or do you have additional requirements? If so, they are not showing in your example, so I may need to increase your question with additional details.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -