Prolog实现太阳系星体识别专家系统

1.广义上,太阳系的领域包括太阳、4颗像地球的内行星、由许多小岩石组成的小行星带、4颗充满气体的巨大外行星、充满冰冻小岩石、被称为柯伊伯带的第二个小天体区。在柯伊伯带之外还有黄道离散盘面、太阳圈和依然属于假设的奥尔特云。

2.离太阳较近的水星、金星、地球及火星称为类地行星,木星与土星称为近日行星,天王星与海王星称为远日行星)颗中的6颗有天然的卫星环绕着,这些星习惯上因为地球的卫星被称为月球而都被视为月球。

太阳(Sun)拥有太阳系内已知质量的99.86%,并以引力主宰着太阳系。重力28.01G。体积1304000地球体积。质量333400地球质量。公转约两亿两千六百万(绕银河系)地球年。自转25.38天(赤道)/37.01天(南北两极)。

属性:恒星;类地行星(4);近日行星(2);远日行星(2)

      恒星;内行星(4);小行星带;外行星(4);柯伊伯带;

3.内太阳系在传统上是类地行星和小行星带区域的名称,主要是由硅酸盐和金属组成的。

4.四颗中的三颗(金星、地球、和火星)有实质的大气层。

水星(Mercury)(0.4 天文单位)是最靠近太阳,也是最小的行星(0.055地球质量)。它没有天然的卫星。重力 0.376 G。公转87.97地球天。自转58.65地球天。体积0.056地球体积。

金星(Venus)(0.7 天文单位)的体积尺寸与地球相似(0.815地球质量)。没有天然的卫星。重力 0.903 G。公转 224.7 地球天。自转 243 地球天,太阳系中自转周期最长的行星。最热的行星,表面高温度可达摄氏480度。全天最亮的行星就是金星。体积0.91地球体积。

地球(Earth)(天文单位)是内行星中最大且密度最高的,也是唯一地质活动仍在持续进行中并拥有生命的行星(至今科学家还没有探索到其他来自太空的生物)。有一颗卫星,即月球。重力 1 G。公转 365.26 地球天。自转 0.9973 地球天。直径最大和比重最大的岩石行星。

火星(Mars)(1.5 天文单位)比地球和金星小(0.107地球质量)。重力 0.38 G。公转 686.98 地球天。自转 1.026 地球天。体积约为地球的十分之一。火星上最大的火山-------奥林柏斯山Olympus Mons,高出地面24公里,几乎是地球上最高山(珠穆朗玛峰Mount Everest)3倍,同时也是太阳系最高的山。体积0.151地球体积。有2颗卫星。体积是0.151地球体积。

5.在外侧的四颗行星,也称为类木行星,囊括了环绕太阳99%的已知质量。木星和土星的大气层都拥有大量的氢和氦HydrogenHelium,天王星和海王星的大气层则有较多的,像是水、氨和甲烷(waterAmmoniaMethane)。

木星(Jupiter)(5.2 天文单位),主要由氢和氦组成,质量是地球的317.832倍,也是其他行星质量总合的2.5倍。重力 2.48 G。公转 11.86 地球年。自转 0.414 地球天。木星的丰沛内热在它的大气层造成一些近似永久性的特征,例如云带和大红斑cloud bands and the Great Red Spot)。木星已经被发现的卫星有63颗。甘尼米德比水星还要大,是太阳系内最大的卫星(Ganymede, the largest satellite in the Solar System, is larger than Mercury )。体积是1321地球体积。

土星(Saturn)(9.5 天文单位),因为有明显的环系统而著名(distinguished by its extensive ring system )。质量是地球的95.16倍。重力 0.94G。公转 29.46 地球年。自转 0.436 地球天。它有60颗已知的卫星。泰坦比水星大,而且是太阳系中唯一实际拥有大气层的卫星。体积是755地球体积(Titan, the second largest moon in the Solar System, is larger than Mercury and the only satellite in the Solar System with a substantial atmosphere. )。

天王星(Uranus)(19.6 天文单位),是最轻的外行星,质量是地球的14.54倍。重力 0.89G。公转 84.01 地球年。自转 0.72 地球天。它的自转轴对黄道倾斜达到90度,因此是横躺着绕着太阳公转,在行星中非常独特(Uniquely among the planets, it orbits the Sun on its side; its axial tiltis over ninety degrees to the ecliptic )。在气体巨星中,它的核心温度最低。天王星已知的卫星有27颗。天王星是人类用肉眼所能看到的最远的一颗行星。有23颗已知卫星。体积是63地球体积。

海王星(Neptune)(30 天文单位)质量是地球的17.15倍。重力1.11G。他虽然辐射出较多的热量,但远不及木星和土星多。海王星已知有13颗卫星,最大的崔顿是太阳系中,最冷的星体,温度在摄氏零下235度。有别于太阳系中大部分的卫星,崔顿是以海王星自转的反方向来绕其母行星运行,是太阳系内唯一逆行的大卫星( Triton is the only large satellite with a retrograde orbit. )。海王星是离太阳最远的行星。体积是58地球体积。


恒星:Star

内行星:Inner planet

外行星:Outer planet

重力:gravity

体积:volume

质量:mass (earth masses)

公转:revolution

地球年/天:year/day of planet earth

自转:rotation

赤道:equator

南北两极:north and south poles

硅酸盐:silicate

氢:hydrogen

氦:helinum 

氨:ammonia

甲烷:methane 

卫星:satellite

表面温度:surface temperatures

摄氏度:degrees Celsius

密度:density

直径:diameter

轴面斜角:axial tilt

黄道:ecliptic

逆行轨道:retrograde orbit

等离子:plasma

地球距离:AU


DOMAINS
    object, vargroup, mess, element, things, strings, response = symbol
DATABASE
    is_fact(symbol, symbol)
	is_not(symbol, symbol)
PREDICATES
    solar_system
    solar_system000
    init
    identify(object)
	out_message(object)
	group(vargroup)
	group_message(vargroup, mess)
	composition(element)
	has(things)
	character(strings)
	act_on(response, symbol, symbol)
	forget
	redo
	run_again(response)
GOAL
    solar_system.
CLAUSES
	solar_system :- init, solar_system000.
	solar_system000 :- identify(Object),
				       out_message(Object),
                       forget.
    
	
	/*init规则,显示提示信息*/
	init :- nl, nl,
	        write("****************************************"), nl, nl,
		    write("This is a program to identify"), nl,
			write("the single star and the eight planets"), nl,
			write("in our Solar System."), nl,
			write("The program will ask a series of"), nl,
			write("questions to which you must answer"), nl,
			write("yes or no."), nl, nl,
			write("****************************************"), nl,
			readln(_), nl.
    
	
	/*identify规则,主体目标,共有10个规则,其中9个规则对应9个星体,如果这9个都不适用,则用第10个,即星体无法识别*/
	identify("Sun") :- group("Star").
	identify("Mercury") :- group("Inner planet"),
						   composition("Terrestrial planet composed largely of silicate and metal"), 
						   character("1. It is the smallest planet. \n2. It is nearest to the Sun.").
					   
	identify("Venus") :- group("Inner planet"),
                         composition("Terrestrial planet composed largely of silicate and metal"),
					     has(atmosphere),
						 character("1. It has the longest rotation period.\n2. It is the hottest planet with surface temperatures over 400 degrees Celsius.\n3. It is the brighest planet in the sky.").
					     /*1.在太阳系中有最长的自转周期   2.这是一个最热的行星,表面温度超过400摄氏度   3.是天空中最亮的行星*/
						 
	identify("Earth") :- group("Inner planet"),
                         composition("Terrestrial planet composed largely of silicate and metal"),
					     has(atmosphere),
					     has(satellite),
						 character("1. It is the largest planet with highest density among the inner planets.\n2. It has life.").
						 /*1.在内行星中最大且密度最高   2.是唯一地质活动仍在持续进行中并拥有生命的行星(至今科学家还没有探索到其他来自太空的生物)*/
						 
	identify("Mars") :- group("Inner planet"),
                        composition("Terrestrial planet composed largely of silicate and metal"),
					    has(atmosphere),
					    has(satellite),
					    character("1. It has a vast volcano, Olympus Mons, which is three times as high as Mount Everest(the highest mountain on earth), making it the highest mountain in the Solar System.\n2. It is the most likely place people would like to emigrate in the future.").
						/*1.火星上最大的火山-----奥林柏斯山Olympus Mons,高出地面24公里,几乎是地球上最高山(珠穆朗玛峰Mount Everest)3倍,同时也是太阳系最高的山   2.最有可能在未来移民的星球*/
					
	identify("Jupiter") :- group("Outter planet"),
                           composition("Gas gaint composed largely of hydrogen and helinum"),
						   has(atmosphere),
						   has(satellite),
						   character("1. It has the largest satellite in the Solar System, Ganymede, which is larger than Mercury.\n2. It has semi-permanent features in its atmosphere, such as cloud bands and the Great Red Spot.\n3. It is the largest planet in the Solar System.").
					       /*1.有太阳系内的最大卫星,甘尼米德,比水星还要大   2.在大气层中有半永久化的特征比如云带和大红斑   3.是太阳系内最大的行星*/
						   
	identify("Saturn") :- group("Outter planet"),
                          composition("Gas gaint composed largely of hydrogen and helinum"),
					      has(atmosphere),
						  has(satellite),
						  character("1.It has the second largest satellite in the Solar System, Titan, which is larger than Mercury.\n2. Titan is the only satellite in the Solar System with a substantial atmosphere.\n3. It is distinguished by its extensive beautiful ring system.").
						  /*1.有太阳系内第二大卫星,泰坦,比水星还要大   2.泰坦是太阳系中唯一实际拥有大气层的卫星   3.因为有明显且美丽的环状系统而著名*/
						  
	identify("Uranus") :- group("Outter planet"),
                          composition("Gas gaint composed largely of ices like water, ammonia and methane"),
					      has(atmosphere),
						  has(satellite),
						  character("1. It is the farthest planet that can be recognized by naked eye.\n2. It orbits the Sun on its side, its axial tilt is over ninety degrees to the ecliptic which is unique among the planets.").
						  /*1.是人类用肉眼所能看到的最远的一颗行星   2.它的自转轴对黄道倾斜达到90度,因此是横躺着绕着太阳公转,在行星中非常独特*/
						  
	identify("Neptune") :- group("Outter planet"),
                           composition("Gas gaint composed largely of ices like water, ammonia and methane"),
                           has(atmosphere),
						   has(satellite),
						   character("1.It has a satellite, Triton, which is the only large satellite with a retrograde orbit.\n2. It is the farthest planet from the Sun.").
						   /*1.有一颗卫星,崔顿,是以母行星自转的反方向来绕其母行星运行,是太阳系内唯一逆行的大卫星    2.距离太阳最远的行星*/
						   
	identify(no) :- !.

	
	/*group规则,为identify的内部规则,用来确定星体所属的范畴*/
	group(Group) :- is_fact(group, Group), !.
	group(Group) :- is_not(group, Group), !, fail.
	group(Group) :- not(is_fact(group, _)), nl, 
                    group_message(Group, Mess),
					write("Does it belongs to"),
					write(Mess),
					write(" ? "),
					readln(Response),
					act_on(Response, group, Group).
	
	
	/*group_message事实,每一个范畴的输出信息*/				
    group_message("Star", " Star which is a massive, luminous ball of plasma held together by gravity"). 
	        /*恒星:大质量、明亮的等离子体球*/
    group_message("Inner planet", " Inner planets which are relatively close to the Sun, similar to Earth and do not have ring systems").
			/*内行星:比较靠近太阳,类似地球并且没有环状系统*/
    group_message("Outter planet", " Outter planets which are further from the Sun, full of gas and have ring systems").
			/*外行星:比较远离太阳,充满气体并且有环状系统*/
	
	
	/*composition规则,用来确定星体的组成元素*/
    composition(Element) :- is_fact(composition, Element), !.	
	composition(Element) :- is_not(composition, Element), !, fail.
	composition(Element) :- not(is_fact(composition, _)), nl,
	                        write("Is it a "),
						    write(Element),
						    write(" ? "),
						    readln(Response),
						    act_on(Response, composition, Element).
			
			
	/*has规则,用来确定星体拥有的事物*/					 
	has(Things) :- is_fact(has, Things), !.	
	has(Things) :- is_not(has, Things), !, fail.
	has(Things) :- nl,
	               write("Does it have "),
				   write(Things),
				   write(" ? "),
				   readln(Response),
				   act_on(Response, has, Things).
				   
				   
	/*character规则,用来确定星体的区别性特性*/			   
	character(Strings) :- is_fact(character, Strings), !.
	character(Strings) :- is_not(character, Strings), !, fail.
	character(Strings) :- not(is_fact(character, _)), nl,
	                      write("Does it have the characters:\n"),
				          write(Strings), nl,
				          readln(Response),
				          act_on(Response, character, Strings).
						  
						  
	/*act_on规则,用来得到用户对问题的回答*/			   
    act_on(yes, Attribute, Type) :- asserta(is_fact(Attribute, Type)).
	act_on(no, Attribute, Type) :- asserta(is_not(Attribute, Type)), fail.
	
	
	/*out_message规则,用来显示系统的结论*/
	out_message(no) :- nl, nl,
	                   write("****************************************"),
					   nl, nl,
					   write("Failure ! "), nl, nl,
					   write("Cannot identify the object."), nl, nl, 
					   write("****************************************"), nl.
	out_message("Sun") :- nl, nl,
						  write("****************************************"),
						  nl, nl,
						  write("The object is Sun. "), nl, nl, 
						  write("Gravity:  28.01 G"),nl, nl, 
						  write("Volume:  1304000 Earth volumes"), nl, nl, 
						  write("Mass:  333400 Earth masses"), nl, nl,
						  write("Revolution period around Milky Way galaxy center:  226000000 Earth years"), nl, nl, 
						  write("Rotation period:   25.38 Earth days(Equator)/37.01 Earth days(South and North poles)"), nl, nl,
						  write("****************************************"), nl.
	out_message("Mercury") :- nl, nl,
						      write("****************************************"),
						      nl, nl,
						      write("The object is Mercury. "), nl, nl,
							  write("Distance:  0.4 AU from the Sun"), nl, nl, 
						      write("Gravity:  0.367 G"),nl, nl,
						      write("Volume:  0.056 Earth volumes"), nl, nl,
						      write("Mass:  0.055 Earth masses"), nl, nl,
						      write("Revolution period:  87.97 Earth days"), nl, nl,
						      write("Rotation period:  58.65 Earth days"), nl, nl,
							  write("Number of moon:  0"), nl, nl,
							  write("****************************************"), nl.
	out_message("Venus") :- nl, nl,
						    write("****************************************"),
						    nl, nl,
						    write("The object is Venus. "), nl, nl,
							write("Distance:  0.7 AU from the Sun"), nl, nl,
						    write("Gravity:  0.903 G"),nl, nl,
						    write("Volume:  0.91 Earth volumes"), nl, nl,
						    write("Mass:  0.815 Earth masses"), nl, nl,
						    write("Revolution period:  224.7 Earth days"), nl, nl,
						    write("Rotation period:  243 Earth days"), nl, nl,
							write("Number of moon:  0"), nl, nl,
							write("****************************************"), nl.
	out_message("Earth") :- nl, nl,
						    write("****************************************"),
						    nl, nl,
						    write("The object is Earth. "), nl, nl,
							write("Distance:  1.0 AU from the Sun"), nl, nl,
						    write("Gravity:  1.0 G"),nl, nl,
						    write("Volume:  1.0 Earth volumes"), nl, nl,
						    write("Mass:  1.0 Earth masses"), nl, nl,
						    write("Revolution period:  365 Earth days"), nl, nl,
						    write("Rotation period:  1 Earth day"), nl, nl,
							write("Number of moon:  1"), nl, nl, 
							write("****************************************"), nl.
	out_message("Mars") :- nl, nl,
						   write("****************************************"),
						   nl, nl,
						   write("The object is Mars. "), nl, nl,
						   write("Distance:  1.5 AU from the Sun"), nl, nl,
						   write("Gravity:  0.38 G"),nl, nl,
						   write("Volume:  0.151 Earth volumes"), nl, nl,
						   write("Mass:  0.107 Earth masses"), nl, nl,
						   write("Revolution period:  686.98 Earth days"), nl, nl,
						   write("Rotation period:  1.026 Earth days"), nl, nl,
						   write("Number of moon:  2"), nl, nl,
						   write("****************************************"), nl.
	out_message("Jupiter") :- nl, nl,
						      write("****************************************"),
						      nl, nl,
						      write("The object is Jupiter. "), nl,
						      write("Distance:  5.2 AU from the Sun"), nl, nl,
						      write("Gravity:  2.48 G"),nl, nl,
						      write("Volume:  1321 Earth volumes"), nl, nl,
						      write("Mass:  317.832 Earth masses"), nl, nl,
						      write("Revolution period:  11.86 Earth years"), nl, nl,
						      write("Rotation period:  0.414 Earth days"), nl, nl,
							  write("Number of moon:  63"), nl, nl,
							  write("****************************************"), nl.
    out_message("Saturn") :- nl, nl,
						     write("****************************************"),
						     nl, nl,
						     write("The object is Saturn. "), nl, nl,
						     write("Distance:  9.5 AU from the Sun"), nl, nl,
						     write("Gravity:  0.94 G"),nl, nl,
						     write("Volume:  755 Earth volumes"), nl, nl,
						     write("Mass:  95.16 Earth masses"), nl, nl,
						     write("Revolution period:  29.46 Earth years"), nl, nl,
						     write("Rotation period:  0.436 Earth days"), nl, nl,
							 write("Number of moon:  60"), nl, nl,
							 write("****************************************"), nl.
	out_message("Uranus") :- nl, nl,
						     write("****************************************"),
						     nl, nl,
						     write("The object is Uranus. "), nl, nl, nl,
						     write("Distance:  19.6 AU from the Sun"), nl, nl,
						     write("Gravity:  0.89 G"),nl, nl,
						     write("Volume:  63 Earth volumes"), nl, nl,
						     write("Mass:  14.54 Earth masses"), nl, nl,
						     write("Revolution period:  84.01 Earth years"), nl, nl,
						     write("Rotation period:  0.72 Earth days"), nl, nl,
							 write("Number of moon:  27"), nl, nl,
							 write("****************************************"), nl.
    out_message("Neptune") :- nl, nl,
						     write("****************************************"),
						     nl, nl,
						     write("The object is Neptune. "), nl, nl,
						     write("Distance:  30 AU from the Sun"), nl, nl,
						     write("Gravity:  1.11 G"),nl, nl,
						     write("Volume:  58 Earth volumes"), nl, nl,
						     write("Mass:  17.15 Earth masses"), nl, nl,
							 write("Number of moon:  13"), nl, nl,
                             write("****************************************"), nl.
	

    /*forget规则,用来清除知识库,以便下次运行程序*/	
	forget :- retract(is_fact(Attribute, Type)), fail.
	forget :- retract(is_not(Attribute, Type)), fail.
	forget :- nl, write("Program finished."), nl, nl, redo.
	
	
	/*redo和run_again规则,可以使程序在用户需要的情况下重新运行*/
	redo :- write(" Do you want to run the program again ? "),
			readln(Response),
			run_again(Response).
			
	run_again(yes) :- nl, nl, solar_system000.
	run_again(no) :- nl, nl.


你可能感兴趣的:(Prolog实现太阳系星体识别专家系统)