Prolog - 节点,叶子,对称性

时间:2015-05-03 21:08:05

标签: prolog

我一直试图了解在Prolog中如何评估以下查询:

reflection(leaf,leaf).
reflection(node(S1,S2),node(T2,T1)) :-
   reflection(S1,T1),
   reflection(S2,T2).

symmetric(T) :-
  reflection(T,T).

| ?- symmetric(X).
X = leaf
X = node(leaf,leaf)
X = node(node(leaf,leaf),node(leaf,leaf))
X = node(node(leaf,node(leaf,leaf)),node(node(leaf,leaf),leaf))
X = ...

我把它实现到X被实例化为leaf然后到node(leaf,leaf),但我无法理解后者。请解释一下,谢谢!

0 个答案:

没有答案