All pastes #194278 Raw Edit

animal.lsp

public text v1 · immutable
·published 2006-10-07 19:20 UTC
rendered paste body
-- --------------------------------------------------------------------------
CR .( First set of rules.) CR

'( MAMMAL  GIVES-MILK HAS-HAIR ) set-to rule1
'( GOAT  IS-BILLY ) set-to rule2
'( GOAT  MAMMAL HAS-HORNS ) set-to rule3
'( HAS-HAIR ) set-to fact1
'( HAS-HORNS ) set-to fact2
'( GIVES-MILK ) set-to fact3

'( @rule1 @rule2 @rule3 @fact1 @fact2 @fact3 ) set-to CLAUSES

   '( GOAT ) set-to GOALS
CR .( testing if ) goals -type .(  is possible given the facts: )
   goals clauses pSEARCH [IF] .( YES) [ELSE] .( NO) [THEN] .( .)

   '( MAMMAL ) set-to GOALS
CR .( testing if ) goals -type .(  is possible given the facts: )
   goals clauses pSEARCH [IF] .( YES) [ELSE] .( NO) [THEN] .( .)

   '( RUBBER-DUCKY ) set-to GOALS
CR .( testing if ) goals -type .(  is possible given the facts: )
   goals clauses pSEARCH [IF] .( YES) [ELSE] .( NO) [THEN] .( .)

CR .STAT CR
-- --------------------------------------------------------------------------
CR .( Second set of rules.) CR

'( GIVES-MILK ) 		set-to fact1
'( HAS-HAIR   ) 		set-to fact2
'( HAS-HORNS  ) 		set-to fact3
'( HAS-HAIR IS-GRUFFY ) 	set-to rule1
'( MAMMAL GIVES-MILK HAS-HAIR ) set-to rule2
'( GOAT IS-BILLY ) 		set-to rule3
'( GOAT IS-GRUFFY ) 		set-to rule4
'( GOAT MAMMAL HAS-HORNS ) 	set-to rule5

'( @rule1 @rule2 @rule3 @rule4 @rule5 @fact1 @fact2 @fact3 ) set-to CLAUSES
'( GOAT ) set-to GOALS

CR .( testing if ) goals -type .(  is possible given the second set of rules: )
   goals clauses pSEARCH [IF] .( YES) [ELSE] .( NO) [THEN] .( .)

CR .STAT CR
-- --------------------------------------------------------------------------
CR .( Entering animal database.) CR

'( IS-MAMMAL HAS-HAIR ) 			set-to rule1
'( IS-MAMMAL GIVES-MILK )	 		set-to rule2
'( IS-BIRD HAS-FEATHERS ) 			set-to rule3
'( IS-BIRD FLIES LAYS-EGGS )		 	set-to rule4
'( IS-CARNIVORE EATS-MEAT )	 		set-to rule5
'( IS-CARNIVORE HAS-POINTED-TEETH 
   HAS-CLAWS HAS-FORWARD-EYES ) 		set-to rule6
'( IS-UNGULATE IS-MAMMAL HAS-HOOFS )	 	set-to rule7
'( IS-UNGULATE IS-MAMMAL CHEWS-CUD ) 		set-to rule8
'( IS-CHEETAH IS-MAMMAL IS-CARNIVORE 
   HAS-TAWNY-COLOR HAS-DARK-SPOTS )	 	set-to rule9
'( IS-TIGER IS-MAMMAL IS-CARNIVORE 
   HAS-TAWNY-COLOR HAS-BLACK-STRIPES )		set-to rule10
'( IS-GIRAFFE HAS-LONG-NECK 
   HAS-LONG-LEGS HAS-DARK-SPOTS )	 	set-to rule11
'( IS-ZEBRA IS-UNGULATE HAS-BLACK-STRIPES )	set-to rule12
'( IS-OSTRICH IS-BIRD DOES-NOT-FLY 
   HAS-LONG-NECK HAS-LONG-LEGS ) 		set-to rule13
'( IS-PENGUIN IS-BIRD DOES-NOT-FLY SWIMS 
   IS-BLACK-AND-WHITE ) 			set-to rule14
'( IS-ALBATROSS IS-BIRD FLIES-WELL ) 		set-to rule15

'( HAS-FEATHERS )	set-to fact1
'( FLIES-WELL ) 	set-to fact2

'( @rule1 @rule2 @rule3 @rule4 @rule5 @rule6 @rule7 @rule8 @rule9 @rule10 
   @rule11 @rule12 @rule13 @rule14 @rule15 @fact1 @fact2 )  set-to CLAUSES

'( IS-ALBATROSS ) set-to GOALS

CR .( testing if ) goals -type .(  is possible given the animal database )
CR .( plus fact1: ) fact1 -type .(  and fact2: ) fact2 -type .(  : )
   goals clauses pSEARCH [IF] .( YES) [ELSE] .( NO) [THEN] .( .)

CR .STAT