日期:2014-05-20 浏览次数:20935 次
var net= new LogicSystem(); net.Add(new Father('x','y') => new Child('y','x'), new male('y')); net.Add(new grandFather('x1','y') => new child('y','x1'), new male('y')); net.Add(new grandFather('x1','y') => new child('y','x1'), new female('y')); net.SaveToDatabase(connectionString); var results= net.SoveGoal(new grandFather('a',"林黛玉"), new grandFather('a',"凤姐")); foreach(var ret in results) Console.WriteLine("林黛玉跟凤姐的共同的祖母是{0}", ret.First(x=> x.Name=='a').Value);
------解决方案--------------------
自己实现他们难度太大了
自己的token,自己的语法树,自己的文法解析,回溯迭代,一套下来估计编译原理就可以考90分了
另外codeplex也有一个同类型开源项目 prolog.net
http://prolog.codeplex.com/