The ancestor filter takes two positions as arguments enclosed in parentheses. It matches the position if the first position is an ancestor of the second position:
   ancestor(x y)

We say that position x is an ancestor of position y if, starting from position x there is a nonempty sequence of moves from the PGN file that reach position y.

If x and y are mainline positions, then x is an ancestor of y if and only if the position id of x is smaller than the position id of y. Thus, in this case, one can test if x is an ancestor of y simply by doing:


Note that ancestor (x y) is equivalent to descendant (y x) .