;**************************************************************************
;* File: CROSSWORDS.clp
;* Content: Specific Module for Solving a CROSSWORDS Problem.
;* This module must be used with the MAIN and SEARCH
;* modules contained in the CCP.clp file
;* Authors: Jean-Marc Labat and Michel Futtersack
;* Version: 1.0 (September 1997)
;* Contact: Jean-Marc.Labat, Michel.Futtersack@lip6.fr
;**************************************************************************


;######################## A Crosswords Problem ########################
; Fill in the following grid :

                X            
              X              
        X               X    
          X         X        
  X   X               X      
            X     X          
    X           X           X
X                 X       X  
      X       X     X        
        X               X    
          X           X      
  X             X            
              X              
      X     X           X    
    X                 X      


; placing horizontally or vertically the following (french) words :
;
; 2 letters : "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut"
; 3 letters : "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" ;"soi" "sur" "ton" "tri" "ulm"
; 4 letters : "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" ;"reel" "sees" "unie" "user"
; 5 letters : "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" ;"ornas" "relue" "satin" "verre"
; 6 letters : "apotre" "enemas" "enigme" "eperon" "essore" "froler" ;"genois" "isatis" "limais" "murage" "pietre" "ruelle"
; 7 letters : "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" ;"granule" "mailles" "origine" "perores" "pimente" "reussie" "uretere" ;"valeurs"
; 8 letters : "assenees" "braisent" "curetage" "emergera"
;#########################################################################


;######################## Modeling #####################################
; A variable represents a place (i.e. a set of contiguous blanks on the
; same row or the same column) in the grid.
; h1, h2,...h41 denote the horizontal places and v1, v2,...v39 denote the ;vertical places.
; The names of the horizontal variables have been attributed by reading the grid
; from the left to the right row by row The names of the vertical variables have been
; attributed by reading the grid from the top to the bottom column by column
; We have to define a bijection of the set of places onto the set of words
;##########################################################################


(defmodule PROPAG
(import MAIN deftemplate ?ALL))


;################## possible values for the variables #################

(deffacts PROPAG::pb-initial
(var (name h1) (possible-values (create$ "assenees" "braisent" "curetage" "emergera" )))
(var (name h2) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name h3) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h4) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h5) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name h6) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h7) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h8) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name h9) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name h10) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name h11) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h12) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name h13) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name h14) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h15) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name h16) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h17) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name h18) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre" "tente")))
(var (name h19) (possible-values (create$ "assenees" "braisent" "curetage" "emergera")))
(var (name h20) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name h21) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name h22) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name h23) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h24) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name h25) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name h26) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h27) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h28) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name h29) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name h30) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name h31) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name h32) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name h33) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h34) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name h35) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name h36) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h37) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name h38) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h39) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name h40) (possible-values (create$ "assenees" "braisent" "curetage" "emergera")))
(var (name h41) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))

(var (name v1) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v2) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v3) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v4) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v5) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v6) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v7) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v8) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v9) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v10) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v11) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name v12) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v13) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name v14) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v15) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v16) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v17) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name v18) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v19) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v20) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v21) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name v22) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name v23) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v24) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v25) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name v26) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v27) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v28) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v29) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v30) (possible-values (create$ "anet" "arts" "crin" "emet" "erre" "lino" "niee" "nuit" "reel" "sees" "unie" "user")))
(var (name v31) (possible-values (create$ "delta" "egale" "emeus" "etire" "gener" "gnous" "maree" "ornas" "relue" "satin" "verre")))
(var (name v32) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v33) (possible-values (create$ "as" "au" "ca" "en" "le" "no" "on" "re" "si" "te" "ut")))
(var (name v34) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v35) (possible-values (create$ "are" "emu" "eta" "eus" "nes" "ost" "pas" "pre" "ree" "rue" "soi" "sur" "ton" "tri" "ulm")))
(var (name v36) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v37) (possible-values (create$ "cendres" "ecrites" "ecrouer" "enferme" "enumere" "esperes" "granule"
"mailles" "origine" "perores" "pimente" "reussie" "uretere" "valeurs")))
(var (name v38) (possible-values (create$ "apotre" "enemas" "enigme" "eperon" "essore" "froler" "genois" "isatis" "limais" "murage" "pietre" "ruelle")))
(var (name v39) (possible-values (create$ "assenees" "braisent" "curetage" "emergera"))))

;########################## description of the constraints ##############

(deftemplate PROPAG::interaction
(slot var1)
(slot letter1)
(slot var2)
(slot letter2)
)

(deffacts PROPAG::cross-words
; the constraint : (interaction (var1 <h>) (letter1 <i>) (var2 <v>) ;(letter2 <j>))
; means that the ith letter of the variable <h> must be equal to the jth ;letter
; of the variable <v>


(interaction (var1 h1) (letter1 1) (var2 v1) (letter2 1))
(interaction (var1 h1) (letter1 2) (var2 v3) (letter2 1))
(interaction (var1 h1) (letter1 3) (var2 v6) (letter2 1))
(interaction (var1 h1) (letter1 4) (var2 v8) (letter2 1))
(interaction (var1 h1) (letter1 5) (var2 v11) (letter2 1))
(interaction (var1 h1) (letter1 6) (var2 v14) (letter2 1))
(interaction (var1 h1) (letter1 7) (var2 v17) (letter2 1))

(interaction (var1 h2) (letter1 1) (var2 v25) (letter2 1))
(interaction (var1 h2) (letter1 2) (var2 v27) (letter2 1))
(interaction (var1 h2) (letter1 3) (var2 v30) (letter2 1))
(interaction (var1 h2) (letter1 4) (var2 v33) (letter2 1))
(interaction (var1 h2) (letter1 5) (var2 v36) (letter2 1))
(interaction (var1 h2) (letter1 6) (var2 v38) (letter2 1))

(interaction (var1 h3) (letter1 1) (var2 v1) (letter2 2))
(interaction (var1 h3) (letter1 2) (var2 v3) (letter2 2))
(interaction (var1 h3) (letter1 3) (var2 v6) (letter2 2))
(interaction (var1 h3) (letter1 4) (var2 v8) (letter2 2))
(interaction (var1 h3) (letter1 5) (var2 v11) (letter2 2))
(interaction (var1 h3) (letter1 6) (var2 v14) (letter2 2))
(interaction (var1 h3) (letter1 7) (var2 v17) (letter2 2))


(interaction (var1 h4) (letter1 1) (var2 v22) (letter2 1))
(interaction (var1 h4) (letter1 2) (var2 v25) (letter2 2))
(interaction (var1 h4) (letter1 3) (var2 v27) (letter2 2))
(interaction (var1 h4) (letter1 4) (var2 v30) (letter2 2))
(interaction (var1 h4) (letter1 5) (var2 v33) (letter2 2))
(interaction (var1 h4) (letter1 6) (var2 v36) (letter2 2))
(interaction (var1 h4) (letter1 7) (var2 v38) (letter2 2))

(interaction (var1 h5) (letter1 1) (var2 v1) (letter2 3))
(interaction (var1 h5) (letter1 2) (var2 v3) (letter2 3))
(interaction (var1 h5) (letter1 3) (var2 v6) (letter2 3))
(interaction (var1 h5) (letter1 4) (var2 v8) (letter2 3))

(interaction (var1 h6) (letter1 1) (var2 v14) (letter2 3))
(interaction (var1 h6) (letter1 2) (var2 v17) (letter2 3))
(interaction (var1 h6) (letter1 3) (var2 v19) (letter2 1))
(interaction (var1 h6) (letter1 4) (var2 v22) (letter2 2))
(interaction (var1 h6) (letter1 5) (var2 v25) (letter2 3))
(interaction (var1 h6) (letter1 6) (var2 v27) (letter2 3))
(interaction (var1 h6) (letter1 7) (var2 v30) (letter2 3))

(interaction (var1 h7) (letter1 1) (var2 v36) (letter2 3))
(interaction (var1 h7) (letter1 2) (var2 v38) (letter2 3))

(interaction (var1 h8) (letter1 1) (var2 v1) (letter2 4))
(interaction (var1 h8) (letter1 2) (var2 v3) (letter2 4))
(interaction (var1 h8) (letter1 3) (var2 v6) (letter2 4))
(interaction (var1 h8) (letter1 4) (var2 v8) (letter2 4))
(interaction (var1 h8) (letter1 5) (var2 v12) (letter2 1))

(interaction (var1 h9) (letter1 1) (var2 v17) (letter2 4))
(interaction (var1 h9) (letter1 2) (var2 v19) (letter2 2))
(interaction (var1 h9) (letter1 3) (var2 v22) (letter2 3))
(interaction (var1 h9) (letter1 4) (var2 v25) (letter2 4))

(interaction (var1 h10) (letter1 1) (var2 v30) (letter2 4))
(interaction (var1 h10) (letter1 2) (var2 v34) (letter2 1))
(interaction (var1 h10) (letter1 3) (var2 v36) (letter2 4))
(interaction (var1 h10) (letter1 4) (var2 v38) (letter2 4))

(interaction (var1 h11) (letter1 1) (var2 v12) (letter2 2))
(interaction (var1 h11) (letter1 2) (var2 v15) (letter2 1))
(interaction (var1 h11) (letter1 3) (var2 v17) (letter2 5))
(interaction (var1 h11) (letter1 4) (var2 v19) (letter2 3))
(interaction (var1 h11) (letter1 5) (var2 v22) (letter2 4))
(interaction (var1 h11) (letter1 6) (var2 v25) (letter2 5))
(interaction (var1 h11) (letter1 7) (var2 v28) (letter2 1))

(interaction (var1 h12) (letter1 1) (var2 v34) (letter2 2))
(interaction (var1 h12) (letter1 2) (var2 v36) (letter2 5))
(interaction (var1 h12) (letter1 3) (var2 v38) (letter2 5))

(interaction (var1 h13) (letter1 1) (var2 v1) (letter2 6))
(interaction (var1 h13) (letter1 2) (var2 v4) (letter2 1))
(interaction (var1 h13) (letter1 3) (var2 v6) (letter2 6))
(interaction (var1 h13) (letter1 4) (var2 v9) (letter2 1))
(interaction (var1 h13) (letter1 5) (var2 v12) (letter2 3))
(interaction (var1 h13) (letter1 6) (var2 v15) (letter2 2))

(interaction (var1 h14) (letter1 1) (var2 v19) (letter2 4))
(interaction (var1 h14) (letter1 2) (var2 v22) (letter2 5))

(interaction (var1 h15) (letter1 1) (var2 v28) (letter2 2))
(interaction (var1 h15) (letter1 2) (var2 v31) (letter2 1))
(interaction (var1 h15) (letter1 3) (var2 v34) (letter2 3))
(interaction (var1 h15) (letter1 4) (var2 v36) (letter2 6))
(interaction (var1 h15) (letter1 5) (var2 v38) (letter2 6))

(interaction (var1 h16) (letter1 1) (var2 v1) (letter2 7))
(interaction (var1 h16) (letter1 2) (var2 v4) (letter2 2))

(interaction (var1 h17) (letter1 1) (var2 v9) (letter2 2))
(interaction (var1 h17) (letter1 2) (var2 v12) (letter2 4))
(interaction (var1 h17) (letter1 3) (var2 v15) (letter2 3))
(interaction (var1 h17) (letter1 4) (var2 v18) (letter2 1))
(interaction (var1 h17) (letter1 5) (var2 v19) (letter2 5))

(interaction (var1 h19) (letter1 1) (var2 v4) (letter2 3))
(interaction (var1 h19) (letter1 2) (var2 v7) (letter2 1))
(interaction (var1 h19) (letter1 3) (var2 v9) (letter2 3))
(interaction (var1 h19) (letter1 4) (var2 v12) (letter2 5))
(interaction (var1 h19) (letter1 5) (var2 v15) (letter2 4))
(interaction (var1 h19) (letter1 6) (var2 v18) (letter2 2))
(interaction (var1 h19) (letter1 7) (var2 v19) (letter2 6))
(interaction (var1 h19) (letter1 8) (var2 v23) (letter2 1))

(interaction (var1 h20) (letter1 1) (var2 v28) (letter2 4))
(interaction (var1 h20) (letter1 2) (var2 v31) (letter2 3))
(interaction (var1 h20) (letter1 3) (var2 v34) (letter2 5))

(interaction (var1 h21) (letter1 1) (var2 v2) (letter2 1))
(interaction (var1 h21) (letter1 2) (var2 v4) (letter2 4))
(interaction (var1 h21) (letter1 3) (var2 v7) (letter2 2))

(interaction (var1 h22) (letter1 1) (var2 v12) (letter2 6))
(interaction (var1 h22) (letter1 2) (var2 v15) (letter2 5))
(interaction (var1 h22) (letter1 3) (var2 v18) (letter2 3))

(interaction (var1 h23) (letter1 1) (var2 v23) (letter2 2))
(interaction (var1 h23) (letter1 2) (var2 v26) (letter2 1))

(interaction (var1 h24) (letter1 1) (var2 v31) (letter2 4))
(interaction (var1 h24) (letter1 2) (var2 v34) (letter2 6))
(interaction (var1 h24) (letter1 3) (var2 v37) (letter2 1))
(interaction (var1 h24) (letter1 4) (var2 v39) (letter2 2))

(interaction (var1 h25) (letter1 1) (var2 v2) (letter2 2))
(interaction (var1 h25) (letter1 2) (var2 v4) (letter2 5))
(interaction (var1 h25) (letter1 3) (var2 v7) (letter2 3))
(interaction (var1 h25) (letter1 4) (var2 v10) (letter2 1))

(interaction (var1 h26) (letter1 1) (var2 v15) (letter2 6))
(interaction (var1 h26) (letter1 2) (var2 v18) (letter2 4))
(interaction (var1 h26) (letter1 3) (var2 v20) (letter2 1))
(interaction (var1 h26) (letter1 4) (var2 v23) (letter2 3))
(interaction (var1 h26) (letter1 5) (var2 v26) (letter2 2))
(interaction (var1 h26) (letter1 6) (var2 v29) (letter2 1))
(interaction (var1 h26) (letter1 7) (var2 v31) (letter2 5))

(interaction (var1 h27) (letter1 1) (var2 v37) (letter2 2))
(interaction (var1 h27) (letter1 2) (var2 v39) (letter2 3))

(interaction (var1 h28) (letter1 1) (var2 v2) (letter2 3))
(interaction (var1 h28) (letter1 2) (var2 v4) (letter2 6))
(interaction (var1 h28) (letter1 3) (var2 v7) (letter2 4))
(interaction (var1 h28) (letter1 4) (var2 v10) (letter2 2))
(interaction (var1 h28) (letter1 5) (var2 v13) (letter2 1))

(interaction (var1 h29) (letter1 1) (var2 v18) (letter2 5))
(interaction (var1 h29) (letter1 2) (var2 v20) (letter2 2))
(interaction (var1 h29) (letter1 3) (var2 v23) (letter2 4))
(interaction (var1 h29) (letter1 4) (var2 v26) (letter2 3))
(interaction (var1 h29) (letter1 5) (var2 v29) (letter2 2))

(interaction (var1 h30) (letter1 1) (var2 v35) (letter2 1))
(interaction (var1 h30) (letter1 2) (var2 v37) (letter2 3))
(interaction (var1 h30) (letter1 3) (var2 v39) (letter2 4))

(interaction (var1 h31) (letter1 1) (var2 v7) (letter2 5))
(interaction (var1 h31) (letter1 2) (var2 v10) (letter2 3))
(interaction (var1 h31) (letter1 3) (var2 v13) (letter2 2))
(interaction (var1 h31) (letter1 4) (var2 v16) (letter2 1))
(interaction (var1 h31) (letter1 5) (var2 v18) (letter2 6))
(interaction (var1 h31) (letter1 6) (var2 v20) (letter2 3))

(interaction (var1 h32) (letter1 1) (var2 v26) (letter2 4))
(interaction (var1 h32) (letter1 2) (var2 v29) (letter2 3))
(interaction (var1 h32) (letter1 3) (var2 v32) (letter2 1))
(interaction (var1 h32) (letter1 4) (var2 v35) (letter2 2))
(interaction (var1 h32) (letter1 5) (var2 v37) (letter2 4))
(interaction (var1 h32) (letter1 6) (var2 v39) (letter2 5))

(interaction (var1 h33) (letter1 1) (var2 v2) (letter2 5))
(interaction (var1 h33) (letter1 2) (var2 v5) (letter2 1))
(interaction (var1 h33) (letter1 3) (var2 v7) (letter2 6))
(interaction (var1 h33) (letter1 4) (var2 v10) (letter2 4))
(interaction (var1 h33) (letter1 5) (var2 v13) (letter2 3))
(interaction (var1 h33) (letter1 6) (var2 v16) (letter2 2))
(interaction (var1 h33) (letter1 7) (var2 v18) (letter2 7))

(interaction (var1 h34) (letter1 1) (var2 v24) (letter2 1))
(interaction (var1 h34) (letter1 2) (var2 v26) (letter2 5))
(interaction (var1 h34) (letter1 3) (var2 v29) (letter2 4))
(interaction (var1 h34) (letter1 4) (var2 v32) (letter2 2))
(interaction (var1 h34) (letter1 5) (var2 v35) (letter2 3))
(interaction (var1 h34) (letter1 6) (var2 v37) (letter2 5))
(interaction (var1 h34) (letter1 7) (var2 v39) (letter2 6))

(interaction (var1 h35) (letter1 1) (var2 v2) (letter2 6))
(interaction (var1 h35) (letter1 2) (var2 v5) (letter2 2))
(interaction (var1 h35) (letter1 3) (var2 v7) (letter2 7))

(interaction (var1 h36) (letter1 1) (var2 v13) (letter2 4))
(interaction (var1 h36) (letter1 2) (var2 v16) (letter2 3))

(interaction (var1 h37) (letter1 1) (var2 v21) (letter2 1))
(interaction (var1 h37) (letter1 2) (var2 v24) (letter2 2))
(interaction (var1 h37) (letter1 3) (var2 v26) (letter2 6))
(interaction (var1 h37) (letter1 4) (var2 v29) (letter2 5))
(interaction (var1 h37) (letter1 5) (var2 v32) (letter2 3))

(interaction (var1 h38) (letter1 1) (var2 v37) (letter2 6))
(interaction (var1 h38) (letter1 2) (var2 v39) (letter2 7))

(interaction (var1 h39) (letter1 1) (var2 v2) (letter2 7))
(interaction (var1 h39) (letter1 2) (var2 v5) (letter2 3))

(interaction (var1 h40) (letter1 2) (var2 v13) (letter2 5))
(interaction (var1 h40) (letter1 3) (var2 v16) (letter2 4))
(interaction (var1 h40) (letter1 5) (var2 v21) (letter2 2))
(interaction (var1 h40) (letter1 6) (var2 v24) (letter2 3))
(interaction (var1 h40) (letter1 7) (var2 v26) (letter2 7))
(interaction (var1 h40) (letter1 8) (var2 v29) (letter2 6))

(interaction (var1 h41) (letter1 2) (var2 v37) (letter2 7))
(interaction (var1 h41) (letter1 3) (var2 v39) (letter2 8))

(word "as") (word "soi") (word "gener") (word "ecrouer")
(word "au") (word "sur") (word "gnous") (word "enferme")
(word "ca") (word "ton") (word "maree") (word "enumere")
(word "en") (word "tri") (word "ornas") (word "esperes")
(word "le") (word "ulm") (word "relue") (word "granule")
(word "no") (word "anet") (word "satin") (word "mailles")
(word "on") (word "arts") (word "verre") (word "origine")
(word "re") (word "crin") (word "apotre") (word "perores")
(word "si") (word "emet") (word "enemas") (word "pimente")
(word "te") (word "erre") (word "enigme") (word "reussie")
(word "ut") (word "lino") (word "eperon") (word "uretere")
(word "are") (word "niee") (word "essore") (word "valeurs")
(word "emu") (word "nuit") (word "froler") (word "assenees")
(word "eta") (word "reel") (word "genois") (word "braisent")
(word "eus") (word "sees") (word "isatis") (word "curetage")
(word "nes") (word "unie") (word "limais") (word "emergera")
(word "ost") (word "user") (word "murage")
(word "pas") (word "delta") (word "pietre")
(word "pre") (word "egale") (word "ruelle")
(word "ree") (word "emeus") (word "cendres")
(word "rue") (word "etire") (word "ecrites")
(word "tente")
)


;###################### Constraints propagation ######################

(defrule PROPAG::propagation-1
; remove from the list of possible values of ?x2 all the words ?m which ;don't cross well
; with the word ?v
(logical (level_search ?n))
(not (level_search ?n1&:(> ?n1 ?n)))
(var (name ?x1) (value ?v&~nil) (level ?n))
?f <- (var (name ?x2) (level ?lev)(value nil)(possible-values $?poss))
(not (var (name ?x2) (level ?mm&:(> ?mm ?lev))))
(or (interaction (var1 ?x1) (letter1 ?num1) (var2 ?x2) (letter2 ?num2))
(interaction (var2 ?x1) (letter2 ?num1) (var1 ?x2) (letter1 ?num2)) )
(word ?m&:(member$ ?m $?poss))
(test (neq (sub-string ?num1 ?num1 ?v) (sub-string ?num2 ?num2 ?m)))
=>
(bind ?num (member$ ?m $?poss))
(if (= ?n ?lev)
then (modify ?f (possible-values (delete$ $?poss ?num ?num)))
else (duplicate ?f (level ?n)(possible-values (delete$ $?poss ?num ?num))))
)

(defrule PROPAG::propagation-2
; remove the word ?v from the list of possible values of ?x2
; ?v is the value of the latest assigned variable ?x1
(logical (level_search ?n))
(not (level_search ?n1&:(> ?n1 ?n)))
(var (name ?x1) (value ?v&~nil) (level ?n))
?f <- (var (name ?x2) (level ?lev)(value nil)(possible-values $?poss))
(not (var (name ?x2) (level ?mm&:(> ?mm ?lev))))
(test (member$ ?v $?poss))
=>
(bind ?num (member$ ?v $?poss))
(if (= ?n ?lev)
then (modify ?f (possible-values (delete$ $?poss ?num ?num)))
else (duplicate ?f (level ?n)(possible-values (delete$ $?poss ?num ?num))))
)