• Aucun résultat trouvé

3.3 Implantation en Lisp

5.1.2 Perspectives

Si les types peuvent dépendre des valeurs du système, deux types peuvent être équivalents tout en étant syntaxiquement diérents. Par exemple, les listes de longueur 1 + 1 sont exacte-ment les mêmes que les listes de longueur 2. Pour qu'un système puisse détecter le plus possible de ces équivalences, il est nécessaire d'implanter un procédé appellé la coercion.

L'implantation de la coercion avec des types dépendants par des fonctions est à l'étude pour DTF. Mais, si la conversion des types simples est un sujet connu qui ne pose pas de problème, il en est tout autrement de la conversion des types dépendants qui, elle, nécessite la dénition d'un algorithme de résolution beaucoup plus complexe. En eet, les relations de sous-typage pour les types dépendants incluent des relations d'équivalence de types. Une représentation explicite de cette relation est donnée par la règle suivante : si X et Y sont convertibles, alors X est un sous-type de Y.

La conversion de types permet une augmentation signicative du nombre des Contextes que l'algorithme aura la possibilité de prouver. En eet, la substitution de types par d'autres, lors de la démonstration des Contextes, permettra évidemment d'identier un plus grand nombre de Contextes pour une situation donnée, mais également d'envisager le partage des traitements entre des agents.

L'algorithme DTF-A est conçu pour traiter des descriptions écrites en LISP, ce qui rend dif-cile son écriture par des personnes non qualiées. Une étude est donc en cours pour réaliser une description standard par l'intermédiaire du langage XML de la dénition des Contextes et des Actions décritent avec un outil graphique. Il deviendra alors posssible de générer des contextes depuis des applications existantes comme des interfaces graphiques de conception ou d'autres, mais également d'utiliser ce formalisme pour l'échange de Contextes entre les agents.

Comme la théorie est stratiée (sortes, types et objets), elle peut être utilisée pour la spéci-cation de systèmes et pour prouver qu'ils respectent un ensemble de règles, i.e. qu'il est possible de faire ce que les essentialistes appellent du méta, sans sortir de la théorie.

Pour nir, si DTF est destiné à des applications à environnement changeant, son utilisation pourra également être étendue à d'autres applications, comme par exemple la spécication d'on-tologie, ou encore le Web-sémantique, à ce propos nous pouvons reprendre le propos de Tim Berners-Lee : "if there is a semantic web machine, then it is a proof validator, not a theorem

Chapitre 5. Conclusion prover" [Tim Berners-Lee].

N.B. : Ce travail a donné lieu à de nombreuses publications dans des conférences internatio-nales, contributions à des chapitres d'ouvrages et un revue nationale [47], [46], [10], [43], [44], [10], [42], [9], [41], [41],[45].

A

Annexe A. Trace de l'exécution du Wumpus ( proofautomath )

2

" ls tofd ee pe stcon text "

4 ( (NEXTPOSITIONISAVALIDSQUARE

((((# <AGENTWUMPUS {405DE315}> (#<POSITION {4056AC65}> #<NORTH {4056910D} >))

6 T) T ) ) ) ) 8 " i n f e r e n c ef o r w a r dp o s i t i o n " " goforward " 10 1 " D i r e c t i o n : " 12 #<NORTH {4056910D}> " P o s i t i o n X" 14 1 " P o s i t i o n Y" 16 2 " lstofdeepestco ntext " 18 ( (SMELLYSQUARE

((((# <AGENTWUMPUS {405DE315}> (#<POSITION {4056BD6D}> #<NORTH {4056910D} >))

20 T) T ) ) ) ) 22 " c h a n g ed i r e c t i o n " (#<SOUTH {40569 C75}>) 24 2 " D i r e c t i o n : " 26 #<SOUTH {40569 C75}> " P o s i t i o n X" 28 1 " P o s i t i o n Y" 30 2 " lstofdeepestcontext "

32 ( (NEXTPOSITIONISAVALIDSQUARE

((((# <AGENTWUMPUS {405DE315}> (#<POSITION {4056BD6D}> #<SOUTH {40569 C75} >))

34 T)

T) ) ) 36 (SMELLYSQUARE

((((# <AGENTWUMPUS {405DE315}> (#<POSITION {4056BD6D}> #<SOUTH {40569 C75} >))

38 T) T ) ) ) ) 40 " i n f e r e n c ef o r w a r dp o s i t i o n " " goforward " 42 3 " D i r e c t i o n : " 44 #<SOUTH {40569 C75}> " P o s i t i o n X" 46 1 " P o s i t i o n Y" 48 1 " ls tofd ee pestco n te xt "

50 ( (NEXTPOSITIONISAVALIDSQUARE

((((# <AGENTWUMPUS {405DE315}> (#<POSITION {4056AC65}> #<SOUTH {40569 C75} >))

52 T) T ) ) ) ) 54 " i n f e r e n c ef o r w a r dp o s i t i o n " " goforward " 56 4 " D i r e c t i o n : " 58 #<SOUTH {40BB87A5}> " P o s i t i o n X" 60 1 " P o s i t i o n Y" 62 1 " ls tofd ee pe stco n te xt " 64 ((~AGENTHASGOLD

(((#<AGENTWUMPUS {40BC496D}> (#<POSITION {40BA0BAD}> #<SOUTH {40BB87A5} >)) 66 T ) ) ) ) " c h a n g ed i r e c t i o n " 68 NIL 5 70 " D i r e c t i o n : " #<EAST {40BB8715}> 72 " P o s i t i o n X" 1 74 " P o s i t i o n Y" 1 76 " ls tofd ee pe stco n te xt "

( (NEXTPOSITIONISAVALIDSQUARE

78 ((((# <AGENTWUMPUS {40BC496D}> (#<POSITION {40BA0BAD}> #<EAST {40BB8715} >)) T) 80 T ) ) ) ) " i n f e r e n c ef o r w a r dp o s i t i o n " 82 " goforward " " i n f e r e n c ef o r w a r dp o s i t i o n " 84 6 " D i r e c t i o n : " 86 #<EAST {40BB8715}> " P o s i t i o n X" 88 2 " P o s i t i o n Y" 90 1 " ls tofd ee pe stcon text " 92 ( (BREEZESQUARE

((((# <AGENTWUMPUS {40BC496D}> (#<POSITION {40BC4795}> #<EAST {40BB8715} >)) 94 T) T ) ) ) ) 96 " c h a n g ed i r e c t i o n " NIL 98 " i n f e r e n c ef o r w a r dp o s i t i o n " 7 100 " D i r e c t i o n : " #<NORTH {40BB8775}> 102 " P o s i t i o n X" 2 104 " P o s i t i o n Y" 1 106 " lstofdeepestconte xt "

( (NEXTPOSITIONISAVALIDSQUARE

108 ((((# <AGENTWUMPUS {40BC496D}> (#<POSITION {40BC4795}> #<NORTH {40BB8775} >)) T)

110 T) ) ) (BREEZESQUARE

112 ((((# <AGENTWUMPUS {40BC496D}> (#<POSITION {40BC4795}> #<NORTH {40BB8775} >)) T) 114 T ) ) ) ) " i n f e r e n c ef o r w a r dp o s i t i o n " 116 " goforward " " i n f e r e n c ef o r w a r dp o s i t i o n " 118 8 " D i r e c t i o n : " 120 #<NORTH {40FB3C35}> " P o s i t i o n X" 122 2 " P o s i t i o n Y" 124 2 " lstofdeepestconte xt "

126 ( (NEXTPOSITIONISAVALIDSQUARE

((((# <AGENTWUMPUS {40FBF9C5}> (#<POSITION {40 F970E5}> #<NORTH {40FB3C35} >)) 128 T) T ) ) ) ) 130 " i n f e r e n c ef o r w a r dp o s i t i o n " " goforward " 132 " i n f e r e n c ef o r w a r dp o s i t i o n " 9 134 " D i r e c t i o n : " #<NORTH {40FB3C35}> 136 " P o s i t i o n X" 2 138 " P o s i t i o n Y" 3

140 " l stofdee pestco nte xt " ( (BREEZESQUARE

142 ((((# <AGENTWUMPUS {40FBF9C5}> (#<POSITION {40FBF745}> #<NORTH {40FB3C35} >)) T)

144 T) ) ) (GOLDSQUARE

146 ((((# <AGENTWUMPUS {40FBF9C5}> (#<POSITION {40FBF745}> #<NORTH {40FB3C35} >)) T)

148 #<GOLD {40FBF9A5} >))) (SMELLYSQUARE

150 ((((# <AGENTWUMPUS {40FBF9C5}> (#<POSITION {40FBF745}> #<NORTH {40FB3C35} >)) T) 152 T ) ) ) ) " keepgold " 154 " i n f e r e n c ef o r w a r dp o s i t i o n " 10 156 " D i r e c t i o n : " #<NORTH {40FB3C35}> 158 " P o s i t i o n X" 2 160 " P o s i t i o n Y" 3 162 " l stofde e pestco nt ext " ( (AGENTHASGOLD

164 (((#<AGENTWUMPUS {40FBF9C5}> (#<POSITION {40FBF745}> #<NORTH {40FB3C35} >)) T ) ) ) ) 166 " gohome" " i n f e r e n c ef o r w a r dp o s i t i o n " 168 11 " D i r e c t i o n : " 170 #<NORTH {40FB3C35}> " P o s i t i o n X" 172 2 " P o s i t i o n Y" 174 3 NIL

B

Code Lisp de DTF-A

1 ; ; ; ; Created on 20081017 17:23:38 ; ; ; Décider du niveau .

3 ; ; ; ; ( load "/home/patrick/Thesis/IntContextType/v02a/IntContextType002/IntContextType002/Proof/pproofalgorithmoftdrs . lisp ")

( l e t ( ( l s to fc u r r e n tv a l i dc o n t e x t ' ( ) ) 5 ( lstofdeepe stconte xt ' ( ) ) ( lstofcompound ' ( ) ) 7 ( a c t i v ea g e n t t ) ( currenttype ' r o o t ) 9 ( c u r r e n tg o a l n i l )

( sigmatypesextension ( makehashtable ) )

11 )

( defun addsigmatypesextension ( name e x t e n s i o n ) 13 ( s e t f ( gethash name sigmatypesextension ) e x t e n s i o n )

)

15 ( defun getextensionofsigmatypes ( sigmaname ) ( l e t ( ( sgname ) )

17 ( i f ( typep sigmaname ' compoundtypes )

( s e t f sgname ( gethash sigmaname agentcompoundtypeskb ) ) 19 ( s e t f sgname sigmaname )

)

21 ( gethash sgname sigmatypesextension ) ) )

23 ( defun i n i t i a l i s ee x t e n s i o no fs i g m a ( name )

( s e t f ( gethash name sigmatypesextension ) ' ( ) ) 25 )

( defun sigmatypesp ( v a l u e )

27 ( gethash v a l u e sigmatypesextension ) )

29 ( defun i se x t e n s i o n ( sigmaname )

( not ( equal ( gethash sigmaname sigmatypesextension ) n i l ) ) 31 )

( defun se tc u r r en tgo a l ( goalname ) 33 ( s e t f c u r r e n tg o a l goalname ) ) 35 ( defun s t a r ta g e n t ( ) ( i f c u r r e n tg o a l 37 ( progn ( s e t f a c t i v ea g e n t t ) 39 ( proofautomath ) )

( print "No c u r r e n tg o a l d e f i n e d f o r t h i s agent ! P l e a s e g i v e a g o a l . " ) ) 41 )

( defun getcurrenttype ( ) 43 currenttype

)

45 ( defun setcurrenttype ( ctype ) ( s e t f currenttype ctype ) 47 )

( defun setcurrenttypeiflowlevel ( ctype )

49 ( l e t ( ( c u r r e n tl e v e l ( getlevelofatype currenttype ) ) ( newlevel ( getlevelofatype ctype ) ) ) 51 ( i f (< newlevel c u r r e n tl e v e l )

( setcurrenttype ctype )

53 )

) 55 )

( defun settrueactiveagent ( ) 57 ( s e t f a c t i v ea g e n t t )

)

59 ( defun setstopactiveagent ( ) ( s e t f a c t i v ea g e n t n i l ) 61 )

( defun getlstofcompound ( ) 63 lstofcompound

)

65 ( defun getlstofdeepestcontext ( ) l stofd ee p es tc on te x t

Annexe B. Code Lisp de DTF-A

67 )

( defun setlstofdeepestcontext ( l s t ) 69 ( s e t f l stofd eepes tconte xt l s t ) )

71 ( defun se tl s to fcu r r en tv a li dc on t ex t ( l s t ) ( s e t f l s to fc u r r e n tv a l i dc o n t e x t l s t ) ) 73

( defun getlstofcurrentvalidcontext ( ) 75 l s to fc u r r e n tv a l i dc o n t e x t

)

77 ; ; ; Les contextes sont enregistrés avec le niveau auquel i l s sont l i é s .

( defun getproofsofthecurrentsituation ( contextroot l e v e l ) 79 ; ; ; Le contexte racine (contextroot) est déjà prouvé .

; ; ; Le contexte racine en cours est un sigmatype.

81 ( l e t ( ( l o c a ll e v e l (+ l e v e l 1 ) )

( l s to fr o o tc h i l d s ( getlstofsubsumingelementofatype contextroot ) ) 83 ; ; ; Parcourir la l i s t e en recherchant une preuve pour chaque DRT.

( l s to fp r o o fr o o tc h i l d s (mapcar # '( lambda ( x ) ( getlstproofoftdr x ) ) l s to fr o o tc h i l d s ) ) 85 ( lstofproofrootchildswithtype (mapcar # '( lambda ( x y ) ( i f ( not ( equal y n i l ) )

( progn

87 ( addsigmatypesextension x y )

( l i s t x y ) ) ) )

89 l s to fr o o tc h i l d s l s to fp r o o fr o o tc h i l d s ) ) ( lsttemp ' ( ) )

91 )

( progn

93 ( s e t f lstofproofrootchildswithtype ( removenil lstofproofrootchildswithtype ) ) ( s e t f lsttemp lstofproofrootchildswithtype )

95

; ;( print "lstofrootchilds")

97 ; ;( print lstofrootchilds) ; ;( print "Current level ")

99 ; ;( print locallevel )

; ;( print lstofproofrootchildswithtype )

101 ( i f ( not ( equal lsttemp n i l ) ) ( progn

103 ; ; ( print "lsttemp") ; ; ( print lsttemp)

105 (pushnew (pushnew l e v e l lsttemp ) l s to fc u r r e n tv a l i dc o n t e x t ) ( loop f o r z i n lstofproofrootchildswithtype do

107 ; ; ;Ne prendre en compte que les types dont une preuve a pu être démontrée .

( getproofsofthecurrentsituation ( f i r s t z ) l o c a ll e v e l )

109 ) ) ) 111 ) ) 113 ) ; ; ; Example :

115 ; ; (addsigmatypesextension 'agentlocation (getlstproofoftdr 'agentlocation ) ) ; ;Ok ; ; (getproofsofthecurrentsituation 'agentlocation 1 ) ; ;Ok

117 ; ; (getlstofcurrentvalidcontext ) ; ;Ok

; ; ; ; Déterminer la l i s t e des DTR de niveau le plus bas . Ok

119

( defun setlstofthedeepestdtr ( )

121 ( l e t ( ( l e v e l ( g e tv a l i dl e v e l l s to fc u r r e n tv a l i dc o n t e x t ) ) ( l s t ' ( ) ) ) 123 ( progn ( loop f o r x i n l s to fc u r r e n tv a l i dc o n t e x t do 125 ( progn ( s e t q c u r r e n tl e v e l ( f i r s t x ) ) 127 ( i f ( equal l e v e l c u r r e n tl e v e l ) ( s e t q l s t (append ( cdr x ) l s t ) ) 129 ) ) ) ) 131 ( s e t q ls tofde epestco ntext l s t ) ) 133 ) ; ; ; Example

135 ; ;( setlstofcurrentvalidcontext ; ; ;Ok

; ; '((1 agentlocation (1 2)) (2 (~agenthasgold (1 2)) ) (3 (breezesquare (1 2))) (3 (goldsquare (5 4))) (3 (smellysquare (6 7 ) ) ) ) ) ; ; ;Ok

137 ; ;( setlstofthedeepestdtr ) ; ; ;Ok ; ; ( getlstofdeepestcontext ) ; ; ;Ok

139 ; ; ; Rechercher les contraintes . . . Ok

( defun getproofsofcurrentcompounddtr ( ) 141 ( l e t ( ( l s to fc o n s t r a i n t sc o n t e x t

( g e tl s to fd r to fc o n s t r a i n t s ( e l i m i n a t e dc o n s t r a i n t sd o u b l e 143 ( getlstofallmeronym ( getlsttype lstofdeepestcont ext ) ) ) ) )

( l s to fv a l i dc o n s t r a i n t s ( e l i m i n a t e dn ov a l i dc o n s t r a i n t s

145 l s to fc o n s t r a i n t sc o n t e x t l stofdeepestcont ext ) )

147 )

l s to fv a l i dc o n s t r a i n t s 149 ) )

151 ; ;( setf lstofcvc '(( breezesquare (1 2)) (goldsquare (5 4)) (smellysquare (6 7)))) ; ;( getlsttype lstofcvc) ; ;Ok

153 ; ;(getlstofallmeronym (getlsttype lstofcvc)) ; ;Ok ; ;( setf lstofconstraintscontext

155 ; ; (getlstofdrtofconstraints

; ; (eliminatedconstraintsdouble (getlstofallmeronym (getlsttype lstofcvc ) ) ) ) ) ; ; ;Ok

157 ; ;( eliminatednovalidconstraints lstofconstraintscontext lstofcvc ) ; ; ;Ok

; ; (setlstofdeepestcontext '(( breezesquare (1 2)) (goldsquare (5 4)) (smellysquare (6 7 ) ) ) ) ; ; ;Ok

159 ; ; (getproofsofcurrentcompounddtr ) ; ; ;Ok

( defun e x e c u t ea c t i o n s ( ) 161 ( l e t ( ( l s t ) ) ( progn 163 ( i f ( equal n i l lstofcompound ) ( s e t f l s t lstofde e pe stcontext ) 165 ( s e t f l s t lstofcompound ) ) 167 ; ; ( print ls t ) (mapcar # '( lambda ( x ) 169 ( e x e c u t ea c t i o n ( f i r s t x ) ) ) l s t ) ) ) 171 ) 173 ( defun e r a s ep r o o f ( )

( delallsonofdtr currenttype ) 175 ( s e t f lstofdee pe s tc ontext n i l ) ( s e t f l s to fc u r r e n tv a l i dc o n t e x t n i l ) 177 ) 179 ( defun e x e c u t ed e d u c t i o n s ( ) ( l e t ( ( l s t ( gethash ' d e d u c t i o n sl s t agentkb ) ) ) 181 (mapcar # '( lambda ( x ) ( getlstproofoftdr x ) ) l s t ) 183 ) ) 185 ( defun i sg o a lv a l i d ( ) ( l e t ( ( g o a l n i l ) ) 187 (mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t ( f i r s t ( cdr x ) ) ) c u r r e n tg o a l ) 189 ( s e t f g o a l c u r r e n tg o a l ) ) ) l s to fc u r r e n tv a l i dc o n t e x t ) 191 g o a l ) 193 )

( defun proofautomath ( ) 195 ( l e t ( ( i 0 ) )

( loop w h i l e ( equal a c t i v ea g e n t t ) 197 do( progn

( s e t f i (+ i 1 ) )

199 ( getproofsofthecurrentsituation currenttype 1) ( i f ( i sg o a lv a l i d )

201 ( progn

( print "Ok g o a l ! " ) 203 ( setstopactiveagent ) )

( progn

205 ( setlstofthedeepestdtr ) ( print " ls to fdeepe stco nte xt " ) 207 ( print ls tofdeep estc ontext )

( s e t f lstofcompound ( getproofsofcurrentcompounddtr ) ) 209 ; ; ( print "lstofcompound")

; ; ( print lstofcompound)

211 ( e x e c u t ea c t i o n s ) ( e x e c u t ed e d u c t i o n s ) 213 ( e r a s ep r o o f )

; ; ( i f (= 10 i ) (setstopactiveagent))

215 ( print i )

( print " D i r e c t i o n : " )

217 ( print ( d i r e c t i o n currentagent ) ) ( print " P o s i t i o n X" )

219 ( print ( c o o r d i n a t e X ( p o s i t i o n G currentagent ) ) ) ( print " P o s i t i o n Y" )

221 ( print ( c o o r d i n a t e Y ( p o s i t i o n G currentagent ) ) ) ) ) )

223 ) ) ) 225

; ; ; ( setcurrentgoal 'agenthasgold)

227 ; ; ;

229 ; ; ; ( proofautomath)

; ;( addsigmatypesextension ' agentlocation (getlstproofoftdr 'agentlocation ) ) ; ;Ok

231 ; ; ( addsigmatypesextension ' root ( l i s t currentagent)) ; ; (getlsttype (getlstofdeepestcontext ) ) ; ;Ok

233 ; ;( eliminatedconstraintsdouble (getlstofallmeronym (getlsttype (getlstofdeepestcontext ) ) ) ) ; ;Ok

; ; ( getlstofdrtofconstraints (eliminatedconstraintsdouble (getlstofallmeronym (getlsttype (getlstofdeepestcontext ) ) ) ) ) ; ;Ok

235 )

Annexe B. Code Lisp de DTF-A

; ; ; ; Created on 20080928 12:28:31

2 ; ; ; Cette fonction permet de calculer le produit cartésien des l i s t e s éléments de la l i s t e argument. ; ; ; 4 ( defun pi1 ( arg ) ( f i r s t arg ) 6 ) 8 ( defun pi2 ( arg ) ( second arg ) 10 )

12 ( defun delallsonofdtr ( drtname )

( l e t ( ( lstofson ( getlstofsubsumingelementofatype drtname ) ) ) 14 (mapcar # '( lambda ( x ) ( i f ( i se x t e n s i o n x )

( progn

16 ( i n i t i a l i s ee x t e n s i o no fs i g m a x ) ( delallsonofdtr x ) ) )

18 ) lstofson )

) 20 )

; ; ; ; ( delallsonofdtr 'agentlocation)

22 ; ; ; ( 1 ) ) ( defun c a r t e s i a np r o d u c t ( l i s to fs e t s ) 24 ( l e t ( ( l o s l i s to fs e t s ) ) ( i f ( null l o s ) n i l 26 ( l e t ( ( f i r s ts e t ( c a r l o s ) ) ( o t h e rs e t s ( cdr l o s ) ) ) 28 ( i f ( null o t h e rs e t s ) (mapcar #' l i s t f i r s ts e t ) 30 ( i f ( null f i r s ts e t ) n i l ( l e t ( ( f i r s te l e m e n t ( c a r f i r s ts e t ) ) 32 ( otherelements ( cdr f i r s ts e t ) ) ) (append

34 (mapcar # '( lambda ( y ) ( cons f i r s te l e m e n t y ) ) ( c a r t e s i a np r o d u c t o t h e rs e t s ) )

36 ( c a r t e s i a np r o d u c t ( cons otherelements o t h e rs e t s ) ) ) ) ) ) ) ) ) ) 38 ; ; ; ; ( cartesianproduct '( (1 2) (a b c) (d) ) )

;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

40 ; ; ; ( 2 ) )

( defmacro getformatname ( s t r i n gf arg )

42 ` ( format n i l ( concatenate ' string , s t r i n gf "~A" ) , arg ) )

44

; ; ; Cette fonction permet d' obtenir la l i s t e des arguments d'une sigma type .

46 ; ; ; ( 3 ) )

( defun getlsttypesofsigmatype ( sigmatypename ) 48 ( l e t ( ( arg ) )

( progn

50 ( s e t q arg ( intern ( s t r i n gu p c a s e ( getformatname "GETTYPELST" sigmatypename ) ) ) ) ( eval ( l i s t arg ) )

52 ) ) ) 54

; ; ; ; ( getlsttypes 'agentlocation)

56

;;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

58 ; ; ; ( 4 ) )

( defun getextensionlstofatomictypes ( typename ) 60 ( gethash typename agentkb )

)

62 ;;;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−

; ; ; ( 5 ) )

64 ; ; ; Les types arguments d'un sigma type sont des types atomiques ou des sigmas .

( defun getextensionoftypeslst ( lsttypename ) 66 (mapcar # '( lambda ( y )

( i f ( typep y ' sigmatypes )

68 ( getextensionofsigmatypes y )

( getextensionlstofatomictypes y ) ) ) lsttypename ) 70 )

72 ; ; ; ( 6 ) )

( defmacro getproofoftdr ( sigmatypename l s to fe x t e n s i o n ); ;Ok

74 ` ( mapcar # '( lambda ( x ) ( apply , sigmatypename x ) ) , l s to fe x t e n s i o n ) )

76 ; ; ; ; ( getproofoftdr plus1 '(1 2 3)) ; ; ; ( 7 )

78 ( defun removenil ( l s t ) ( delete n i l l s t ) 80 )

82 ; ; ; ( 8 )

( defun getlstproofoftdr ( sigmatypename ); ;Ok

84 ( l e t ( ( l s to fa r g s ( getlsttypesofsigmatype sigmatypename ) ) ( l s to fe x t e n s i o n ( getextensionoftypeslst l s to fa r g s ) ) 86 ( l s to fc a r t e s i o np r o d u c to fe x t e n s i o n )

88 ( sigmaname sigmatypename ) )

90 ; ; ; Vérifier qu' i l existe bien au moins une valeur pour chaque type .

( i f ( not (member n i l l s to fe x t e n s i o n ) ) 92 ( progn

( s e t f l s to fc a r t e s i o np r o d u c to fe x t e n s i o n ( c a r t e s i a np r o d u c t l s to fe x t e n s i o n ) ) 94 ( s e t f l s to fp r o o f ( getproofoftdr sigmaname l s to fc a r t e s i o np r o d u c to fe x t e n s i o n ) )

( s e t f l s to fp r o o f ( removenil l s to fp r o o f ) ) 96 ) ) 98 l s to fp r o o f ) ) 100 102 104 ; ; ; Example : 106 ; ;(1) agentlocation

; ; ( getlsttypesofsigmatype ' agentlocation ) ; ;Ok

108 ; ;( setf lstofextension (getextensionoftypeslst (getlsttypesofsigmatype 'agentlocation ) ) ) ; ;Ok ; ;( setf lstofcartesionproductofextension (cartesianproduct lstofextension ) ) ; ;Ok

110 ; ;( getproofoftdr 'agentlocation lstofcartesionproductofextension ) ; ;Ok ; ;( agentlocation ( f i r s t lstofcartesionproductofextension))

112 ; ;( agentdirection ( f i r s t ( f i r s t lstofcartesionproductofextension) )) ; ; ; ; ; ; ( getlstproofoftdr ' agentlocation ) ; ;Ok

114 ; ;(2) ~agenthasgold

; ; ; ; ; ; ( addsigmatypesextension 'agentlocation (getlstproofoftdr 'agentlocation ) ) ; ;Ok

116 ; ;( getlsttypesofsigmatype '~agenthasgold ) ; ;Ok ; ;( getextensionofsigmatypes 'agentlocation ) ; ;Ok

118 ; ;( getextensionoftypeslst '( agentlocation ) ) ; ;Ok

; ;( setf lstofextension (getextensionoftypeslst (getlsttypesofsigmatype '~agenthasgold ) ) ) ; ; ;Ok

120 ; ;( setf lstofcartesionproductofextension (cartesianproduct lstofextension ) ) ; ;Ok ; ;( getproofoftdr '~agenthasgold lstofcartesionproductofextension)

122

; ;(hasgoldp ( f i r s t ( f i r s t ( f i r s t lstofextension ) ) ) ) ; ;Ok

124 ; ;(~hasgoldp ( f i r s t ( f i r s t ( f i r s t lstofextension ) ) ) ) ; ;Ok ; ; ; ; ; ; ( getlstproofoftdr '~agenthasgold ) ; ;Ok

126 ; ;(3) smellysquare

128 ; ; ; ( addsigmatypesextension '~agenthasgold (getlstproofoftdr '~agenthasgold ) ) ; ; ; ; ; ; ; ; ( getlsttypesofsigmatype 'smellysquare ) ; ;Ok

130 ; ; ; ; ; ; ( getextensionoftypeslst '(smellysquare ) ) ; ;Ok

; ; ; ; ; ; ( setagentposition currentagent (makeinstance ' position : smelly t ))

132 ; ; ; ( getlstproofoftdr 'smellysquare)

134 ; ;(4) nextpositionisavalidsquare

; ;( getlstproofoftdr 'nextpositionisavalidsquare)

136

138 ( defun g e tv a l i dl e v e l ( l s t ) ( l e t ( ( l e v e l 0)

140 ( c u r r e n tl e v e l ) )

; ; ; Parcourir les éléments pour décider de la profondeur .

142 ( progn ( loop f o r x i n l s t do 144 ( progn ( s e t q c u r r e n tl e v e l ( f i r s t x ) ) 146 ( i f (< l e v e l c u r r e n tl e v e l ) ( s e t q l e v e l c u r r e n tl e v e l ) 148 ) ) ) l e v e l ) 150 ) )

152 ( defun getlevelofatype ( sigmatypename ) ( l e t ( ( arg ) )

154 ( progn

( s e t q arg ( intern ( s t r i n gu p c a s e ( getformatname "GETLEVEL" sigmatypename ) ) ) ) 156 ( eval ( l i s t arg ) )

) ) 158 )

160 ( defun getlstofsubsumingelementofatype ( sigmatypename ) ( l e t ( ( arg ) )

162 ( progn

( s e t q arg ( intern ( s t r i n gu p c a s e ( getformatname "GETSUBSUMING" sigmatypename ) ) ) ) 164 ( eval ( l i s t arg ) )

) ) 166 )

168 ( defun getlstofmeronymelementofatype ( sigmatypename ) ( l e t ( ( arg ) )

Annexe B. Code Lisp de DTF-A

( s e t q arg ( intern ( s t r i n gu p c a s e ( getformatname "GETMERONYM" sigmatypename ) ) ) ) 172 ( eval ( l i s t arg ) )

) ) 174 )

176 ( defun getlstofdrtofconstraint ( constraintname ) ( l e t ( ( arg ) )

178 ( progn

( s e t q arg ( intern ( s t r i n gu p c a s e ( getformatname "GETTYPELST" constraintname ) ) ) ) 180 ( eval ( l i s t arg ) )

) ) 182 )

184 ; ; ( defun executeaction (typename) ; ; ( let (( arg ))

186 ; ; (progn

; ; ( setq arg ( intern (stringupcase (getformatname "EXECUTEACTION" typename))))

188 ; ; ( eval ( l i s t arg )) ; ; ))

190 ; ; )

( defun e x e c u t ea c t i o n ( typename )

192 ( l e t ( ( lsttypenameextension ( getextensionofsigmatypes typename ) ) ( sigmaactiontypename ( gethash typename agentactionskb ) ) ) 194 (mapcar # '( lambda ( x )

( f u n c a l l sigmaactiontypename x ) ) lsttypenameextension ) 196 ) )

; ; ; ( executeaction 'nextpositionisavalidsquare)

198 ; ; ; ( getlstofdrtofconstraint dr01)

( defun g e tl s to fd r to fc o n s t r a i n t s ( l s t )

200 (mapcar # '( lambda ( y ) ( l i s t y ( getlstofdrtofconstraint y ) ) ) l s t ) )

202

204 ( defun memberdtrtype ( l s t v a l u e ) ( l e t ( ( bValue n i l ) )

206 (mapcar # '( lambda ( y ) ( i f (member v a l u e y ) ( s e t f bValue t ) ) ) l s t ) 208 bValue ) 210 ) 212 ( defun e l i m i n a t e dc o n s t r a i n t sd o u b l e ( l s t ) ( l e t ( ( l s to fc o n s t r a i n t s ) )

214 (mapcar # '( lambda ( x ) (mapcar # '( lambda ( y ) (pushnew y l s to fc o n s t r a i n t s ) ) x ) ) l s t ) l s to fc o n s t r a i n t s )

216 )

218 ( defun g e tl s to fd r te x p r e s s i o no fc o n s t r a i n t s ( l s to fc o n s t r a i n t s ) ( l e t ( ( l s td e t a i l so fc o n s t r a i n t s ) )

220 (mapcar # '( lambda ( x ) (pushnew ( l i s t x ( getlstofdrtofconstraint x ) ) l s td e t a i l so fc o n s t r a i n t s ) ) l s to fc o n s t r a i n t s ) l s td e t a i l so fc o n s t r a i n t s

222 ) )

224 ( defun e l i m i n a t e dn ov a l i dc o n s t r a i n t s ( l s to fc o n s t r a i n t l s to fv a l i dd r t ) ( l e t ( ( l s to fv a l i dc o n s t r a i n t s )

226 )

(mapcar # '( lambda ( x ) ( i f ( eval ( cons 'and (mapcar # '( lambda ( y ) ( memberdtrtype l s to fv a l i dd r t y ) ) ( second x ) ) ) ) 228 (pushnew x l s to fv a l i dc o n s t r a i n t s ) ) ) l s to fc o n s t r a i n t )

l s to fv a l i dc o n s t r a i n t s 230 )

) 232

; ; ; ( setf te1 '(( type1 re1) (type2 re2) (type3 re3 )))

234 ; ; ; ( setf te2 '(( dr1 (type1 type2)) (dr2 (type4 type2)) (dr3 (type5 type6 )))) ; ; ; ( eliminatednovalidconstraints te2 te1)

236 ( defun g e tl s to fc o n s t r a i n t sw i t ht h eb i g g e s tc a r d i n a l ( l s t ) 238 ( l e t ( ( l s to fv a l i dc o n s t r a i n t s ) ( c a r d i n a l 0) 240 ) ( progn

242 (mapcar # '( lambda ( x ) ( l e t ( ( l s tl e n g t h ( l i s tl e n g t h ( second x ) ) ) ) ( i f (< c a r d i n a l l s tl e n g t h )

244 ( s e t f c a r d i n a l l s tl e n g t h ) ) ) ) l s t ) (mapcar # '( lambda ( x ) ( l e t ( ( l s tl e n g t h ( l i s tl e n g t h ( second x ) ) ) ) 246 ( i f (= c a r d i n a l l s tl e n g t h )

(pushnew x l s to fv a l i dc o n s t r a i n t s )

248 ) ) ) l s t )

l s to fv a l i dc o n s t r a i n t s

250 ) ) )

252 ; ; ; ( setf te3 '(( dr1 (type1 type2)) (dr2 (type4 type2 type5)) (dr3 (type5 type6 )))) ; ; ; ( getlstofconstraintswiththebiggestcardinal te3)

254

( defun getlsttype ( l s t )

256 (mapcar # '( lambda ( x ) ( f i r s t x ) ) l s t ) )

( defun getlstofallmeronym ( l s t )

260 (mapcar # '( lambda ( x ) ( getlstofmeronymelementofatype x ) ) l s t ) )

1 ; ; ; ; Created on 20081030 17:25:35

( defun t e s tc o n d i t i o n s ( )

3 ( getlstproofoftdr ' ded01 ) ( executeactionded01 ) 5 )

7 ( defun testcompoundsrelations ( ) ( getproofsofcurrentcompounddtr ) 9 )

11 ( defun t e s td t r ( ) ( progn

13 ( g e tp r o o f so fc u r r e n ts i t u a t i o n ) ( setlstofthedeepestdtr ) ) 15 )

C

Code Lisp du Wumpus

1 ; ; ; ; Created on 20081030 22:32:01

( s e t f stopvalue n i l ) 3

( s e t q agentkb ( makehashtable ) )

5 ( s e t q agentactionskb ( makehashtable ) ) ( s e t q agentcompoundtypeskb ( makehashtable ) ) 7

( s e t f ( gethash ' pr1 agentcompoundtypeskb ) ' nextpositionisavalidsquare ) 9 ( s e t f ( gethash ' pr2 agentcompoundtypeskb ) ' goldsquare )

( s e t f ( gethash ' pr3 agentcompoundtypeskb ) ' nextpositionisavalidsquare ) 11 ( s e t f ( gethash ' pr4 agentcompoundtypeskb ) ' goldsquare )

( s e t f ( gethash ' pr5 agentcompoundtypeskb ) ' nextpositionisavalidsquare ) 13 ( s e t f ( gethash ' pr6 agentcompoundtypeskb ) ' goldsquare )

15 ( deftype compoundtypes ( ) ' ( s a t i s f i e s compoundtypesp ) ) ( defun compoundtypesp ( typename )

17 ( gethash typename agentcompoundtypeskb ) )

19 21

( s e t f currentagent ( makeinstance ' agentwumpus : p o s i t i o n G p o s i t i o n 1 1

23 : d i r e c t i o n north ) )

25 ( s e t f ( gethash ' agentwumpus agentkb ) ( l i s t currentagent ) ) 27 ( s e t f ( gethash ' d i r e c t i o n agentkb ) ( l i s t ( ) ) )

29 ( s e t f ( gethash ' position agentkb ) ( l i s t p o s i t i o n 1 1 ) ) 31 ( s e t f ( gethash ' hasgold agentkb ) ( l i s t ( ) ) ) 33 ( s e t f ( gethash ' positionwumpus agentkb ) ( l i s t ( ) ) ) 35 ( s e t f ( gethash ' p o s i t i o ng o l d agentkb ) ( l i s t ( ) ) ) 37 ( s e t f ( gethash ' adjacentnorth agentkb ) ( l i s t ( ) ) )

( s e t f ( gethash ' a d j a c e n te a s t agentkb ) ( l i s t ( ) ) ) 39 ( s e t f ( gethash ' adjacentsouth agentkb ) ( l i s t ( ) ) )

( s e t f ( gethash ' adjacentwest agentkb ) ( l i s t ( ) ) ) 41 ( s e t f ( gethash ' d e d u c t i o n sl s t agentkb ) ( l i s t ' ded01 ) )

43 ( s e t f ( gethash '~ agenthasgold agentactionskb ) '~ agenthasgoldchangedirection ) ( s e t f ( gethash ' smellysquare agentactionskb ) ' smellysquarechangedirection ) 45 ( s e t f ( gethash ' breezesquare agentactionskb ) ' breezysquarechangedirection )

( s e t f ( gethash ' nextpositionisavalidsquare agentactionskb ) ' nextpositionisavalidsquaregoforward ) 47 ( s e t f ( gethash ' identifydeadwumpussquare agentactionskb ) ' identifydeadwumpussquaregoforward )

( s e t f ( gethash ' identifywumpussquare agentactionskb ) ' identifywumpussquarekillthewumpus ) 49 ( s e t f ( gethash ' goldsquare agentactionskb ) ' goldsquareagentkeepgold )

( s e t f ( gethash ' agenthasgold agentactionskb ) ' agenthasgoldgohome ) 51

( s e t f ( gethash ' pr1 agentactionskb ) ' nextpositionisavalidsquaregoforward ) 53 ( s e t f ( gethash ' pr2 agentactionskb ) ' goldsquareagentkeepgold )

( s e t f ( gethash ' pr3 agentactionskb ) ' nextpositionisavalidsquaregoforward ) 55 ( s e t f ( gethash ' pr4 agentactionskb ) ' goldsquareagentkeepgold )

( s e t f ( gethash ' pr5 agentactionskb ) ' nextpositionisavalidsquaregoforward ) 57 ( s e t f ( gethash ' pr6 agentactionskb ) ' goldsquareagentkeepgold )

59

( s e t f s t a r tp o s i t i o n p o s i t i o n 1 1 ) 61

; ;( addsigmatypesextension 'agentlocation (getlstproofoftdr 'agentlocation ) ) ; ;Ok ; ; ; ; Created on 20080928 16:18:15

Annexe C. Code Lisp du Wumpus ( d e f c l a s s position ( ) 4 ( ( c o o r d i n a t e X : i n i t a r g : c o o r d i n a t e X : a c c e s s o r c o o r d i n a t e X ) ( c o o r d i n a t e Y : i n i t a r g : c o o r d i n a t e Y : a c c e s s o r c o o r d i n a t e Y ) 6 ( v a l i d : i n i t f o r m n i l : i n i t a r g : v a l i d : a c c e s s o r v a l i d ) ( s m e l l y : i n i t f o r m n i l : i n i t a r g : s m e l l y : a c c e s s o r s m e l l y ) 8 ( b r e e z y : i n i t f o r m n i l : i n i t a r g : b r e e z y : a c c e s s o r b r e e z y ) ( p i t : i n i t f o r m n i l : i n i t a r g : p i t : a c c e s s o r p i t ) 10 ( v i s i t e d : i n i t f o r m n i l : i n i t a r g : v i s i t e d : a c c e s s o r v i s i t e d ) ( g o l d : i n i t f o r m n i l : i n i t a r g : g o l d : a c c e s s o r g o l d ) 12 ) ) 14 ( d e f c l a s s w a l l ( position ) 16 ( ( v a l i d : i n i t f o r m n i l : i n i t a r g : v a l i d : a c c e s s o r v a l i d ) ) ) 18 ( d e f c l a s s d i r e c t i o n ( ) 20 ( ) ) 22 ( d e f c l a s s e a s t ( d i r e c t i o n ) 24 ( ) ) 26 ( d e f c l a s s west ( d i r e c t i o n ) ( ) 28 ) ( d e f c l a s s north ( d i r e c t i o n ) 30 ( ) ) 32 ( d e f c l a s s south ( d i r e c t i o n ) ( ) 34 ) 36 ( d e f c l a s s wumpus ( )

( ( positionW : i n i t f o r m n i l : i n i t a r g : positionW : a c c e s s o r positionW ) 38 ( a l i v e : i n i t f o r m t : i n i t a r g : a l i v e : a c c e s s o r a l i v e ) ) ) 40 ( d e f c l a s s agent ( ) 42 ( ) ) 44 ( d e f c l a s s g o l d ( ) 46 ( ) ) 48

( d e f c l a s s agentwumpus ( agent )

50 ( ( p o s i t i o n G : i n i t f o r m 0 : i n i t a r g : p o s i t i o n G : a c c e s s o r p o s i t i o n G ) ( d i r e c t i o n : i n i t f o r m n i l : i n i t a r g : d i r e c t i o n : a c c e s s o r d i r e c t i o n ) 52 )

)

54 ; ; ; ; ( setq agent1 (makeinstance 'agentwumpus : positionG (makeinstance ' position )

; ; ; ; : direction (makeinstance ' direction )))

1 ; ; ; ; Created on 20081101 07:46:12

3 ( s e t q s i t u a t i o n ( makehashtable ) ) 5 ( s e t q w a l l ( makeinstance ' w a l l ) ) 7 ( s e t q wumpus1 ( makeinstance 'wumpus ) ) 9 ( s e t q g o l d 1 ( makeinstance ' g o l d ) ) 11 ( s e t q e a s t ( makeinstance ' e a s t ) )

( s e t q west ( makeinstance ' west ) ) 13 ( s e t q north ( makeinstance ' north ) )

( s e t q south ( makeinstance ' south ) ) 15

( s e t q p o s i t i o n 1 1 ( makeinstance ' position : c o o r d i n a t e X 1 : c o o r d i n a t e Y 1 : v a l i d t ) ) 17 ( s e t q p o s i t i o n 1 2 ( makeinstance ' position : c o o r d i n a t e X 1 : c o o r d i n a t e Y 2 : s m e l l y t ) )

( s e t q p o s i t i o n 1 3 ( makeinstance ' position : c o o r d i n a t e X 1 : c o o r d i n a t e Y 3 : p i t t ) ) 19 ( s e t q p o s i t i o n 1 4 ( makeinstance ' position : c o o r d i n a t e X 1 : c o o r d i n a t e Y 4 : s m e l l y t ) )

( s e t q p o s i t i o n 1 5 ( makeinstance ' position : c o o r d i n a t e X 1 : c o o r d i n a t e Y 5 ) ) 21

( s e t q p o s i t i o n 2 1 ( makeinstance ' position : c o o r d i n a t e X 2 : c o o r d i n a t e Y 1 : b r e e z y t ) ) 23 ( s e t q p o s i t i o n 2 2 ( makeinstance ' position : c o o r d i n a t e X 2 : c o o r d i n a t e Y 2 : v a l i d t ) )

( s e t q p o s i t i o n 2 3 ( makeinstance ' position : c o o r d i n a t e X 2 : c o o r d i n a t e Y 3 : s m e l l y t : b r e e z y t : g o l d g o l d 1 ) ) 25 ( s e t q p o s i t i o n 2 4 ( makeinstance ' position : c o o r d i n a t e X 2 : c o o r d i n a t e Y 4 : b r e e z y t ) )

( s e t q p o s i t i o n 2 5 ( makeinstance ' position : c o o r d i n a t e X 2 : c o o r d i n a t e Y 5 : v a l i d t ) ) 27

( s e t q p o s i t i o n 3 1 ( makeinstance ' position : c o o r d i n a t e X 3 : c o o r d i n a t e Y 1 : p i t t ) ) 29 ( s e t q p o s i t i o n 3 2 ( makeinstance ' position : c o o r d i n a t e X 3 : c o o r d i n a t e Y 2 : b r e e z y t ) )

( s e t q p o s i t i o n 3 3 ( makeinstance ' position : c o o r d i n a t e X 3 : c o o r d i n a t e Y 3 : p i t t ) ) 31 ( s e t q p o s i t i o n 3 4 ( makeinstance ' position : c o o r d i n a t e X 3 : c o o r d i n a t e Y 4 : b r e e z y t ) )

( s e t q p o s i t i o n 3 5 ( makeinstance ' position : c o o r d i n a t e X 3 : c o o r d i n a t e Y 5 : v a l i d t ) ) 33

( s e t q p o s i t i o n 4 1 ( makeinstance ' position : c o o r d i n a t e X 4 : c o o r d i n a t e Y 1 : b r e e z y t ) ) 35 ( s e t q p o s i t i o n 4 2 ( makeinstance ' position : c o o r d i n a t e X 4 : c o o r d i n a t e Y 2 : v a l i d t ) )

( s e t q p o s i t i o n 4 3 ( makeinstance ' position : c o o r d i n a t e X 4 : c o o r d i n a t e Y 3 : b r e e z y t ) ) 37 ( s e t q p o s i t i o n 4 4 ( makeinstance ' position : c o o r d i n a t e X 4 : c o o r d i n a t e Y 4 : p i t t ) )

( s e t q p o s i t i o n 4 5 ( makeinstance ' position : c o o r d i n a t e X 4 : c o o r d i n a t e Y 5 : v a l i d t ) ) 39

( s e t q p o s i t i o n 5 1 ( makeinstance ' position : c o o r d i n a t e X 5 : c o o r d i n a t e Y 1 : v a l i d t ) ) 41 ( s e t q p o s i t i o n 5 2 ( makeinstance ' position : c o o r d i n a t e X 5 : c o o r d i n a t e Y 2 : v a l i d t ) ) ( s e t q p o s i t i o n 5 3 ( makeinstance ' position : c o o r d i n a t e X 5 : c o o r d i n a t e Y 3 : v a l i d t ) ) 43 ( s e t q p o s i t i o n 5 4 ( makeinstance ' position : c o o r d i n a t e X 5 : c o o r d i n a t e Y 4 : v a l i d t ) ) ( s e t q p o s i t i o n 5 5 ( makeinstance ' position : c o o r d i n a t e X 5 : c o o r d i n a t e Y 5 : v a l i d t ) ) 45 47 ( s e t f ( gethash ' a d j a c e n te a s t s i t u a t i o n ) ( l i s t ( l i s t p o s i t i o n 5 1 w a l l ) 49 ( l i s t p o s i t i o n 5 2 w a l l ) ( l i s t p o s i t i o n 5 3 w a l l ) 51 ( l i s t p o s i t i o n 5 4 w a l l ) ( l i s t p o s i t i o n 5 5 w a l l ) 53 ( l i s t p o s i t i o n 1 1 p o s i t i o n 2 1 ) ( l i s t p o s i t i o n 2 1 p o s i t i o n 3 1 ) 55 ( l i s t p o s i t i o n 3 1 p o s i t i o n 4 1 ) ( l i s t p o s i t i o n 4 1 p o s i t i o n 5 1 ) 57 ( l i s t p o s i t i o n 1 2 p o s i t i o n 2 2 ) ( l i s t p o s i t i o n 2 2 p o s i t i o n 3 2 ) 59 ( l i s t p o s i t i o n 3 2 p o s i t i o n 4 2 ) ( l i s t p o s i t i o n 4 2 p o s i t i o n 5 2 ) 61 ( l i s t p o s i t i o n 1 3 p o s i t i o n 2 3 ) ( l i s t p o s i t i o n 2 3 p o s i t i o n 3 3 ) 63 ( l i s t p o s i t i o n 3 3 p o s i t i o n 4 3 ) ( l i s t p o s i t i o n 4 3 p o s i t i o n 5 3 ) 65 ( l i s t p o s i t i o n 1 4 p o s i t i o n 2 4 ) ( l i s t p o s i t i o n 2 4 p o s i t i o n 3 4 ) 67 ( l i s t p o s i t i o n 3 4 p o s i t i o n 4 4 ) ( l i s t p o s i t i o n 4 4 p o s i t i o n 5 4 ) 69 ( l i s t p o s i t i o n 1 5 p o s i t i o n 2 5 ) ( l i s t p o s i t i o n 2 5 p o s i t i o n 3 5 ) 71 ( l i s t p o s i t i o n 3 5 p o s i t i o n 4 5 ) ( l i s t p o s i t i o n 4 5 p o s i t i o n 5 5 ) 73 ) ) 75

( s e t f ( gethash ' adjacentnorth s i t u a t i o n ) ( l i s t

77 ( l i s t p o s i t i o n 1 5 w a l l ) ( l i s t p o s i t i o n 2 5 w a l l ) 79 ( l i s t p o s i t i o n 3 5 w a l l ) ( l i s t p o s i t i o n 4 5 w a l l ) 81 ( l i s t p o s i t i o n 5 5 w a l l ) ( l i s t p o s i t i o n 1 1 p o s i t i o n 1 2 ) 83 ( l i s t p o s i t i o n 2 1 p o s i t i o n 2 2 ) ( l i s t p o s i t i o n 3 1 p o s i t i o n 3 2 ) 85 ( l i s t p o s i t i o n 4 1 p o s i t i o n 4 2 ) ( l i s t p o s i t i o n 5 1 p o s i t i o n 5 2 ) 87 ( l i s t p o s i t i o n 1 2 p o s i t i o n 1 3 ) ( l i s t p o s i t i o n 2 2 p o s i t i o n 2 3 ) 89 ( l i s t p o s i t i o n 3 2 p o s i t i o n 3 3 ) ( l i s t p o s i t i o n 4 2 p o s i t i o n 4 3 ) 91 ( l i s t p o s i t i o n 5 2 p o s i t i o n 5 3 ) ( l i s t p o s i t i o n 1 3 p o s i t i o n 1 4 ) 93 ( l i s t p o s i t i o n 2 3 p o s i t i o n 2 4 ) ( l i s t p o s i t i o n 3 3 p o s i t i o n 3 4 ) 95 ( l i s t p o s i t i o n 4 3 p o s i t i o n 4 4 ) ( l i s t p o s i t i o n 5 3 p o s i t i o n 5 4 ) 97 ( l i s t p o s i t i o n 1 4 p o s i t i o n 1 5 ) ( l i s t p o s i t i o n 2 4 p o s i t i o n 2 5 ) 99 ( l i s t p o s i t i o n 3 4 p o s i t i o n 3 5 ) ( l i s t p o s i t i o n 4 4 p o s i t i o n 4 5 ) 101 ( l i s t p o s i t i o n 5 4 p o s i t i o n 5 5 ) ) ) 103

( s e t f ( gethash ' adjacentsouth s i t u a t i o n ) ( l i s t

105 ( l i s t p o s i t i o n 1 1 w a l l ) ( l i s t p o s i t i o n 2 1 w a l l ) 107 ( l i s t p o s i t i o n 3 1 w a l l ) ( l i s t p o s i t i o n 4 1 w a l l ) 109 ( l i s t p o s i t i o n 5 1 w a l l ) ( l i s t p o s i t i o n 1 2 p o s i t i o n 1 1 ) 111 ( l i s t p o s i t i o n 2 2 p o s i t i o n 2 1 ) ( l i s t p o s i t i o n 3 2 p o s i t i o n 3 1 ) 113 ( l i s t p o s i t i o n 4 2 p o s i t i o n 4 1 ) ( l i s t p o s i t i o n 5 2 p o s i t i o n 5 1 ) 115 ( l i s t p o s i t i o n 1 3 p o s i t i o n 1 2 ) ( l i s t p o s i t i o n 2 3 p o s i t i o n 2 2 ) 117 ( l i s t p o s i t i o n 3 3 p o s i t i o n 3 2 ) ( l i s t p o s i t i o n 4 3 p o s i t i o n 4 2 ) 119 ( l i s t p o s i t i o n 5 3 p o s i t i o n 5 2 ) ( l i s t p o s i t i o n 1 4 p o s i t i o n 1 3 ) 121 ( l i s t p o s i t i o n 2 4 p o s i t i o n 2 3 ) ( l i s t p o s i t i o n 3 4 p o s i t i o n 3 3 ) 123 ( l i s t p o s i t i o n 4 4 p o s i t i o n 4 3 ) ( l i s t p o s i t i o n 5 4 p o s i t i o n 5 3 ) 125 ( l i s t p o s i t i o n 1 5 p o s i t i o n 1 4 ) ( l i s t p o s i t i o n 2 5 p o s i t i o n 2 4 ) 127 ( l i s t p o s i t i o n 3 5 p o s i t i o n 3 4 ) ( l i s t p o s i t i o n 4 5 p o s i t i o n 4 4 ) 129 ( l i s t p o s i t i o n 5 5 p o s i t i o n 5 4 )

Annexe C. Code Lisp du Wumpus

) ) 131

( s e t f ( gethash ' adjacentwest s i t u a t i o n ) ( l i s t

133 ( l i s t p o s i t i o n 1 1 w a l l ) ( l i s t p o s i t i o n 1 2 w a l l ) 135 ( l i s t p o s i t i o n 1 3 w a l l ) ( l i s t p o s i t i o n 1 4 w a l l ) 137 ( l i s t p o s i t i o n 1 5 w a l l ) ( l i s t p o s i t i o n 2 1 p o s i t i o n 1 1 ) 139 ( l i s t p o s i t i o n 3 1 p o s i t i o n 2 1 ) ( l i s t p o s i t i o n 4 1 p o s i t i o n 3 1 ) 141 ( l i s t p o s i t i o n 5 1 p o s i t i o n 4 1 ) ( l i s t p o s i t i o n 2 2 p o s i t i o n 1 2 ) 143 ( l i s t p o s i t i o n 3 2 p o s i t i o n 2 2 ) ( l i s t p o s i t i o n 4 2 p o s i t i o n 3 2 ) 145 ( l i s t p o s i t i o n 5 2 p o s i t i o n 4 2 ) ( l i s t p o s i t i o n 2 3 p o s i t i o n 1 3 ) 147 ( l i s t p o s i t i o n 3 3 p o s i t i o n 2 3 ) ( l i s t p o s i t i o n 4 3 p o s i t i o n 3 3 ) 149 ( l i s t p o s i t i o n 5 3 p o s i t i o n 4 3 ) ( l i s t p o s i t i o n 2 4 p o s i t i o n 1 4 ) 151 ( l i s t p o s i t i o n 3 4 p o s i t i o n 2 4 ) ( l i s t p o s i t i o n 4 4 p o s i t i o n 3 4 ) 153 ( l i s t p o s i t i o n 5 4 p o s i t i o n 4 4 ) ( l i s t p o s i t i o n 2 5 p o s i t i o n 1 5 ) 155 ( l i s t p o s i t i o n 3 5 p o s i t i o n 2 5 ) ( l i s t p o s i t i o n 4 5 p o s i t i o n 3 5 ) 157 ( l i s t p o s i t i o n 5 5 p o s i t i o n 4 5 ) ) ) 159 161 ( s e t f ( gethash ' d i r e c t i o n s i t u a t i o n ) ( l i s t e a s t west 163 north south ) ) 165 ( s e t f ( gethash ' position s i t u a t i o n ) ( l i s t p o s i t i o n 1 1 p o s i t i o n 1 2 p o s i t i o n 1 3 p o s i t i o n 1 4 p o s i t i o n 1 5 167 p o s i t i o n 2 1 p o s i t i o n 2 2 p o s i t i o n 2 3 p o s i t i o n 2 4 p o s i t i o n 2 5 p o s i t i o n 3 1 p o s i t i o n 3 2 p o s i t i o n 3 3 p o s i t i o n 3 4 p o s i t i o n 3 5 169 p o s i t i o n 4 1 p o s i t i o n 4 2 p o s i t i o n 4 3 p o s i t i o n 4 4 p o s i t i o n 4 5 p o s i t i o n 5 1 p o s i t i o n 5 2 p o s i t i o n 5 3 p o s i t i o n 5 4 p o s i t i o n 5 5 ) ) 171 173

( s e t f ( gethash ' hasgold s i t u a t i o n ) ( l i s t ' ( ) ) ) 175

( s e t f ( gethash ' positionwumpus s i t u a t i o n ) ( l i s t p o s i t i o n 1 3 wumpus1 ) ) 177

( s e t f ( gethash ' p o s i t i o ng o l d s i t u a t i o n ) ( l i s t p o s i t i o n 2 3 g o l d 1 ) ) 1 ; ; ; ; Created on 20081030 17:27:33

( defun a g e n tp o s i t i o n ( agentwump ) 3 ( p o s i t i o n G agentwump )

)

5 ; ; agentdirection : (Pi a :agentwumpus. direction (a)))

( defun a g e n td i r e c t i o n ( agentwump ) 7 ( d i r e c t i o n agentwump )

) 9

( defun s e ta g e n tp o s i t i o n ( agentwump positionEC ) 11 ( s e t f ( p o s i t i o n G agentwump ) positionEC )

) 13

( defun g e ti n v e r s ed i r e c t i o n ( d i r e c t i o n ) 15 ( cond

( ( equal d i r e c t i o n north ) south ) 17 ( ( equal d i r e c t i o n e a s t ) west )

( ( equal d i r e c t i o n south ) north ) 19 ( ( equal d i r e c t i o n west ) e a s t ) )

)

21 ; ; ; ( getinversedirection 'north)

23 ( defun g e tn e x tl e f td i r e c t i o n ( d i r e c t i o n ) ( cond

25 ( ( equal d i r e c t i o n north ) west ) ( ( equal d i r e c t i o n west ) south ) 27 ( ( equal d i r e c t i o n south ) e a s t )

( ( equal d i r e c t i o n e a s t ) north ) ) 29 )

; ; ; ( getnextleftdirection 'north)

31 ( defun nextpositionkb ( position d i r e c t i o n ) ( cond

33 ( ( equal d i r e c t i o n north ) ( nextnorthpositionkb position ) ) ( ( equal d i r e c t i o n e a s t ) ( nexteastpositionkb position ) ) 35 ( ( equal d i r e c t i o n south ) ( nextsouthpositionkb position ) )

( ( equal d i r e c t i o n west ) ( nextwestpositionkb position ) ) ) 37 )

39

41 ( cond

( ( equal d i r e c t i o n north ) ( nextnorthposition position ) ) 43 ( ( equal d i r e c t i o n e a s t ) ( n e x te a s tp o s i t i o n position ) )

( ( equal d i r e c t i o n south ) ( nextsouthposition position ) ) 45 ( ( equal d i r e c t i o n west ) ( nextwestposition position ) ) )

)

47 ; ; ; Example

; ;( nextposition ' position12 ' east )

49 ( defun n e x te a s tp o s i t i o n ( position )

( l e t ( ( l s t ( gethash ' a d j a c e n te a s t s i t u a t i o n ) ) 51 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 53 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 55 n e x tp o s i t i o n

) 57 )

59 ( defun nexteastpositionkb ( position )

( l e t ( ( l s t ( gethash ' a d j a c e n te a s t agentkb ) ) 61 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 63 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 65 n e x tp o s i t i o n

) 67 )

69 ( defun nextsouthposition ( position )

( l e t ( ( l s t ( gethash ' adjacentsouth s i t u a t i o n ) ) 71 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 73 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 75 n e x tp o s i t i o n

) 77 )

79 ( defun nextsouthpositionkb ( position )

( l e t ( ( l s t ( gethash ' adjacentsouth agentkb ) ) 81 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 83 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 85 n e x tp o s i t i o n

) 87 )

89 ( defun nextwestposition ( position )

( l e t ( ( l s t ( gethash ' adjacentwest s i t u a t i o n ) ) 91 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 93 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 95 n e x tp o s i t i o n

) 97 )

99 ( defun nextwestpositionkb ( position )

( l e t ( ( l s t ( gethash ' adjacentwest agentkb ) ) 101 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 103 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 105 n e x tp o s i t i o n

) 107 )

109 ( defun nextnorthposition ( position )

( l e t ( ( l s t ( gethash ' adjacentnorth s i t u a t i o n ) ) 111 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 113 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 115 n e x tp o s i t i o n

) 117 )

119 ( defun nextnorthpositionkb ( position )

( l e t ( ( l s t ( gethash ' adjacentnorth agentkb ) ) 121 ( n e x tp o s i t i o n n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 123 ( s e t f n e x tp o s i t i o n ( second x ) )

) ) l s t ) 125 n e x tp o s i t i o n

) 127 )

129 ( defun getthewumpus ( position )

( l e t ( ( l s t ( gethash ' a d j a c e n te a s t s i t u a t i o n ) ) 131 ( wumpuspos n i l ) )

Annexe C. Code Lisp du Wumpus

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 133 ( s e t f wumpuspos ( second x ) )

) ) l s t ) 135 wumpuspos

) 137 )

139 ( defun isdirectionknown ( d i r e c t i o n position ) ( l e t ( ( l s td i r e c t i o n )

141 ( p o s i t i o n S ) )

143 ( progn ( cond

145 ( ( equal d i r e c t i o n north ) ( s e t f l s td i r e c t i o n ( gethash ' adjacentnorth agentkb ) ) ) ( ( equal d i r e c t i o n e a s t ) ( s e t f l s td i r e c t i o n ( gethash ' a d j a c e n te a s t agentkb ) ) ) 147 ( ( equal d i r e c t i o n south ) ( s e t f l s td i r e c t i o n ( gethash ' adjacentsouth agentkb ) ) ) ( ( equal d i r e c t i o n west ) ( s e t f l s td i r e c t i o n ( gethash ' adjacentwest agentkb ) ) ) ) 149 ; ; ( print lstdirection )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) 151 ( s e t f p o s i t i o n S ( second x ) ) ) ) l s td i r e c t i o n ) 153 p o s i t i o n S ) ) 155 ) 157 159 ( defun i ss t a r tp o s i t i o n ( c u r r e n tp o s i t i o n ) ( equal s t a r tp o s i t i o n c u r r e n tp o s i t i o n ) 161 ) 163 ( defun s e tp o s i t i o nv a l i d ( position ) ( s e t f ( v a l i d position ) t ) 165 ) 167 ( defun c h o o s ed i r e c t i o n ( l s td i r e c t i o n position ) ( l e t ( ( c h o i c ed i r e c t i o n n i l ) 169 ( n e x tp o s i t i o n n i l ) ) ( progn

171 (mapcar # '( lambda ( x ) ( progn

( s e t f n e x tp o s i t i o n ( nextpositionkb position x ) ) 173 ( i f ( equal n e x tp o s i t i o n n i l ) ( i f ( equal c h o i c ed i r e c t i o n n i l ) 175 ( s e t f c h o i c ed i r e c t i o n x ) ) ) ) 177 ) l s td i r e c t i o n ) c h o i c ed i r e c t i o n ) 179 ) ) 181 ( defun i n f e r e n c ef o r w a r dp o s i t i o n ( position d i r e c t i o n ) 183 ( l e t ( ( nextpos ( n e x tp o s i t i o n position d i r e c t i o n ) )

( i n v e r s ed i r e c t i o n ( g e ti n v e r s ed i r e c t i o n d i r e c t i o n ) )

185 )

( progn

187 ( print " i n f e r e n c ef o r w a r dp o s i t i o n " ) ( s e t f ( v i s i t e d nextpos ) t )

189 (pushnew nextpos ( gethash ' position agentkb ) ) ( cond

191 ( ( equal d i r e c t i o n north ) (pushnew ( l i s t position nextpos ) ( gethash ' adjacentnorth agentkb ) ) ) ( ( equal d i r e c t i o n e a s t ) (pushnew ( l i s t position nextpos ) ( gethash ' a d j a c e n te a s t agentkb ) ) ) 193 ( ( equal d i r e c t i o n south ) (pushnew ( l i s t position nextpos ) ( gethash ' adjacentsouth agentkb ) ) ) ( ( equal d i r e c t i o n west ) (pushnew ( l i s t position nextpos ) ( gethash ' adjacentwest agentkb ) ) ) ) 195 ( cond

( ( equal i n v e r s ed i r e c t i o n north ) (pushnew ( l i s t nextpos position ) ( gethash ' adjacentnorth agentkb ) ) ) 197 ( ( equal i n v e r s ed i r e c t i o n e a s t ) (pushnew ( l i s t nextpos position ) ( gethash ' a d j a c e n te a s t agentkb ) ) ) ( ( equal i n v e r s ed i r e c t i o n south ) (pushnew ( l i s t nextpos position ) ( gethash ' adjacentsouth agentkb ) ) ) 199 ( ( equal i n v e r s ed i r e c t i o n west ) (pushnew ( l i s t nextpos position ) ( gethash ' adjacentwest agentkb ) ) ) )

nextpos

201 )

) )

1 ; ; ; ; Created on 20081026 17:45:59

; ; agentposition : (Pi a :agentwumpus. position (a)))

3 ( defun a g e n tp o s i t i o n ( agentwump ) ( p o s i t i o n G agentwump )

5 )

; ; agentdirection : (Pi a :agentwumpus. direction (a)))

7 ( defun a g e n td i r e c t i o n ( agentwump ) ( d i r e c t i o n agentwump )

9 )

; ; hasgoldp : (Pi a :agentwumpus. prop(a)))

11 ( defun hasgoldp ( agentwump )

( l e t ( ( l s t ( gethash ' hasgold kbagent ) ) 13 ( bValue n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) agentwump )

15 ( s e t f bValue t )

) ) l s t ) 17 bValue

19 )

; ;~hasgoldp : (Pi a :agentwumpus. prop(a)))

21 ( defun ~hasgoldp ( agentwump )

( equal ( hasgoldp agentwump ) n i l ) 23 )

25 ( defun s e ta g e n tp o s i t i o n ( agentwump positionEC ) ( s e t f ( p o s i t i o n G agentwump ) positionEC ) 27 )

29 ( defun i ss m e l l yp o s i t i o n p ( positionEC ) ( s m e l l y positionEC )

31 )

1 ; ; ; ; Created on 20081030 17:27:18 ; ; hasgoldp : (Pi a :agentwumpus. prop(a)))

3 ( defun hasgoldp ( agentwump )

( l e t ( ( l s t ( gethash ' hasgold agentkb ) ) 5 ( bValue n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) agentwump )

7 ( s e t f bValue t )

) ) l s t ) 9 bValue

) 11 )

; ;~hasgoldp : (Pi a :agentwumpus. prop(a)))

13 ( defun ~hasgoldp ( agentwump )

( equal ( hasgoldp agentwump ) n i l ) 15 )

17 ( defun issmellypositionp ( positionEC ) ( s m e l l y positionEC ) 19 ) 21 ( defun i sv a l i dp o s i t i o np ( positionEC ) ( i f ( equal positionEC n i l ) 23 n i l ( v a l i d positionEC ) ) 25 ) 27 ( defun i sd i f f e r e n tp o s i t i o np ( p o s i t i o n 1 p o s i t i o n 2 ) ( not ( equal p o s i t i o n 1 p o s i t i o n 2 ) ) 29 )

31 ( defun isadjacentpositionp ( p o s i t i o n 1 p o s i t i o n 2 ) ( or ( equal ( adjacentnorth p o s i t i o n 1 ) p o s i t i o n 2 ) 33 ( equal ( a d j a c e n te a s t p o s i t i o n 1 ) p o s i t i o n 2 ) ( equal ( adjacentsouth p o s i t i o n 1 ) p o s i t i o n 2 ) 35 ( equal ( adjacentwest p o s i t i o n 1 ) p o s i t i o n 2 ) )

) 37

( defun iswumpusdeadp (wumpusP) 39 ( not ( a l i v e wumpusP ) )

) 41

( defun iswumpuslocatedinp ( position )

43 ( l e t ( ( l s t ( gethash ' positionwumpus agentkb ) ) ( bValue n i l ) )

45 (mapcar # '( lambda ( x ) ( i f ( equal ( f i r s t x ) position ) ( s e t f bValue t ) 47 ) ) l s t ) bValue 49 ) ) 51 ( defun i sp e r c e i v eg l i t t e rp ( position ) 53 ( g o l d position ) ) 55

( defun isbreezypositionp ( positionEC ) 57 ( b r e e z y positionEC )

) 59

( defun ismemberp ( e l 1 l s t ) 61 ( l e t ( ( bValue n i l ) )

(mapcar # '( lambda ( x ) ( i f ( equal x e l 1 )

63 ( s e t f bValue t ) ) ) l s t ) 65 bValue ) ) 67 ( defun isadjacentp ( p o s i t i o n 1 p o s i t i o n 2 ) 69 ( l e t ( ( l s t 1 ( gethash ' a d j a c e n te a s t agentkb ) )

( l s t 2 ( gethash ' adjacentwest agentkb ) ) 71 ( l s t 3 ( gethash ' adjacentnorth agentkb ) )

( l s t 4 ( gethash ' adjacentsouth agentkb ) ) ) 73 ( or ( ismemberp ( l i s t p o s i t i o n 1 p o s i t i o n 2 ) l s t 1 )

( ismemberp ( l i s t p o s i t i o n 1 p o s i t i o n 2 ) l s t 2 ) 75 ( ismemberp ( l i s t p o s i t i o n 1 p o s i t i o n 2 ) l s t 3 ) ( ismemberp ( l i s t p o s i t i o n 1 p o s i t i o n 2 ) l s t 4 ) )

Annexe C. Code Lisp du Wumpus

77 ) )

; ; ; Example :

79 ; ; ( isadjacentp position11 position12 )

81 ( defun i sd i f f e r e n tp ( p o s i t i o n 1 p o s i t i o n 2 ) ( not ( equal p o s i t i o n 1 p o s i t i o n 2 ) )

83 )

85 ( defun i sp o s s i b l ed i r e c t i o n ( position d i r e c t i o n )

( l e t ( ( nextpos ( nextpositionkb position d i r e c t i o n ) ) )

87 (and ( or ( i sv a l i dp o s i t i o np nextpos ) ( i sv a l i dp o s i t i o np position ) ) ( not ( equal nextpos w a l l ) ) ) )

89 )

1 ; ; ; ; Created on 20081026 19:12:34

3 ( addsigmatypesextension ' a g e n tl o c a t i o n ' ( ) ) ( addsigmatypesextension ' agenthasgold ' ( ) ) 5 ( addsigmatypesextension '~ agenthasgold ' ( ) )

( addsigmatypesextension ' breezesquare ' ( ) ) 7 ( addsigmatypesextension ' goldsquare ' ( ) )

( addsigmatypesextension ' identifydeadwumpussquare ' ( ) ) 9 ( addsigmatypesextension ' identifywumpussquare ' ( ) )

( addsigmatypesextension ' nextpositionisavalidsquare ' ( ) ) 11 ( addsigmatypesextension ' p o s i t i o ni nv a l i ds q u a r e ' ( ) )

( addsigmatypesextension ' smellysquare ' ( ) ) 13

( addsigmatypesextension ' r o o t ( l i s t currentagent ) )

; ; ; ; Created on 20081123 13:05:28

2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

4

( l e t ( ( name '~ agenthasgoldchangedirection ) 6 ( l s tt y p e s '(~ agenthasgold ) )

( subsumed ' ( ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x ) ( b ( c h a n g ed i r e c t i o n ( pi1 ( pi1 a ) ) 16 ( pi1 ( pi2 ( pi1 a ) ) ) ( pi2 ( pi2 ( pi1 a ) ) ) ) ) ) 18 ( progn ( i f ( not ( equal b n i l ) ) 20 ( l i s t a b ) n i l 22 ) ) ) 24 ) ) )

26 ( defun getlevel~agenthasgoldchangedirection ( ) l e v e l

28 )

( defun i n i t i a l i s e~agenthasgoldchangedirection ( ) 30 ( s e t f c u r r e n tv a l u e ' ( ) )

)

32 ( defun getsubsumed~agenthasgoldchangedirection ( ) subsumed

34 )

( defun getsubsuming~agenthasgoldchangedirection ( ) 36 subsuming

)

38 ( defun getmeronym~agenthasgoldchangedirection ( ) meronym

40 )

( defun getholonym~agenthasgoldchangedirection ( ) 42 holonym

)

44 ( defun proof~agenthasgoldchangedirection ( )

; ; ; Call a generic function .

46 )

( defun gettypelst~agenthasgoldchangedirection ( ) 48 l s tt y p e s

)

50 ( defun ~agenthasgoldchangedirection (~ agenthasgold ) ( f u n c a l l ( eval c o n s t r u c t o r ) ~agenthasgold ) ) )

1 ; ; ; ; Created on 20081123 13:05:28 ; ; ; ; Created on 20081009 14:41:25

3 ; ; ; ; ~agenthasgold

5 ( l e t ( ( name ' smellysquarechangedirection ) ( l s tt y p e s ' ( smellysquare ) )

( subsuming ' ( ) ) 9 ( meronym ' ( ) ) ( holonym ' ( ) ) 11 ( c u r r e n tv a l u e ' ( ) ) ( l e v e l 2) 13 ( c o n s t r u c t o r ' ( lambda ( x ) ( l e t( ( a x ) 15 ( b ( c h a n g ed i r e c t i o n ( pi1 ( pi1 ( pi1 a ) ) ) ( pi1 ( pi2 ( pi1 ( pi1 a ) ) ) ) 17 ( pi2 ( pi2 ( pi1 ( pi1 a ) ) ) ) ) ) ) 19 ( progn ( i f ( not ( equal b n i l ) ) 21 ( l i s t a b ) n i l 23 ) ) ) 25 ) ) )

27 ( defun getlevelsmellysquarechangedirection ( ) l e v e l

29 )

( defun i n i t i a l i s es m e l l ys q u a r ec h a n g ed i r e c t i o n ( ) 31 ( s e t f c u r r e n tv a l u e ' ( ) )

)

33 ( defun getsubsumedsmellysquarechangedirection ( ) subsumed

35 )

( defun getsubsumingsmellysquarechangedirection ( ) 37 subsuming

)

39 ( defun getmeronymsmellysquarechangedirection ( ) meronym

41 )

( defun getholonymsmellysquarechangedirection ( ) 43 holonym

)

45 ( defun proofsmellysquarechangedirection ( )

; ; ; Call a generic function .

47 )

( defun gettypelstsmellysquarechangedirection ( ) 49 l s tt y p e s

)

51 ( defun smellysquarechangedirection ( smellysquare ) ( f u n c a l l ( eval c o n s t r u c t o r ) smellysquare ) ) )

; ; ; ; Created on 20081123 13:05:28

2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

4

( l e t ( ( name ' breezysquarechangedirection ) 6 ( l s tt y p e s ' ( breezysquare ) ) ( subsumed ' ( ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x ) ( b ( c h a n g ed i r e c t i o n ( pi1 ( pi1 ( pi1 a ) ) ) 16 ( pi1 ( pi2 ( pi1 ( pi1 a ) ) ) ) ( pi2 ( pi2 ( pi1 ( pi1 a ) ) ) ) 18 ) ) ) ( progn 20 ( i f ( not ( equal b n i l ) ) ( l i s t a b ) 22 n i l ) ) 24 ) ) 26 ) )

( defun getlevelbreezysquarechangedirection ( ) 28 l e v e l

)

30 ( defun i n i t i a l i s eb r e e z ys q u a r ec h a n g ed i r e c t i o n ( ) ( s e t f c u r r e n tv a l u e ' ( ) )

32 )

( defun getsubsumedbreezysquarechangedirection ( ) 34 subsumed

)

36 ( defun getsubsumingbreezysquarechangedirection ( ) subsuming

38 )

( defun getmeronymbreezysquarechangedirection ( ) 40 meronym

)

42 ( defun getholonymbreezysquarechangedirection ( ) holonym

44 )

Annexe C. Code Lisp du Wumpus

46 ; ; ; Call a generic function .

)

48 ( defun gettypelstbreezysquarechangedirection ( ) l s tt y p e s

50 )

( defun breezysquarechangedirection ( breezysquare ) 52 ( f u n c a l l ( eval c o n s t r u c t o r ) breezysquare ) ) )

; ; ; ; Created on 20081123 13:05:28

2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

4

( l e t ( ( name ' nextpositionisavalidsquaregoforward ) 6 ( l s tt y p e s ' ( nextpositionisavalidsquare ) )

( subsumed ' ( ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x ) ( b ( goforward ( pi1 ( pi1 ( pi1 a ) ) ) 16 ( pi1 ( pi2 ( pi1 ( pi1 a ) ) ) ) ( pi2 ( pi2 ( pi1 ( pi1 a ) ) ) ) 18 ) ) ) ( progn 20 ( i f ( not ( equal b n i l ) ) ( l i s t a b ) 22 n i l ) ) 24 ) ) 26 ) )

( defun getlevelnextpositionisavalidsquaregoforward ( ) 28 l e v e l

)

30 ( defun i n i t i a l i s en e x tp o s i t i o ni sav a l i ds q u a r eg of o r w a r d ( ) ( s e t f c u r r e n tv a l u e ' ( ) )

32 )

( defun getsubsumednextpositionisavalidsquaregoforward ( ) 34 subsumed

)

36 ( defun getsubsumingnextpositionisavalidsquaregoforward ( ) subsuming

38 )

( defun getmeronymnextpositionisavalidsquaregoforward ( ) 40 meronym

)

42 ( defun getholonymnextpositionisavalidsquaregoforward ( ) holonym

44 )

( defun proofnextpositionisavalidsquaregoforward ( ) 46 ; ; ; Call a generic function .

)

48 ( defun gettypelstnextpositionisavalidsquaregoforward ( ) l s tt y p e s

50 )

( defun nextpositionisavalidsquaregoforward ( nextpositionisavalidsquare ) 52 ( f u n c a l l ( eval c o n s t r u c t o r ) nextpositionisavalidsquare ) ) )

; ; ; ; Created on 20081123 13:05:28

2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

4

( l e t ( ( name ' identifydeadwumpussquaregoforward ) 6 ( l s tt y p e s ' ( identifydeadwumpussquare ) )

( subsumed ' ( ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x ) ( b ( goforward ( pi1 ( pi1 ( pi1 ( pi1 a ) ) ) ) 16 ( pi1 ( pi2 ( pi1 ( pi1 ( pi1 a ) ) ) ) ) ( pi2 ( pi2 ( pi1 ( pi1 ( pi1 a ) ) ) ) ) 18 ) ) ) ( progn 20 ( i f ( not ( equal b n i l ) ) ( l i s t a b ) 22 n i l ) ) 24 ) ) 26 ) )

( defun getlevelidentifydeadwumpussquaregoforward ( ) 28 l e v e l

)

30 ( defun initialiseidentifydeadwumpussquaregoforward ( ) ( s e t f c u r r e n tv a l u e ' ( ) )

32 )

( defun getsubsumedidentifydeadwumpussquaregoforward ( ) 34 subsumed

)

36 ( defun getsubsumingidentifydeadwumpussquaregoforward ( ) subsuming

38 )

( defun getmeronymidentifydeadwumpussquaregoforward ( ) 40 meronym

)

42 ( defun getholonymidentifydeadwumpussquaregoforward ( ) holonym

44 )

( defun proofidentifydeadwumpussquaregoforward ( ) 46 ; ; ; Call a generic function .

)

48 ( defun gettypelstidentifydeadwumpussquaregoforward ( ) l s tt y p e s

50 )

( defun identifydeadwumpussquaregoforward ( identifydeadwumpussquare ) 52 ( f u n c a l l ( eval c o n s t r u c t o r ) identifydeadwumpussquare ) ) )

; ; ; ; Created on 20081123 13:05:28

2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

4

( l e t ( ( name ' identifywumpussquarekillwumpus ) 6 ( l s tt y p e s ' ( identifywumpussquare ) )

( subsumed ' ( ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x )

( b ( killedthewumpus ( pi1 ( pi1 ( pi1 ( pi1 a ) ) ) ) 16 ( pi1 ( pi2 ( pi1 ( pi1 ( pi1 a ) ) ) ) ) ) ) ) 18 ( progn ( i f ( not ( equal b n i l ) ) 20 ( l i s t a b ) n i l 22 ) ) ) 24 ) ) )

26 ( defun getlevelidentifywumpussquarekillwumpus ( ) l e v e l

28 )

( defun initialiseidentifywumpussquarekillwumpus ( ) 30 ( s e t f c u r r e n tv a l u e ' ( ) )

)

32 ( defun getsubsumedidentifywumpussquarekillwumpus ( ) subsumed

34 )

( defun getsubsumingidentifywumpussquarekillwumpus ( ) 36 subsuming

)

38 ( defun getmeronymidentifywumpussquarekillwumpus ( ) meronym

40 )

( defun getholonymidentifywumpussquarekillwumpus ( ) 42 holonym

)

44 ( defun proofidentifywumpussquarekillwumpus ( )

; ; ; Call a generic function .

46 )

( defun gettypelstidentifywumpussquarekillwumpus ( ) 48 l s tt y p e s

)

50 ( defun identifywumpussquarekillwumpus ( identifywumpussquare ) ( f u n c a l l ( eval c o n s t r u c t o r ) identifywumpussquare ) ) )

1 ; ; ; ; Created on 20081123 13:05:28 ; ; ; ; Created on 20081009 14:41:25

3 ; ; ; ; ~agenthasgold

5 ( l e t ( ( name ' goldsquareagentkeepgold ) ( l s tt y p e s ' ( goldsquare ) ) 7 ( subsumed ' ( ) ) ( subsuming ' ( ) ) 9 ( meronym ' ( ) ) ( holonym ' ( ) ) 11 ( c u r r e n tv a l u e ' ( ) ) ( l e v e l 2)

Annexe C. Code Lisp du Wumpus 13 ( c o n s t r u c t o r ' ( lambda ( x ) ( l e t( ( a x ) 15 ( b ( keepgold ( pi1 ( pi1 ( pi1 a ) ) ) ( pi2 a ) ) ) ) 17 ( progn ( i f ( not ( equal b n i l ) ) 19 ( l i s t a b ) n i l 21 ) ) ) 23 ) ) )

25 ( defun getlevelgoldsquareagentkeepgold ( ) l e v e l

27 )

( defun i n i t i a l i s eg o l ds q u a r ea g e n tk e e pg o l d ( ) 29 ( s e t f c u r r e n tv a l u e ' ( ) )

)

31 ( defun getsubsumedgoldsquareagentkeepgold ( ) subsumed

33 )

( defun getsubsuminggoldsquareagentkeepgold ( ) 35 subsuming

)

37 ( defun getmeronymgoldsquareagentkeepgold ( ) meronym

39 )

( defun getholonymgoldsquareagentkeepgold ( ) 41 holonym

)

43 ( defun proofgoldsquareagentkeepgold ( )

; ; ; Call a generic function .

45 )

( defun gettypelstgoldsquareagentkeepgold ( ) 47 l s tt y p e s

)

49 ( defun goldsquareagentkeepgold ( goldsquare ) ( f u n c a l l ( eval c o n s t r u c t o r ) goldsquare ) ) )

; ; ; ; Created on 20081123 13:05:28

2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

4

( l e t ( ( name ' agenthasgoldgohome ) 6 ( l s tt y p e s ' ( agenthasgold ) )

( subsumed ' ( ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x ) ( b ( gohome 16 ) ) ) ( progn 18 ( i f ( not ( equal b n i l ) ) ( l i s t a b ) 20 n i l ) ) 22 ) ) 24 ) )

( defun getlevelagenthasgoldgohome ( ) 26 l e v e l

)

28 ( defun initialiseagenthasgoldgohome ( ) ( s e t f c u r r e n tv a l u e ' ( ) )

30 )

( defun getsubsumedagenthasgoldgohome ( ) 32 subsumed

)

34 ( defun getsubsumingagenthasgoldgohome ( ) subsuming

36 )

( defun getmeronymagenthasgoldgohome ( ) 38 meronym

)

40 ( defun getholonymagenthasgoldgohome ( ) holonym

42 )

( defun proofagenthasgoldgohome ( ) 44 ; ; ; Call a generic function .

)

46 ( defun gettypelstagenthasgoldgohome ( ) l s tt y p e s

48 )

( defun agenthasgoldgohome ( agenthasgold ) 50 ( f u n c a l l ( eval c o n s t r u c t o r ) agenthasgold ) ) )

; ; ; ; Created on 20081009 22:00:10

2 ( l e t ( ( l s tt y p e s ' ( agentdirectiontovalidsquare ) ) ( c o n s t r u c t o r ' ( lambda ( x )

4 ( l e t( ( a x )

( b ( f u n c a l l ( agentmoveto ) ( f i r s t a ) ( f i r s t ( second a ) ) ) ) ) 6 ( i f ( not ( equal b n i l ) )

( l i s t a b )

8 n i l

) ) ) ) )

10 ( defun proofmoveagenttovalidsquare ( )

; ; ; Call a generic function .

12 )

( defun gettypelstmoveagenttovalidsquare ( ) 14 l s tt y p e s

)

16 ( defun moveagenttovalidsquare ( agentwump ) ( f u n c a l l ( eval c o n s t r u c t o r ) agentwump ) ) )

; ; ; ; Created on 20081009 21:23:32

2 ; ; ; ; moveagenttovalidsquare : (Pi a : agenttovalidsquare .agentmoveto( pi (a) pi (pi '( pi '( pi ' ( pi ' ( a))))))) ; ; ; ; agentkeepgold : (Pi a : goldsquare ( ) . agentkeepgold( pi (a) pi (pi ' ( a) )))

4 ; ; ; ; agentchangedirection : (Pi a : smellysquare . changedirection( pi (a) pi (pi ' ( pi '( a) ))) ; ; ; ; killthewumpus : (Pi a : identifywumpusposition .killwumpus( pi ( pi (a)) pi (pi ' ( pi '( a))))

6 ( l e t ( ( returntype ' r o o t ) ) ( defun gohome ( )

8 ( progn

( print " gohome" ) 10 ( setstopactiveagent )

( setcurrenttypeiflowlevel returntype )

12 )

) ) 14

16 ( l e t ( ( returntype ' a g e n tl o c a t i o n ) ) ( defun keepgold ( agent g o l d ) 18 ( progn

( print " keepgold " )

20 ( push ( l i s t agent g o l d ) ( gethash ' hasgold agentkb ) ) ( setcurrenttypeiflowlevel returntype )

22 )

) 24 )

26 ; ;( let ((returntype ' root ))

; ; (defun changedirection (agent position direction )

28 ; ; ( let (

; ; ( lstpossible '())

30 ; ; ( lstlast ( l i s t (getinversedirection direction ))) ; ; ( lstimpossible '())

32 ; ; (currentdirection direction ) ; ; ( lastposition )

34 ; ; )

; ; (progn

36 ; ; ( print "changedirection") ; ; ( print currentdirection)

38 ; ; (loop for i from 1 to 3 do

; ; (progn

40 ; ; ( setf currentdirection (getnextleftdirection currentdirection )) ; ; ( setf lastposition (isdirectionknown currentdirection position ))

42 ; ; ( i f (not (equal lastposition nil ))

; ; ( i f (and ( valid lastposition ) (not (equal wall lastposition )))

44 ; ; ( setf lstpossible (append lstpossible ( l i s t currentdirection ))) ; ; ( setf lstimpossible (append lstpossible ( l i s t currentdirection )))

46 ; ; )

; ; ( setf lstpossible (append lstpossible ( l i s t currentdirection )))

48 ; ; ))

; ; )

50 ; ; ( i f (not (equal lstpossible nil ))

; ; (progn

52 ; ; ( setf ( direction agent) (choosedirection lstpossible position )) ; ; ( i f (equal ( direction agent) nil )

54 ; ; ( setf ( direction agent) ( f i r s t lstpossible )))) ; ; ( setf ( direction agent) ( f i r s t lstlast )))

56 ; ; (setcurrenttypeiflowlevel returntype)

; ; )

58 ; ; ) ; ; )

60 ; ; )

Annexe C. Code Lisp du Wumpus 62 ( l e t ( ( l s tp o s s i b l e n i l ) 64 ( c u r r e n td i r e c t i o n d i r e c t i o n ) ( positionEC ) 66 ) ( progn 68 ( print " c h a n g ed i r e c t i o nf r e e " ) ( loop f o r i from 1 to 3 do 70 ( progn ( s e t f c u r r e n td i r e c t i o n ( g e tn e x tl e f td i r e c t i o n c u r r e n td i r e c t i o n ) ) 72 ( s e t f positionEC ( isdirectionknown c u r r e n td i r e c t i o n position ) )

( i f ( equal positionEC n i l ) 74 (pushnew c u r r e n td i r e c t i o n l s tp o s s i b l e ) ) ) ) 76 ( i f ( not ( equal l s tp o s s i b l e n i l ) ) ( s e t f ( d i r e c t i o n agent ) ( f i r s t l s tp o s s i b l e ) ) 78 ( s e t f ( d i r e c t i o n agent ) ( g e tn e x tl e f td i r e c t i o n d i r e c t i o n ) ) ) ) ) ) 80

( defun c h a n g ed i r e c t i o n ( agent position d i r e c t i o n ) 82 ( l e t ( ( l s tp o s s i b l e n i l ) 84 ( c u r r e n td i r e c t i o n d i r e c t i o n ) ( positionEC ) 86 ) ( progn 88 ( print " c h a n g ed i r e c t i o n " ) ( loop f o r i from 1 to 3 do 90 ( progn ( s e t f c u r r e n td i r e c t i o n ( g e tn e x tl e f td i r e c t i o n c u r r e n td i r e c t i o n ) ) 92 ( s e t f positionEC ( isdirectionknown c u r r e n td i r e c t i o n position ) )

( i f ( not ( equal positionEC n i l ) )

94 ( i f (and ( v a l i d positionEC ) ( not ( v i s i t e d positionEC ) ) ) (pushnew c u r r e n td i r e c t i o n l s tp o s s i b l e ) ) 96 ) ) ) ( print l s tp o s s i b l e ) 98 ( i f ( not ( equal l s tp o s s i b l e n i l ) ) ( s e t f ( d i r e c t i o n agent ) ( f i r s t l s tp o s s i b l e ) ) 100 ( s e t f ( d i r e c t i o n agent ) ( g e tn e x tl e f td i r e c t i o n d i r e c t i o n ) ) ) ) ) ) 102

; ; ( changedirection currentagent (positionG currentagent) ( direction currentagent))

104 ; ; ; Example

; ; ( setf (smelly position12 ) t )

106 ; ; (pushnew ( l i s t position11 position12 ) (gethash 'adjacentnorth agentkb) ) ; ; (pushnew ( l i s t position11 wall ) (gethash 'adjacentwest agentkb) )

108 ; ; ( changedirection currentagent position11 south)

( l e t ( ( returntype ' identifywumpussquare ) ) 110 ( defun killedthewumpus ( agent position )

( l e t ( ( nextpos ( n e x tp o s i t i o n position d i r e c t i o n ) ) ) 112 ( prog

( print " killedthewumpus " ) 114 ( getthewumpus n e x tp o s i t i o n )

( setcurrenttypeiflowlevel returntype )

116 )

) ) 118 )

120 ( l e t ( ( returntype ' r o o t ) )

( defun goforward ( agent position d i r e c t i o n )

122 ( l e t ( ( nextpos ( i n f e r e n c ef o r w a r dp o s i t i o n position d i r e c t i o n ) ) )

124 ( progn

( print " goforward " )

126 ( i f ( not ( equal nextpos w a l l ) )

( s e t f ( p o s i t i o n G agent ) nextpos ) ) 128 ( setcurrenttypeiflowlevel returntype )

) 130 ) ) 132 ) ;;;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− 1 ; ; ; ; Created on 20081025 12:19:17 ( defun s etva lidsq u a r e ( c p o s i t i o n ) 3 ( s e t f ( v a l i d c p o s i t i o n ) t ) ) ; ; ; ; Created on 20081018 15:30:36 2 ; ; ; pr1 . ( l e t ( ( name ' pr1 )

4 ( l s tt y p e s ' ( nextpositionisavalidsquare breezesquare ) ) ( subsumed ' ( ) )

6 ( subsuming ' ( pr3 ) ) ( meronym ' ( ) )

8 ( holonym ' executeactionnextpositionisavalidsquare ) ( c o n s t r u c t o r ' ( lambda ( x y )

10 ( l e t( ( a x )

12 ( c ( f u n c a l l ( partof ) a b ) ) ) ( i f ( not ( equal c n i l ) )

14 ( l i s t a ( l i s t b c ) ) n i l

16 ) ) ) ) )

( defun getsubsumedpr1 ( ) 18 subsumed

)

20 ( defun getsubsumingpr1 ( ) subsuming

22 )

( defun getmeronympr1 ( ) 24 meronym

)

26 ( defun getholonympr1 ( ) holonym

28 )

( defun proofpr1 ( )

30 ; ; ; Call a generic function .

)

32 ( defun gettypelstpr1 ( ) l s tt y p e s

34 )

( defun pr1 ( agentdirectiontovalidsquare breezesquare )

36 ( f u n c a l l ( eval c o n s t r u c t o r ) agentdirectiontovalidsquare breezesquare ) ) )

; ; ; ; Created on 20081018 15:30:36

2 ; ; ; pr1 .

( l e t ( ( name ' pr2 )

4 ( l s tt y p e s ' ( breezesquare goldsquare ) ) ( subsumed ' ( ) ) 6 ( subsuming ' ( ) ) ( meronym ' ( ) ) 8 ( holonym n i l ) ( c o n s t r u c t o r ' ( lambda ( x y ) 10 ( l e t( ( a x ) ( b y ) 12 ( c ( f u n c a l l ( partof ) a b ) ) ) ( i f ( not ( equal c n i l ) ) 14 ( l i s t a ( l i s t b c ) ) n i l 16 ) ) ) ) )

( defun getsubsumedpr2 ( ) 18 subsumed

)

20 ( defun getsubsumingpr4 ( ) subsuming

22 )

( defun getmeronympr2 ( ) 24 meronym

)

26 ( defun getholonympr2 ( ) holonym

28 )

( defun proofpr2 ( )

30 ; ; ; Call a generic function .

)

32 ( defun gettypelstpr2 ( ) l s tt y p e s

34 )

( defun pr2 ( breezesquare goldsquare )

36 ( f u n c a l l ( eval c o n s t r u c t o r ) breezesquare goldsquare ) ) )

; ; ; ; Created on 20081018 15:42:15

2 ( l e t ( ( name ' pr3 )

( l s tt y p e s ' ( nextpositionisavalidsquare breezesquare smellysquare ) ) 4 ( subsumed ' ( pr1 pr2 ) )

( subsuming ' ( pr4 ) ) 6 ( meronym ' ( ) )

( holonym ' ( nextpositionisavalidsquare breezesquare smellysquare ) ) 8 ( c o n s t r u c t o r ' ( lambda ( x y z ) ( l e t( ( a x ) 10 ( b y ) ( c z ) 12 ( d ( f u n c a l l ( partof ) a b c ) ) ) ( i f ( not ( equal d n i l ) ) 14 ( l i s t a b c d ) n i l 16 ) ) ) ) )

( defun getsubsumedpr3 ( ) 18 subsumed

)

20 ( defun getsubsumingpr3 ( ) subsuming

22 )

( defun getmeronympr3 ( ) 24 meronym

)

26 ( defun getholonympr3 ( ) holonym

Annexe C. Code Lisp du Wumpus

28 )

( defun proofpr3 ( )

30 ; ; ; Call a generic function .

)

32 ( defun gettypelstpr3 ( ) l s tt y p e s

34 )

( defun pr3 ( agentdirectiontovalidsquare breezesquare smellysquare )

36 ( f u n c a l l ( eval c o n s t r u c t o r ) agentdirectiontovalidsquare breezesquare smellysquare ) ) )

; ; ; ; Created on 20081018 15:30:36

2 ; ; ; pr1 .

( l e t ( ( name ' pr4 )

4 ( l s tt y p e s ' ( smellysquare breezesquare goldsquare ) ) ( subsumed ' ( ) ) 6 ( subsuming ' ( ) ) ( meronym ' ( ) ) 8 ( holonym n i l ) ( c o n s t r u c t o r ' ( lambda ( x y z ) 10 ( l e t( ( a x ) ( b y ) 12 ( c z ) ( d ( f u n c a l l ( partof ) a b c ) ) ) 14 ( i f ( not ( equal d n i l ) ) ( l i s t a ( l i s t b ( l i s t c d ) ) ) 16 n i l ) ) ) ) ) 18 ( defun getsubsumedpr4 ( )

subsumed 20 )

( defun getsubsumingpr4 ( ) 22 subsuming

)

24 ( defun getmeronympr4 ( ) meronym

26 )

( defun getholonympr4 ( ) 28 holonym

)

30 ( defun proofpr4 ( )

; ; ; Call a generic function .

32 )

( defun gettypelstpr4 ( ) 34 l s tt y p e s

)

36 ( defun pr4 ( smellysquare breezesquare goldsquare )

( f u n c a l l ( eval c o n s t r u c t o r ) smellysquare breezesquare goldsquare ) ) ) 1 ; ; ; ; Created on 20081024 16:30:42

; ; ; pr5 .

3 ( l e t ( ( name ' pr5 )

( l s tt y p e s ' ( nextpositionisavalidsquare smellysquare ) ) 5 ( subsumed ' ( ) )

( subsuming ' ( ) ) 7 ( meronym ' ( ) )

( holonym ' ( nextpositionisavalidsquare smellysquare ) ) 9 ( c o n s t r u c t o r ' ( lambda ( x y ) ( l e t( ( a x ) 11 ( b y ) ( c ( f u n c a l l ( partof ) a b ) ) ) 13 ( i f ( not ( equal c n i l ) ) ( l i s t a ( l i s t b c ) ) 15 n i l ) ) ) ) ) 17 ( defun getsubsumedpr5 ( )

subsumed 19 )

( defun getsubsumingpr5 ( ) 21 subsuming

)

23 ( defun getmeronympr5 ( ) meronym

25 )

( defun getholonympr5 ( ) 27 holonym

)

29 ( defun proofpr5 ( )

; ; ; Call a generic function .

31 )

( defun gettypelstpr5 ( ) 33 l s tt y p e s

)

35 ( defun pr5 ( agentdirectiontovalidsquare smellysquare )

( f u n c a l l ( eval c o n s t r u c t o r ) agentdirectiontovalidsquare smellysquare ) ) )

; ; ; ; Created on 20081018 15:30:36

2 ; ; ; pr1 .

4 ( l s tt y p e s ' ( smellysquare goldsquare ) ) ( subsumed ' ( ) ) 6 ( subsuming ' ( ) ) ( meronym ' ( ) ) 8 ( holonym n i l ) ( c o n s t r u c t o r ' ( lambda ( x y ) 10 ( l e t( ( a x ) ( b y ) 12 ( c ( f u n c a l l ( partof ) a b ) ) ) ( i f ( not ( equal c n i l ) ) 14 ( l i s t a ( l i s t b c ) ) n i l 16 ) ) ) ) )

( defun getsubsumedpr6 ( ) 18 subsumed

)

20 ( defun getsubsumingpr6 ( ) subsuming

22 )

( defun getmeronympr6 ( ) 24 meronym

)

26 ( defun getholonympr6 ( ) holonym

28 )

( defun proofpr6 ( )

30 ; ; ; Call a generic function .

)

32 ( defun gettypelstpr6 ( ) l s tt y p e s

34 )

( defun pr6 ( smellysquare goldsquare )

36 ( f u n c a l l ( eval c o n s t r u c t o r ) smellysquare goldsquare ) ) )

; ; ; ; Created on 20081116 19:08:19 2 ; ; ; ; <> 4 ( l e t ( ( name ' r o o t ) ( l s tt y p e s ' ( ) ) 6 ( subsumed ' ( ) ) ( subsuming ' ( a g e n tl o c a t i o n ) ) 8 ( meronym ' ( ) ) ( holonym ' ( ) ) 10 ( c u r r e n tv a l u e ' ( ) ) ( l e v e l 2) 12 ( c o n s t r u c t o r ' ( ) ) ) 14 ( defun g e tl e v e lr o o t ( ) l e v e l 16 ) ( defun i n i t i a l i s er o o t ( ) 18 ( s e t f c u r r e n tv a l u e ' ( ) ) ) 20

( defun getsubsumedroot ( ) 22 subsumed

)

24 ( defun getsubsumingroot ( ) subsuming

26 )

( defun getmeronymroot ( ) 28 meronym

)

30 ( defun getholonymroot ( ) holonym

32 )

( defun proofroo t ( )

34 ; ; ; Call a generic function .

)

36 ( defun gettypelstroot ( ) l s tt y p e s 38 ) ( defun r o o t ( ) 40 ( ) ) ) ; ; ; ; Created on 20081025 11:10:35 2 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; agenthasgold

4

( l e t ( ( name ' agenthasgold )

6 ( l s tt y p e s ' ( a g e n tl o c a t i o n ) ) ( subsumed ' ( a g e n tl o c a t i o n ) ) 8 ( subsuming ' ( ) ) ( meronym ' ( ) ) 10 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 12 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 14 ( l e t( ( a x ) ( b ( hasgoldp ( pi1 a ) ) ) )

Annexe C. Code Lisp du Wumpus

16 ( i f (and ( not ( equal b n i l ) ) ) ( l i s t a b )

18 n i l

) ) ) ) ) 20

( defun getlevelagenthasgold ( ) 22 l e v e l

)

24 ( defun i n i t i a l i s ea g e n th a sg o l d ( ) ( s e t f c u r r e n tv a l u e ' ( ) )

26 )

( defun getsubsumedagenthasgold ( ) 28 subsumed

)

30 ( defun getsubsumingagenthasgold ( ) subsuming

32 )

( defun getmeronymagenthasgold ( ) 34 meronym

)

36 ( defun getholonymagenthasgold ( ) holonym

38 )

( defun proofagenthasgold ( ) 40 ; ; ; Call a generic function .

)

42 ( defun gettypelstagenthasgold ( ) l s tt y p e s

44 )

( defun agenthasgold ( agentwump )

46 ( f u n c a l l ( eval c o n s t r u c t o r ) agentwump ) ) )

; ; ; ; Created on 20081009 14:39:41

2 ; ; ; agentlocation (TDR).

( l e t ( ( name ' a g e n tl o c a t i o n ) 4 ( l s tt y p e s ' ( agentwumpus ) )

( subsumed ' ( ) )

6 ( subsuming ' ( agenthasgold ~agenthasgold ) ) ( meronym ' ( ) ) 8 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 10 ( l e v e l 1) ( c o n s t r u c t o r ' ( lambda ( x ) 12 ( l e t( ( a x ) ( b ( a g e n tp o s i t i o n a ) ) 14 ( c ( a g e n td i r e c t i o n a ) ) )

( i f (and ( not ( equal b n i l ) ) ( not ( equal c n i l ) ) ) 16 ( l i s t a ( l i s t b c ) ) n i l 18 ) ) ) ) ) 20 ( defun g e tl e v e la g e n tl o c a t i o n ( ) 22 l e v e l ) 24 ( defun i n i t i a l i s ea g e n tl o c a t i o n ( ) ( s e t f c u r r e n tv a l u e ' ( ) ) 26 ) ( defun e x e c u t ea c t i o na g e n tl o c a t i o n ( ) 28 ( f u n c a l l a c t i o n ( pi1 ( pi2 ( pi2 c u r r e n tv a l u e ) ) ) ) )

30 ( defun getsubsumedagentlocation ( ) subsumed

32 )

( defun getsubsumingagentlocation ( ) 34 subsuming

)

36 ( defun getmeronymagentlocation ( ) meronym

38 )

( defun getholonymagentlocation ( ) 40 holonym

)

42 ( defun p r o o fa g e n tl o c a t i o n ( )

; ; ; Call a generic function .

44 )

( defun gettypelstagentlocation ( ) 46 l s tt y p e s

)

48 ( defun a g e n tl o c a t i o n ( agentwump )

( f u n c a l l ( eval c o n s t r u c t o r ) agentwump ) ) ) 50

; ; ; ( agentlocation agent1)

1 ; ; ; ; Created on 20081009 15:15:04 ; ; ; ; breezesquare

3 ; ; ; ; ( load "/home/patrick/Thesis/IntContextType/v02a/IntContextType002/IntContextType002/Ontologies/Contexts/DTR/tdrbreezesquare . lisp ")

( l s tt y p e s '(~ agenthasgold ) ) 7 ( subsumed '(~ agenthasgold ) )

( subsuming ' ( ) ) 9 ( meronym ' ( pr1 pr2 pr3 pr4 ) ) ( holonym ' ( ) ) 11 ( c u r r e n tv a l u e ' ( ) ) ( l e v e l 3) 13 ( c o n s t r u c t o r ' ( lambda ( x ) ( l e t( ( a x ) 15 ( b ( isbreezypositionp ( pi1 ( pi2 ( pi1 a ) ) ) ) ) )

17 ( i f (and ( not ( equal b n i l ) ) )

19 ( l i s t a b )

n i l

21 ) ) ) ) )

( defun getlevelbree zes quar e ( ) 23 l e v e l

)

25 ( defun i n i t i a l i s eb r e e z es q u a r e ( ) ( s e t f c u r r e n tv a l u e ' ( ) ) 27 )

( defun getsubsumedbreezesquare ( ) 29 subsumed

)

31 ( defun getsubsumingbreezesquare ( ) subsuming

33 )

( defun getmeronymbreezesquare ( ) 35 meronym

)

37 ( defun getholonymbreezesquare ( ) holonym

39 )

( defun proofbreezesquare ( ) 41 ; ; ; Call a generic function .

)

43 ( defun gettypelstbreezesquare ( ) l s tt y p e s

45 )

( defun breezesquare ( a g e n tl o c a t i o n )

47 ( f u n c a l l ( eval c o n s t r u c t o r ) a g e n tl o c a t i o n ) ) ) 1 ; ; ; ; Created on 20081009 15:22:53

; ; ; ; goldsquare

3 ; ; ; ; ( load "/home/patrick/Thesis/IntContextType/v02a/IntContextType002/IntContextType002/Ontologies/Contexts/DTR/tdrgoldsquare . lisp ")

5

( l e t ( ( name ' goldsquare )

7 ( l s tt y p e s '(~ agenthasgold ) ) ( subsumed '(~ agenthasgold ) ) 9 ( subsuming ' ( ) ) ( meronym ' ( pr4 ) ) 11 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 13 ( l e v e l 3) ( c o n s t r u c t o r ' ( lambda ( x ) 15 ( l e t( ( a x ) ( b ( i sp e r c e i v eg l i t t e rp ( pi1 ( pi2 ( pi1 a ) ) ) ) ) 17 )

( i f (and ( not ( equal b n i l ) )

19 )

( l i s t a b )

21 n i l

) ) ) ) ) 23 ( defun getlevelgoldsquare ( )

l e v e l 25 )

( defun i n i t i a l i s eg o l ds q u a r e ( ) 27 ( s e t f c u r r e n tv a l u e ' ( ) )

)

29 ( defun getsubsumedgoldsquare ( ) subsumed

31 )

( defun getsubsuminggoldsquare ( ) 33 subsuming

)

35 ( defun getmeronymgoldsquare ( ) meronym

37 )

( defun getholonymgoldsquare ( ) 39 holonym

)

41 ( defun proofgoldsquare ( )

; ; ; Call a generic function .

43 )

( defun gettypelstgoldsquare ( ) 45 l s tt y p e s

)

Annexe C. Code Lisp du Wumpus

( f u n c a l l ( eval c o n s t r u c t o r ) a g e n tl o c a t i o n ) ) )

; ; ; ; Created on 20081011 12:11:48

2 ; ; ; ; identifydeadwumpussquare

4 ( l e t ( ( name ' identifydeadwumpussquare )

( l s tt y p e s ' ( identifywumpusposition wumpus ) ) 6 ( subsumed ' ( identifywumpusposition ) )

( subsuming ' ( ) ) 8 ( meronym ' ( ) ) ( holonym ' ( ) ) 10 ( c u r r e n tv a l u e ' ( ) ) ( l e v e l 5) 12 ( c o n s t r u c t o r ' ( lambda ( x y ) ( l e t( ( a x ) 14 ( b y ) ( c ( i sl o c a t e di n p ( pi2 ( pi1 ( pi1 ( a ) ) ) ) b ) ) 16 ( d ( isdeadp b ) ) ) 18 ( i f ( not ( equal c n i l ) ) ( l i s t a ( l i s t b ( l i s t c d ) ) ) 20 n i l ) ) ) ) )

22 ( defun getlevelidentifydeadwumpussquare ( ) l e v e l

24 )

( defun initialiseidentifydeadwumpussquare ( ) 26 ( s e t f c u r r e n tv a l u e ' ( ) )

)

28 ( defun getsubsumedidentifydeadwumpussquare ( ) subsumed

30 )

( defun getsubsumingidentifydeadwumpussquare ( ) 32 subsuming

)

34 ( defun getmeronymidentifydeadwumpussquare ( ) meronym

36 )

( defun getholonymidentifydeadwumpussquare ( ) 38 holonym

)

40 ( defun proofidentifydeadwumpussquare ( )

; ; ; Call a generic function .

42 )

( defun gettypelstidentifydeadwumpussquare ( ) 44 l s tt y p e s

)

46 ( defun identifydeadwumpussquare ( identifywumpusposition wumpus) ( f u n c a l l ( eval c o n s t r u c t o r ) identifywumpusposition wumpus ) ) 48 )

; ; ; ; Created on 20081009 15:42:38

2 ; ; ; ; identifywumpussquare

4 ( l e t ( ( name ' identifywumpussquare )

( l s tt y p e s ' ( smellysquare position position s m e l l y ) ) 6 ( subsumed ' ( smellysquare ) )

( subsuming ' ( ) ) 8 ( meronym ' ( ) ) ( holonym ' ( ) ) 10 ( c u r r e n tv a l u e ' ( ) ) ( l e v e l 4) 12 ( c o n s t r u c t o r ' ( lambda ( v w x y ) ( l e t( ( a v ) 14 ( b w) ( c x ) 16 ( d y ) ( e ( i sa d j a c e n tp o s i t i o n p ( pi1 ( pi2 ( pi1 a ) ) ) b ) ) 18 ( f ( n e x tp o s i t i o n ( pi1 ( pi2 ( a ) ) ) ( pi1 ( pi2 ( pi2 ( a ) ) ) ) b ) ) ( g ( i sa d j a c e n tp o s i t i o n p b c ) ) 20 ( h ( i sa d j a c e n tp o s i t i o n b c ) ) ( i ( i ss m e l l yp o s i t i o n p b d ) ) 22 ( j ( i sd i f f e r e n tp o s i t i o n p ( pi1 ( pi2 ( a ) ) ) c ) ) )

24 ( i f (and ( not ( equal e n i l ) ) ( not ( equal f n i l ) ) ( not ( equal g n i l ) ) ( not ( equal h n i l ) ) ( not ( equal i n i l ) ) ( not ( equal j n i l ) )

26 )

( l i s t a ( l i s t b ( l i s t c ( l i s t d ( l i s t e ( l i s t f ( l i s t g ( l i s t h ( l i s t i j ) ) ) ) ) ) ) ) )

28 n i l

) ) ) ) )

30 ( defun getlevelidentifywumpussquare ( ) l e v e l

32 )

( defun i n i t i a l i s ei d e n t i f yw u m p u ss q u a r e ( ) 34 ( s e t f c u r r e n tv a l u e ' ( ) )

)

36 ( defun getsubsumedidentifywumpussquare ( ) subsumed

38 )

40 subsuming )

42 ( defun getmeronymidentifywumpussquare ( ) meronym

44 )

( defun getholonymidentifywumpussquare ( ) 46 holonym

)

48 ( defun proofidentifywumpussquare ( )

; ; ; Call a generic function .

50 )

( defun gettypelstidentifywumpussquare ( ) 52 l s tt y p e s

)

54 ( defun identifywumpussquare ( smellysquare p o s i t i o n 1 p o s i t i o n 2 s m e l l y ) ( f u n c a l l ( eval c o n s t r u c t o r ) smellysquare p o s i t i o n 1 p o s i t i o n 2 s m e l l y ) ) ) 1 ; ; ; ; Created on 20081025 11:41:31

; ; ; ; nextpositionisavalidsquare

3

( l e t ( ( name ' nextpositionisavalidsquare ) 5 ( l s tt y p e s '(~ agenthasgold ) )

( subsumed '(~ agenthasgold ) ) 7 ( subsuming ' ( ) ) ( meronym ' ( pr1 pr5 ) ) 9 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 11 ( l e v e l 3) ( c o n s t r u c t o r ' ( lambda ( x ) 13 ( l e t( ( a x ) ( b ( i sp o s s i b l ed i r e c t i o n ( pi1 ( pi2 ( pi1 a ) ) ) ( pi2 ( pi2 ( pi1 a ) ) ) ) ) 15 ) ( i f ( not ( equal b n i l ) ) 17 ( l i s t a b ) n i l 19 ) ) ) ) )

( defun getlevelnextpositionisavalidsquare ( ) 21 l e v e l

)

23 ( defun i n i t i a l i s en e x tp o s i t i o ni sav a l i ds q u a r e ( ) ( s e t f c u r r e n tv a l u e ' ( ) )

25 )

( defun getsubsumednextpositionisavalidsquare ( ) 27 subsumed

)

29 ( defun getsubsumingnextpositionisavalidsquare ( ) subsuming

31 )

( defun getmeronymnextpositionisavalidsquare ( ) 33 meronym

)

35 ( defun getholonymnextpositionisavalidsquare ( ) holonym

37 )

( defun proofnextpositionisavalidsquare ( ) 39 ; ; ; Call a generic function .

)

41 ( defun gettypelstnextpositionisavalidsquare ( ) l s tt y p e s

43 )

( defun nextpositionisavalidsquare ( a g e n tl o c a t i o n ) 45 ( f u n c a l l ( eval c o n s t r u c t o r ) a g e n tl o c a t i o n ) ) )

1 ; ; ; ; Created on 20081009 14:41:25 ; ; ; ; ~agenthasgold

3

( l e t ( ( name '~ agenthasgold )

5 ( l s tt y p e s ' ( a g e n tl o c a t i o n ) ) ( subsumed ' ( a g e n tl o c a t i o n ) )

7 ( subsuming ' ( nextpositionisavalidsquare breezesquare goldsquare smellysquare ) ) ( meronym ' ( ) ) 9 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 11 ( l e v e l 2) ( c o n s t r u c t o r ' ( lambda ( x ) 13 ( l e t( ( a x ) ( b (~ hasgoldp ( pi1 a ) ) ) ) 15 ( progn ( i f ( not ( equal b n i l ) ) 17 ( l i s t a b ) n i l 19 ) ) ) 21 ) 23 ) )

( defun getlevel~agenthasgold ( ) 25 l e v e l

)

Annexe C. Code Lisp du Wumpus

subsumed 29 )

( defun i n i t i a l i s e~agenthasgold ( ) 31 ( s e t f c u r r e n tv a l u e ' ( ) )

)

33 ( defun getsubsumed~agenthasgold ( ) subsumed

35 )

( defun getsubsuming~agenthasgold ( ) 37 subsuming

)

39 ( defun getmeronym~agenthasgold ( ) meronym

41 )

( defun getholonym~agenthasgold ( ) 43 holonym

)

45 ( defun proof~agenthasgold ( )

; ; ; Call a generic function .

47 )

( defun gettypelst~agenthasgold ( ) 49 l s tt y p e s

)

51 ( defun ~agenthasgold ( agentwump )

( f u n c a l l ( eval c o n s t r u c t o r ) agentwump ) ) )

; ; ; ; Created on 20081025 11:34:58

2 ; ; ; ; positioninvalidsquare

4 ( l e t ( ( name ' p o s i t i o ni nv a l i ds q u a r e ) ( l s tt y p e s '(~ agenthasgold ) ) 6 ( subsumed '(~ agenthasgold ) )

( subsuming ' ( ) ) 8 ( meronym ' ( pr1 ) ) ( holonym ' ( ) ) 10 ( c u r r e n tv a l u e ' ( ) ) ( c o n s t r u c t o r ' ( lambda ( x ) 12 ( l e t( ( a x ) ( b ( svalidpositionp ( pi1 ( pi2 ( pi1 a ) ) ) ) ( pi2 ( pi2 ( pi1 a ) ) ) ) 14 ) ( i f ( not ( equal b n i l ) ) 16 ) ( l i s t a b ) 18 n i l ) ) ) ) 20 ( defun g e tl e v e lp o s i t i o ni nv a l i ds q u a r e ( ) l e v e l 22 ) ( defun i n i t i a l i s ep o s i t i o ni nv a l i ds q u a r e ( ) 24 ( s e t f c u r r e n tv a l u e ' ( ) ) )

26 ( defun getsubsumedpositioninvalidsquare ( ) subsumed

28 )

( defun getsubsumingpositioninvalidsquare ( ) 30 subsuming

)

32 ( defun getmeronympositioninvalidsquare ( ) meronym

34 )

( defun getholonympositioninvalidsquare ( ) 36 holonym

)

38 ( defun pr oo fpos i t io ninva li ds qua re ( )

; ; ; Call a generic function .

40 )

( defun gettypelstpositioninvalidsquare ( ) 42 l s tt y p e s

)

44 ( defun p o s i t i o ni nv a l i ds q u a r e (~ agenthasgold ) ( f u n c a l l ( eval c o n s t r u c t o r ) ~agenthasgold ) ) ) 1 ; ; ; ; Created on 20081009 15:34:48

; ; ; ; smellysquare

3

( l e t ( ( name ' smellysquare )

5 ( l s tt y p e s '(~ agenthasgold ) ) ( subsumed '(~ agenthasgold ) )

7 ( subsuming ' ( identifywumpussquare ) ) ( meronym ' ( pr3 pr4 pr5 pr6 ) ) 9 ( holonym ' ( ) ) ( c u r r e n tv a l u e ' ( ) ) 11 ( l e v e l 3) ( c o n s t r u c t o r ' ( lambda ( x ) 13 ( l e t( ( a x ) ( b ( issmellypositionp ( pi1 ( pi2 ( pi1 a ) ) ) ) ) 15 ) ( i f ( not ( equal b n i l ) ) 17 ( l i s t a b ) n i l

19 ) ) ) ) ) 21 ( defun getlevelsmellysquare ( )

l e v e l 23 )

( defun i n i t i a l i s es m e l l ys q u a r e ( ) 25 ( s e t f c u r r e n tv a l u e ' ( ) )

)

27 ( defun getsubsumedsmellysquare ( ) subsumed

29 )

( defun getsubsumingsmellysquare ( ) 31 subsuming

)

33 ( defun getmeronymsmellysquare ( ) meronym

35 )

( defun getholonymsmellysquare ( ) 37 holonym

)

39 ( defun proofsmellysquare ( )

; ; ; Call a generic function .

41 )

( defun gettypelstsmellysquare ( ) 43 l s tt y p e s

)

45 ( defun smellysquare (~ agenthasgold )

( f u n c a l l ( eval c o n s t r u c t o r ) ~agenthasgold ) ) )

; ; ; ; Created on 20081025 11:57:36

2 ; ; ; ded01.

; ; ; Permet de déterminer que la case suivante est une case valide .

4 ( l e t ( ( l s tt y p e s ' ( position position position ) ) ( subsumed ' ( ) )

6 ( subsuming ' ( ) ) ( meronym ' ( ) )

8 ( holonym ' ( agentdirectiontovalidsquare breezesquare ) ) ( a c t i o n ' ( ) ) 10 ( c u r r e n tv a l u e ' ( ) ) ( c o n s t r u c t o r ' ( lambda ( x y z ) 12 ( l e t( ( a x ) ( b y ) 14 ( c z ) ( d ( r e s o l u t i o n a b c ) ) 16 ) ( i f ( not ( equal d n i l ) ) 18 ( l i s t a ( l i s t b c ) ) n i l ) ) ) ) 20 ) ( defun i n i t i a l i s ed e d0 1 ( ) 22 ( s e t f c u r r e n tv a l u e ' ( ) ) )

24 ( defun getcurrentvalueded01 ( ) c u r r e n tv a l u e

26 )

( defun getactionded01 ( ) 28 a c t i o n

)

30 ( defun executeactionded01 ( ) n i l

32 )

( defun getsubsumedded01 ( ) 34 subsumed

)

36 ( defun getsubsumingded01 ( ) subsuming

38 )

( defun getmeronymded01 ( ) 40 meronym

)

42 ( defun getholonymded01 ( ) holonym

44 )

( defun proofded01 ( ) 46 ; ; ; Call a generic function .

)

48 ( defun gettypelstded01 ( ) l s tt y p e s 50 ) ( defun ded01 ( p o s i t i o n 1 p o s i t i o n 2 p o s i t i o n 3 ) 52 ( f u n c a l l ( eval c o n s t r u c t o r ) p o s i t i o n 1 p o s i t i o n 2 p o s i t i o n 3 ) ) 54 ) ; ; ; Example

56 ; ;( getlsttypesofsigmatype 'ded01)

; ;( setf (gethash ' position agentkb) ( l i s t position11 position12 position22 ))

58 ; ;( setf (gethash 'adjacenteast agentkb) ( l i s t ( l i s t position12 position22 ))) ; ;( setf (gethash 'adjacentnorth agentkb) ( l i s t ( l i s t position11 position12 )))

Annexe C. Code Lisp du Wumpus

; ; ( setf (gethash 'adjacentwest agentkb) ( l i s t ( l i s t position22 position12 )))

62 ; ; ( setf lstofextension (getextensionoftypeslst (getlsttypesofsigmatype 'ded01))) ; ; ( setf lstofcartesionproductofextension (cartesianproduct lstofextension ))

64 ; ; ( getproofoftdr 'ded01 lstofcartesionproductofextension) ; ; (ded01 te1 position22 )

66

; ; ( setf te1 ( f i r s t ( f i r s t lstofcartesionproductofextension )))

68 ; ; ( setf b1 (nextpositionkb ( f i r s t (second te1 )) (second (second te1 ))))

70 ; ; ( setf te2 ( f i r s t (getcurrentvalueded01))) ; ; ( setf te3 '( setpositionvalid ))

72 ; ; ( funcall ( f i r s t te3) ( f i r s t (second(second te2 ))))

74 ; ; ( agentdirection ( f i r s t ( f i r s t lstofcartesionproductofextension) )) ; ; ; ; ; ; ( getlstproofoftdr 'agentlocation ) ; ;Ok

76 ; ; ( getlstproofoftdr 'ded01) ; ; ; ; Created on 20080928 12:17:19

2 ; ; ; ; ( load "/home/patrick/Thesis/IntContextType/v02a/IntContextType002/IntContextType002/piwumpus01. lisp ")

( l e t ( ( pitypes ' ( ) ) )

4 ( defun g e tp io n t o l o g i el s t ( ) ( second pitypes ) )

6 ( defun addpitype ( pivalue ) ( push pivalue pitypes )

8 )

( defun pitypesp ( v a l u e ) 10 (member v a l u e pitypes )

) 12 )

14 ( deftype pitypes ( ) ' ( s a t i s f i e s pitypesp ) ) 16 ; ; ; agentposition (sigma ) .

( addpitype ' a g e n tp o s i t i o n ) 18 ( l e t ( ( l s tt y p e s ' ( agentwumpus ) ) 20 ( typeO pitype ) ( c o n s t r u c t o r ' ( lambda ( x ) ( p o s i t i o n G x ) ) ) ) 22 ( defun p r o o fa g e n tl o c a t i o n ( )

; ; ; Call a generic function .

24 ) ( defun g e ta g e n tp o s i t i o nl s t ( ) 26 l s tt y p e s ) 28 ( defun a g e n tp o s i t i o n 1 ( ) ( eval c o n s t r u c t o r ) ) ) 30

; ; ; agentdirection (sigma ) .

32 ( addpitype ' a g e n td i r e c t i o n ) 34 ( l e t ( ( l s tt y p e s ' ( agentwumpus ) )

( c o n s t r u c t o r ' ( lambda ( x ) ( d i r e c t i o n x ) ) ) ) 36 ( defun p r o o fa g e n td i r e c t i o n ( )

; ; ; Call a generic function .

38 ) ( defun g e ta g e n td i r e c t i o nl s t ( ) 40 l s tt y p e s ) 42 ( defun a g e n td i r e c t i o n 1 ( ) ( eval c o n s t r u c t o r ) ) ) 1 ; ; ; ; Created on 20080928 11:33:39

; ; ; ; ( load "/home/patrick/Thesis/IntContextType/v02a/IntContextType002/sigmawumpus01. lisp ")

3

( deftype sigmatypes ( ) ' ( s a t i s f i e s sigmatypesp ) ) 5

7 ; ; ; Example :

; ; ( addsigmatypesextension 'agentlocation (getlstproofoftdr ' agentlocation ))

Index

Index Σ−types emboîtés, 83 λcube, 58 λ-cube, 59 λ−calcul typé, 45 épistémologique, 14 fonction calculable, 47 actions, 30, 87 Arbre de Porphyre, 21 AUTOMATH, 53

Calcul des Constructions Etendu, 51 calcul des Fluents, 99

Calcul des Situations, 14 calculabilité, 47 capteurs symboliques, 84 champs manifestes, 82 classe, 19 concepts, 80, 101 concepts intentionnels, 87 constructivisme, 40 contexte, 82, 84 décidable, 47 démonstrateur de DTF, 116 DFT-A, 116 DTF, 69

enregistrements à types dépendants, 84 Fluent, 99 FLUX, 99 graphes contextuels, 30 Heyting, 43 Husserl, 16 Imprédicatif, 58 imprédicative, 56 individus, 101 informatique diuse, 31

ingénierie des connaissances, 23 L'Ontologie existentielle, 13 l'ontologie formelle, 14 L'ontologie matérielle, 14 la théorie des dépendances, 16

La théorie des types de Martin-Löf, 51 Lesniewski, 16

Lisp, 139

logique combinatoire, 45 logique d'ordre supérieur, 51 Logiques de Description, 100 méréologie, 16 micromondes, 33 ontologie, 13 ontologie de domaine, 24 ontologie formelle, 15 OWL, 22 partonomie, 82 Prédicatif, 58 prédicativité, 56 principe de compatibilité, 33 principe de localité, 33 Prop, 57 PTS, 58 rôles, 101 relations partonomiques, 104 sémantique conceptuelle, 17 sémantique dénotationnelle, 46 Sorte, 57 Subsomption, 19 subsomption, 102

Index Tarski, 42 taxonomie, 19

théorie des types simples, 51

théorie des types simples de Church, 51 types dépendants, 53

Bibliographie

[1] V. Akman and M. Surav. The use of situation theory in context modeling. Computational Intelligence, 12(4) :113, 1996.

[2] Anonymous. The Common Lisp Object Standard (CLOS), October 1987. 1 videocassette (VHS) (53 min.).

[3] R. Artale, E. Franconi, and N. Guarino. Open problems with part-whole relations. In In Proc. of the 1996 Description Logic Workshop (DL-96), number WS-96-05, pages 7073. AAAI Press, 1996.

[4] Nicholas Asher and Alex Lascarides. Logics of Conversation (Studies in Natural Language Processing). Cambridge University Press, June 2005.

[5] R. Baeza-Yates. Average running time of the boyer-moore-horspool algorithm. Theoretical Computer Science, 92(1) :1931, January 1992.

[6] H. Barendregt. Handbook of Logic in Computer Science, volume 2, chapter Lambda Calculi with Types, pages 117309. Oxford University Press, 1992.

[7] H. Barendregt and H. Geuvers. Handbook of Automated Reasoning, chapter Proof-Assistants Using Dependent Type Systems, pages 11491238. Elsevier and MIT Press, 2001.

[8] H.P Barendregt. Introduction to generalized type systems. Journal of functional program-ming, vol. 1 :124 154, 1991.

[9] P. Barlatier and R. Dapoigny. Using contexts to prove and share situations. In FLAIRS Conference, pages 448453, 2007.

[10] P. Barlatier and R. Dapoigny. A theorem prover with dependent types for reasoning about actions. In STAIRS'08 Procs., pages 1223, 2008.

[11] B Barras and B. Bernardo. The implicit calculus of constructions as a programming language with dependent types. In FoSSaCS, pages 365379, 2008.

[12] J. Barwise. On Conditionals, chapter Conditionals and conditional information, pages 2154. Cambridge University Press, 1986.

[13] E. Benoit. Capteurs symboliques et capteurs ous : un nouveau pas vers l'intelligence. PhD thesis, Université Joseph Fourier, 1993.

[14] G. Betarte. Type checking dependent (record) types and subtyping. Journal of Functional and Logic Programming, 10(2) :137166, 2000.

[15] T. Bittner and M. Donnelly. Computational ontologies of parthood, componenthood, and containment. In IJCAI, pages 382387, 2005.

[16] Kamareddine F. Borghuis, T. and R. Nederpelt. Formalizing belief revision in type theory. Journal of the IGPL, 10(5) :461500, 2002.

Bibliographie

[17] Alexander Borgida. On the relative expressiveness of description logics and predicate logics. Articial Intelligence, 82(12) :353367, 1996.

[18] P. Bouquet, L. Serani, P. Brézillon, M. Benerecetti, and F. Castellani, editors. Modelling and Using Context, number 1688 in LNCS. Springer Verlag, 1999.

[19] R. J. Brachman. On the epistemological status of semantic networks. In N. V. Findler, editor, Associative Networks : Representation and Use of Knowledge by Computers, pages 350. Academic Press, Orlando, 1979.

[20] P. Brézillon. Hors du contexte and point de salut. Séminaire 'Objets Communicants', Autrans, France, 2002.

[21] P Brézillon. Context dynamic and explanation in contextual graphs. In Modeling and Using Context (CONTEXT-03, pages 94106. Springer Verlag, 2003.

[22] P. Brézillon, L. Pasquier, and J.C. Pomerol. Reasoning with contextual graphs. European Journal of Operational Research, 136(2) :290298, 2001.

[23] Patrick Brézillon and Marcos Cavalcanti. International and interdisciplinary conference context-97. 2007.

[24] S. Buvac. Quanticational logic of context. In Procs. of the 13th National Conference on Articial Intelligence, volume 1, pages 600606, 1996.

[25] S. Buvac, V. Buvac, and I. A. Mason. Metamathematics of contexts. Fundamentae Infor-maticae, 23(3) :412419, 1995.

[26] D. Calvanese, G. De Giacomo, M. Lenzerini, D. Nardi, R. Rosati, D. Calvanese, M. Len-zerini, D. Nardi, and R. Rosati. Description logics for information integration. In In Com-putational Logic : From Logic Programming into the Future (In honour of Bob Kowalski), Lecture Notes in Computer Science, pages 4160. Springer, 2001.

[27] Diego Calvanese, Maurizio Lenzerini, and Daniele Nardi. Description logics for conceptual data modeling. Logics for databases and information systems, pages 229263, 1998. Kluwer Academic Publishers, Norwell, MA, USA.

[28] P. Cartier. Logique, catégories et faisceaux. Séminaire Bourbaki, 20 (1977-1978), Exposé No. 513, 24 p., 1978.

[29] M. Chalmers. A historical view of context. Computer supported cooperative work, 13(3) :223247, 2004.

[30] G. Chen and D. Kotz. A survey of context-aware mobile computing research. Technical Report TR2000-381, Department of Computer Science, Dartmouth College, 2000.

[31] H. Chen, T. Finin, and A. Joshi. Using owl in a pervasive computing broker. In Procs. of Workshop on Ontologies in Open Agent Systems (AAMAS'03), 2003.

[32] K. Cheverst, K. Mitchell, and N. Davies. 1 design of an object model for a context sensitive tourist guide.

[33] N.B. Cochiarella. Logic and ontology. Axiomathes, 12 :117150, 2001.

[34] R. L. Constable, S. F. Allen, H. M. Bromley, W. R. Cleaveland, J. F. Cremer, R. W. Harper, D. J. Howe, T. B. Knoblock, N. P. Mendler, P. Panangaden, J. T. Sasaki, and S. F. Smith. Implementing mathematics with the Nuprl proof development system. Prentice-Hall, Inc., Upper Saddle River, NJ, USA, 1986.

[35] R. Cooper. Records and record types in semantic theory. J. Log. Comput., 15(2) :99112, 2005.

[36] T. Coquand and G. Huet. Constructions : A higher order proof system for mechanizing mathematics. In European Conference on Computer Algebra (1), pages 151184, 1985. [37] T. Coquand and G. Huet. The calculus of constructions. Information and Computation

76 (88), no. 2-3, pages 95120, 1988.

[38] J. Coutaz, J. Crowley, S. Dobson, and D. Garlan. Context is key. Communications of the ACM, 48(3) :4953, 2005.

[39] J.L. Crowley, J. Coutaz, G. Rey, and P. Reignier. Perceptual components for context aware computing. In UbiComp 2002.

[40] H. B. Curry and R. Feys. Combinatory Logic. North-Holland, Amsterdam, 1958.

[41] R. Dapoigny and P. Barlatier. Deriving behavior from goal structure for the intelligent control of physical systems. In J.A. Cetto J.Filipe, J.L. Ferrier and M. Carvalho, editors, Informatics in Control, Automation and Robotics II, volume 15, pages 5158. Springer, 2007.

[42] R. Dapoigny and P. Barlatier. Goal reasoning with context record types. In CONTEXT, pages 164177. Springer Berlin / Heidelberg, 2007.

[43] R. Dapoigny and P. Barlatier. Causal reasoning with contexts using dependent types. In FLAIRS Conference, pages 107108, 2008.

[44] R. Dapoigny and P. Barlatier. Towards a conceptual structure based on type theory. In ICCS Supplement, pages 107114, 2008.

[45] R. Dapoigny and P. Barlatier. Vers un modèle formel pour le raisonnement à partir des contextes. Revue d'Intelligence Articielle, 22(6) :725755, 2008.

[46] R. Dapoigny and P. Barlatier. Reasoning about relations with dependent types : Applica-tion to context-aware applicaApplica-tions. In ISMIS'09 Procs. Springer, 2009.

[47] R. Dapoigny and P. Barlatier. Towards an ontological modeling with dependent types : Application to part-whole relations. In ER'09 Procs. Springer, 2009.

[48] G. De Lavalette and R. Renardel. Strictness analysis via abstract interpretation for recur-sively dened types. Inf. Comput., 99(2) :154177, 1992.

[49] Maria Stela V. de Paiva. Constructive description logics : what, why and how. Workshop on Context Representation and Reasoning (CRR 2006).

[50] M. Dean and Guus Schreiber. OWL web ontology language reference. W3C recommenda-tion, W3C, February 2004.

[51] N.G. deBruijn. The Mathematical Language AUTOMATH, Its Usage and Some of its Extensions. Springer, 1970.

[52] K. Devlin. Logic and Information Theory. Cambridge University Press, 1991.

[53] Dey and K. Anind. Understanding and using context. Personal Ubiquitous Comput., 5(1) :47, 2001.

[54] Anind K. Dey and Abowd Gregory D. Towards a better understanding of context and context-awareness. In Procs. of the CHI 2000 Workshop on The What, Who, Where, When, and How of Context-Awareness, 2000.

[55] P. Dockhorn Costa, J. P. A. Almeida, L. F. Pires, G. Guizzardi, and M. van Sinderen. Towards conceptual foundations for context-aware applications. In Procs. of the AAAI'06 Workshop on Modeling and Retrieval of Context, pages 5458. AAAI Press, 2006.

Bibliographie

[56] P. Dourish. Seeking a foundation for context-aware computing. Human-Computer Inter-action, 16(2-3), 2001.

[57] P. Dourish. What we talk about when we talk about context. Personal and Ubiquitous Computing, 8(1) :1930, 2004.

[58] J. Euzenat, J Pierson, and F. Ramparany. Dynamic context management for pervasive applications. Knowl. Eng. Rev., 23(1) :2149, 2008.

[59] L. Ferreira Pires, M. van Sinderen, E. Munthe-Kaas, S. Prokaev, Hutschemaekers M., and D.-J. Plas. Techniques for describing and manipulating context information. Free-band/A_MUSE D3.5v2.0, Lucent Technologies, 2005.

[60] A. Gangemi and P. Mika. Understanding the semantic web through descriptions and situa-tions. In International Conference on Ontologies, Databases and Applications of SEmantics (ODBASE 2003), Catania, (Italy), November 2003.

[61] C. Ghidini and F. Giunchiglia. Local models semantics, or contextual reasoning = locality + compatibility. Articial Intelligence, 127(2) :221259, 2001.

[62] J. Girard. Le lambda-calcul du second ordre. Séminaire Bourbaki, 29 (1986-1987), Exposé No. 678, 13 p., 1987.

[63] J.Y. Girard. Interprétation Fonctionnelle et Elimination des Coupures de L'arithmétique D'ordre Supérieur. Thèse de Doctorat, Université Paris VII, 1972.

[64] F. Giunchiglia. Towards a logical treatment of qualitative reasoning. In Procs. of the 1rst workshop on Qualitative Reasoning about Physical Systems, 1991.

[65] F. Giunchiglia. Contextual reasoning. Technical Report 9211-20, Istituto per la Ricerca Scientica e Technologica, 1992.

[66] A. Göker. Capturing information need by learning user context. In IJCAI Workshop on Learning about users, 1999.

[67] C. Golbreich, O. Bierlaire, O. Dameron, and B. Gibaud. Use case : Ontology with rules for identifying brain anatomical structures. In W3C Workshop on Rule Languages for Interoperability, 2005.

[68] Paul Graham. On Lisp : Advanced Techniques for Common Lisp. Prentice Hall PTR, 1993. http ://www.paulgraham.com/onlisp.html.

[69] Thomas R. Gruber. Ontolingua : A mechanism to support portable ontologies. Technical report, 1992.

[70] N. Guarino. Formal ontology and informations systems. In Procs. of the 1st International Conference on Formal Ontologies in Information Systems (FOIS'98), pages 315, 1998. [71] N. Guarino, M. Carrara, and P. Giaretta. Formalizing ontological commitments. In AAAI

'94 : Proceedings of the twelfth national conference on Articial intelligence (vol. 1), pages 560567, Menlo Park, CA, USA, 1994. American Association for Articial Intelligence. [72] K. Hanna, N. Daeche, and G. Howells. Implementation of the veritas design logic. pages

7794, 1990.

[73] R. Harper and M. Lillibridge. A type-theoretic approach to higher-order modules with sharing. In Procs. of the 21st Symposium on Principles of Programming Languages, pages 123137. ACM Press, 1994.

[74] Jerry R. Hobbs. Ontological promiscuity. In Proceedings, 23rd Annual Meeting of the Association for Computational Linguistics, pages 6169, 1985.

[75] I. Horrocks and F. Patel-Schneider. A proposal for an owl rules language. In Procs. of the Thirteenth International World Wide Web Conference (WWW 2004), pages 723731, 2004.

[76] W. A. Howard. To H.B. Curry : Essays on Combinatory Logic, Lambda Calculus and Formalism, chapter The formulae-as-types notion of construction, pages 479490. Academic Press, 1980.

[77] G. Huet and T. Coquand. Coquand Huet : Constructions : a higher order proofs system for mechanizing mathematics. Technical report, INRIA, 401 edition, May 1985.

[78] G. Huet and C. Paulin-Mohring. Preuves et constructions de programmes = Proof and program construction. CNRS, Paris, FRANCE (Revue), 1993.

[79] J. Indulska, R. Robinson, A. Rakotonirainy, and K. Henricksen. Experiences in using cc/pp in context-aware systems. In In Proc. of the Intl. Conf. on Mobile Data Management (MDM, pages 247261. Springer, 2003.

[80] B. Jacobs and T.F. Melham. Translating dependent type theory into higher order logic. In Proceedings of the International Conference on Typed Lambda Calculi and Applications (TLCA'93), pages 209229, 1993.

[81] M. Kaenampornpan and E. O'Neill. Modelling context : An activity theory approach. In in Ambient Intelligence : Second European Symposium, EUSAI 2004, pages 367374. Springer, 2004.

[82] H. Kamp and U. Reyle. A calculus for rst order discourse representation structures. Logic, Language and Information, 1996.

[83] A. Kofod-Petersen and J. Cassens. Using activity theory to model context awareness. In Procs. of Modeling and Retrieval of Context (MRC2005), pages 117, 2005.

[84] A. Kopylov. Dependent intersection : A new way of dening records in type theory. In Procs. of the 18th An. IEEE Symposium on Logic in Computer Science, pages 8695, 2003. [85] G. Kreisel. La prédicativité. Bulletin de la S.M.F., tome 88, 1960.

[86] Douglas B. Lenat, C. Sierra, R.V. Guha, K. Pittman, D. Pratt, and M. Shepherd. Cyc : toward programs with common sense. Communications of the ACM, 33(8) :3049, 1990. [87] G. Löhrer. On ends and means. constructive type theory as a guide for modeling in theory

of mind and action. Mathematics and Social Sciences, 171(3) :523, 2005.

[88] S. W. Loke. Representing and reasoning with situations for context-aware pervasive compu-ting : a logic programming perspective. The Knowledge Engineering Review, 19 :213233, 2004.

[89] J. R. Longley and A. K. Simpson. A uniform approach to domain theory in realizability models. Mathematical. Structures in Comp. Sci., 7(5) :469505, 1997.

[90] Z. Luo. A unifying theory of dependent types i. LFCS Report Series ECS-LFCS-91-154,