0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

download 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

of 127

Transcript of 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    1/330

     

    Th Pacc of Poo

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    2/330

    gi gmmigEhud Shapiro, eorKoichi Furukawa, Jean-Louis Lassez, Fedo Perea, and David H. D Waen,assiae irs

    The Art of Prolog: Advanced Programming Techniques Leon Serlng and EhudShapro, 1986

     Logic Programming Proceedings of the Fourth Intertonal Coerence (volues 1 and2), editd by eanLouis Lassez, 1987

    Concuent Prolog Collected Pers (volumes 1 nd 2, eie by Ehud Shapro, 1987

     Logic Progrmming Prceedings of the Fth International Conference and Symposium(voumes 1 and 2), edited by Robert A Kowask and Kenneh A Bowen, 1988

    Constraint Satisfacton in Logic Prgramming, Pasca Va Henteryck, 1989

     Logic-Based Knowledge Representation, ie by eter Jackon, Han Reichget, andFrank van relen, 1989

     Logic Programming Proceedings f the Sixth Internationl Coerence, eted byGiorgo ev and Mauro Mrll, 1989

    Meta-Programming in Logic Prgramming, edtd b vey Abrason d M HRogers, 1989

     Logic Programming Proceedings of the North American Conference voues 1and 2, editd by Ewing usk and Ross A Overbeek, 1989

    PROLOG and Its Applicatons eed by A Bond ad Bauki S an, 1990

     Logic Prgramming Proceedings of the North American Conference eied bySauya Debray and Manuel Heenegdo, 1990

    Concurrent Constraint Programming Languages, Vijay A Sraswat, 1990

     Logic Prgramming Proceedings of the Seventh Internatoal Conference died byDavid D Wrren and Peter Ser, 1990

    Prolog VLSI Implementations, Pieruigi Cvera, Giuca iccinini, and MaurzoZaboni, 1990

    The Craft of Prolog Rchard A O'Kfe, 990

    he Practice of Proog Lon S Stering, 990

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    3/330

    T Prctic of Prolo

    E by L l

    The MT Press

    Carde, Massachusesndn n and

    opyrighte Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    4/330

    ©1990 Mchutts Instute of Technolo

    All gh reved. No pt of this k may b  reproduced in any fom by

    any eectronc or mechaca means (includng photopyng, recording or nfoao strge and reteva) without sson n wting om thepubsher

    This  k was pnd and und in the Uid Stas of Ame

    Library of Coness Caogng-n-Publication Da

    The Prce of Po / [edd by] on S Srgp cm -- (gc progamming)

    ncudes biblogaphical referencesSBN 0262930-9 Prolog (Computer progr language) I Serlng, on

    l esQ7673P76P73

    0053'3-dc20

    990

    Copyrighted Material

     902397

    IP

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    5/330

    To my father Joseph Sterling, a truth seeker.

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    6/330

    Contents

    1

    Lis of Figes

    Ls of Taes

    The Auhos

    Ioduio

    rying Daabases in rlg

    T. Kazc, E. sk R Os, R Ovebeek ad S Tecke

    11 Ioduio

    1.2 Desigig a oog Daae

    121 Ceaig he EiyReaioship Mode122 Speifyig he Reaioa Repeseaio123 Impemeaio i oog

    1.3 A Moe Adaed Exampe

    13.1 A Eiy-Reaioship Mode fo a Lay132 The Reaioa Repeseaio fo he Liay aaase

    133 Impemeig he Liay aae i oog14 A Daae o Sppo oea Bioogy

    4 New oems i Compaoa Bioogy142 Lees of Daa1.4.3 Implemeig he Daae

    1. Summay

    16 Bagoud

    2 REDITO : A rg-based VLSI Edi

    Pe B Rejes

    21 oduio

    2.2 Oeew

    221 Desig Repeseaio

    222 Gaphia ispay223 Ediig

    Copyrighted Material

    1

    1

    4

    456

    9

    112

    121523

    2

    29

    31

    31 

    32

    32 

    34 

    37

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    7/330

    Contens

    23 The Coodinae Sysem 39 

    231 The Transformaion Marix 40

    232 Herarchy Flaening 45 

    2.4 The Graphical neface 45 

    24.1 Dawng Predcaes 46

    24.2 Ineracive Graphics 50

    2.5 The Edior 52

    251 Edi Operaions 52

    25.2 Hierarchy Conrol 60

    2.53 Te Ediing Loop 61

    2.5 Alernae mplemenaion 67

    2.6 Conclusion 70 

    2.7  Background 1

    3 Assisting Reiser Tansfer Level Hardwae Desin: A

    Proog Appicaon 73 

    a J. Drongowski

    3 Inroduction 73

    32 Gaphica Design Languge 74 

    3.3  Two Implemenaons 78

    3.3.1 CGDP 78332 Agen 80

    34 Design Relaions 81

    341 Modules and Subnes 833.42 Behavioa Represenaion 84343 Srucural Represenaon 87344 Phyca Represenaon 893.4.5  Componens 9

    35 Agohms and Code 93

    351 Regiser Transfer Parsing 95

    352 Daapah Suciency 983.5.3 Curren and Power Esimaion 10

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    8/330

    Contents

    36 Commnay 106

    3.7  Bagoud 106

    4 vlopng Pobl Plllzing Psc Compi nPolog 109

    Ean Gabb

    41 oduon ad Bagound 109

    42 PPPC sag III

    4.3 PPPC Oaion 113

    431 TAUPa 11443.2 VMMP Svis 1144.3.3  Paaizao Rus 1154.34 Ru Tim Pdiio 1164.35  Cod Gao 11436 Sdu Mumns 120

    4.4 mmaio 1214.4.1 Dsign Disios 121442 PPPC Comons 1224.43 Daa Suus 1224.4.4  Fon Ed Ps 124445 Smani Ch Ps 125446 Paa Ps 124.4. Cod Gnao Ps 1314.4. PPPC mmaio Saiss 132

    45 Poog an mmnao aguag 133

    46 Fuu Rsah 134

    4 Summay ad Conusions 134

    5 PoMX: Poog Pil Evluon Sysm 13

    Aun Lakhota and on Sting

    5 noduon 13Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    9/330

    5.2 The pe f aa Eaua

    53 Exampe

    5.4 ssues n aa Eaua

    541 Geeag Resdues542 Cg Ufdg543 Ceg Resdues5.44 Rewg Gas

    5.5 Sysem Aheue

    5.6 Mx

    5.7 Rewe

    5. De

    5.9 Kwedge Be

    591 pey f edaes5.9.2 Deaas f Ufdg593 Rewe Rues59.4 Deaas f De

    5.10 Hw C Ufdg5.10.1 Wkg a ee5.102 A Ose510.3 Ufd Cea

    5.11 Bakgud

    6 Genting Nur Lngge Expnns f n

    Chris Mell

    61 du

    6.2 as

    6.3 Sages Expag a a

    63 usfyg e Seps

    6.4 Deemg Explaa Suue

    65 Smpfyg he Expana

    Copyrighted Material

    o

    13

    139

    142

    4314314444

    145

    45

    157

    161

    16

    616916970

    1711717273

    176

    11

    1

    12

    1

    191

    97

    201

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    10/330

    Cnens

    66 Maipulaig Syacic Srucures 204

    6.7 Geerag Syacic Srucurs 22

    6 The Lexico ad Domai-depedece 217

    6.9  Liearisaio ad Oupu 219

    610 Bacgroud 222

    7 A Simle Learning Program 225

    Richad O'Keefe

    7.1 The T 225

    72 A Triial mplemeaio 227

    7.3  Simplifyig he rolem 232

    74 Solig he Suprolem 234

    7.5  Wha does i Cos? 23

    76 Basig he Tas o Laices raher ha Ses 241

    77 Exploraios 23 

    7. Coclusios 24

    8 Sem Data Anaysis in Prolog 249

    D. Stott Paker

    1 Sream Daa Aalysis 250

    2 Bics of Sream Daa Aalysis 25

    21 Bic Sream rocessig 252

    22 Kids of Trasducers 253

    23 Composg Trasducers 2524 Sream rocessg is moe ha Lis rocessig 260

    .25 The Sream Daa Aalysis aradigm 262

    3 Limaos of rolog for Sream Daa Aalyss 26331 rolog Requires Los of Memory 264

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    11/330

    Cntts

    83 oog Las a Sig Daaype 6

    833 Seam oessig Requies Sak Maeae 66

    83.4 oogs /O Mehasms ae adequae 6983 olog's Coo Mehasms ae adequae

    836 oog h a mpedae Mismah wih DBMS 3

    83 Summay: oems ad Souios 4

    84 Log(F) A Rewiig Sysem i oog

    84 Oeiew of F* ad Log(F) 6

    84 F* A Rewe Rue Laguage 8

    843 Log(F) egaig F wih oog 80

    844 Seam oessg Aspes of Log(F)83

    8. Seam oessig oog 8

    8 mpemeig Tasdues Log(F) 8

    8 Bi Saisa Tme Sees Aaysis 88.3 Aggegae Compuaios 898.4 Compuig Medias ad Quaies 898 ae Mahig agais Seams 9

    8.6 Coeg oog wih Daaes 94

    86 A Commo Mode fo oog ad DBMS 9486 Coupg oog ad DBMS wh Seams 295 8.63 mpemeao of oog-DBMS Coupg 96

    8 Bagoud 299 

    Biiogaphy 33

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    12/330

    Lis of Fiues

    A Smple Model 4

    An Expanded Model

    3 brary ER Dagram 9

    4 Core Data ER Dagram 6

    Extended ER Dagram

    Documentaton 3

    Schematc 36

    3 Symboc 36

    4 Physcal Layout 37. Informaton n a box/ term 40

    6 Coordnate Transformaton 4

    7 ansformaton Components 4

    8 Four of Eght Orentatons 4

    9 Matrx Transformaton 44 

    0 Dspay Code and Resutng Image of a Contct 46 

    Transstors 47 

    Fve Dspay Modes for a Sub-crcut Instance 0

    3 Code and Dsplay Output of drawinsan/3 50 

    4 MouseButton Functons 3

    3 Example Behavor Graph 7

    3 Subnet wth Condtona Control Flow 76

    33 Example Structure Dagram 77 3.4  CGD System Structure 79 

    3 Agent System Structure 80

    36 Desgn Fle Representaton of "man 8

    37  anston Relaton 83

    38 Module and Subnet Reatons 84

    39  Pace Reatons 8

    30 Ce and Select Dspatch Relaton 86

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    13/330

    Li of Fgur

    3.11 Arc Rlaios 6

    31 Modl ad ompo sac Raios

    313 ompo Ari/Val Diio 3.14 or Dio Rlaio

    3.1 ocio Rlaio

    3.16 acm ormaio 9

    31 ompo Diio Rlaios 90

    3.1 ompo Dlay Rlaio 90

    319 ompo hysical haracrisics 9

    30 Rpor Arcrlad rrors 9431 Hadli crm a Spcial 95 

    3 Risr Trasr ars Topll 96

    33 prsso ars ad Oraors 9

    34 Siks Sorcs ad rx cod 99

    3 Bi Trac rom Dsiaio Risr 100

    3.6 Trac xprssio ad Daapah 10

    3. Trac Moadic xprssio ad Daapah 103

    3 ao rom a Sich lm 103

    39 r ad or simao 104

    330 od o omp ompo rr ad or 10

    4.1 Usa 11

    4. ompos 13

    .1 rprr or r roo 13

    COUt - a olo rprr o o Rcios 140

    5.3  should_ake A Rdmary Mdica xpr Sysm 140

    4 Rsu o ompii coun ih rspc o houlLtake 14

    55  Rsl o Trasorm rsid 143

    6 Mx Krl or r rolo 146

    6.1 A lcrical 16

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    14/330

    Ls of Figures

    6 Stges in Explining Pln 88

    8 he Sum f Piwise Pducts f w Strm 8. Cmpsitin f nsduces 8

    8 A nsduc tht Cmputes Stndrd Diins 9

    84 Recusive rnsduce tht Fnds Prims 60

    8 Cupling Prg wi DMS vi Strm 9

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    15/330

    Lis of Tabls

    Attrbute for brary Databe

    4 Speedup Meurement 4 PPPC Component Soure Sze 3

    4.3  PPPC Complaton Tme 33

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    16/330

    The Authors

    Pu Drongowsi s a ssoat Profssor of omptr grg ad

    at Wstr Rsr Ursty lad Oho r rogowsk ardhs dotorat at th Ursty of Utah 198 hs omptr grgfrom 977 ad hs B athmats from argllo Ursty 97 Prosy h w a omptr gr wth ord rospa ad ommatos orporato old th dsg of dstrd ad sr systms

    w a orgal otrtor to th NmP systm for rgstr trasr l modllgad aayss of hardwar systms s rrt trsts ld th spaomapl ao ad aalyss of omd hardwar ad softwar arhttrs ald whh s rtay rady for a pratal prt systms approah!

    Ern Gbbr s rrtly a PhD rsarh stdt at th omptr partt of T Ursty sra s thss stgts mthods for dlopgportal ad t softwar for mltprossors rd hs B mathmats ad omptr s ad ompr s 98 d 98

    rspty from T- rsty s rrtly th hf programmr of thparalll omptg laoratory at th omptr Dpartmt of TlUrsty prosy workd for s yars a systms rogrammr o Baframs ad o UNX systms s trsts ld parall omptto programmg lagags ad tools, sofwar grg ad omptr arhttr

    Toni Kzic s a strtor th Dpartmt of Gs hgo Urstyhool of d ad a Vstg tst th athmats ad omptr Dso at rgo Natoal Laoratory h rd hr PhD g

    ts from th rsty of Psylaa 984 d workd N rr adhromo strr of Eschichi coli for sra yrs r prst rsrh

    trsts ld tratos of mtp ohma phwys oogal ds

    ad omptatoal ology

    Aun ho s a ssstat Profssor th tr for dd omptr tds at th Ursty of othwstr osaa rd hs (Th) omptr from th Brla sttt of Thoogy ad (BT) 98 ad hs Ph. omptr from str sr rsty

    990 Drg th ors of hs PhD. h spt thr smmrs wth th omptr tr of Tx strmts Bfor og WU h workd for thr

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    17/330

    years n ndan companes, Madr Computer Laboratores and Zent ComputersLmted a software engneer and proect leader. s nterests nclude logc programmng software development metodologes, and software engneerng

    Ewig s s a senor computer scentst n te Matematcs and Comter Scence Dvson at Argonne Natonal Laboratory and Scentc Drector of Argonne'sAdvanced Computng Researc Faclty Ater recevg s P. D. n matematcsat te Unversty of Maryland n 970 e served rst te Matematcs Department and later n te Computer Scence Department at Nortern lnos Unverstybefore onng t Automated Reonng group at Argonne n 9 Hs currentreser s n automated teorem provng, logc programmng and prallel computng

    hris Mllish s a lecturer and SERC Advanced Fellow n te Department of Artcal ntellgence at te Unversty of Ednburg He graduated a matematcanfrom Oford Unversty n 976 and w awarded a PD by te Unversty of Ednburg n 9 After furter postdoctoral work, e moved to te Unversty ofSusse to ake p a lectresp n Computng and A n te Cogntve Studes Prgramme n 97 e returned to Ednburg a lecturer n te A Deprment.Snce October 95 e been supported by an SEC Advanced T FellowspHs man nterests are logc programmng and natural language processng. He s

    cautor of a tetbook on Prolog and of tree versos of a tetbook on naturallanguage processng

    Rihard 'Kf receved s undergraduate tranng at te Unversty of Aucklandbefore movng to te Department of Atcal ntellgence at te Unersty of Ednburg were e receved a P.D. At Ednburg card become an outspokenbut gly regarded member of te Prolog communty. e wored several years forQuntus Prolog n Slcon Valley before returnng down under were e s now alecturer n Compute Scence at te Royal Melbourne nsttute of Tecnology He

    s autor of a book on te crat of Prolog programmng

    Rbr lsn receved s BS. n Computer Scence from te Unversty of llnosat Urbana n 99 and s a currently olds a reseac sstantsp n te ComputerScence department He s aso pursung a doctorate n Computer Scence wtnte graduae college at Urbana. Robert w a scenc sstant n te Matematcs and Computer Scence Dvson at Argonne Natonal Laboratoy for te yearprevous to s graduaton n addton e partcpated n student researc programs under te supervson of Ross Overbeek at Argonne for te ve years pror

    to s appontment a sentc sstant He s presently workng wt multpr

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    18/330

    esso eomane insumenaion and visualizaion and an ongoing ineesin develoing ools o oale aallel omuing

    R vb is a senio omue siens a gonne Naional aoaoy Heeeved s BP om Gand alley Sae College and s MS om Penn Sae

    nvesy in 97 He go s PD in omue siene om Penn Sae in 97.e en aug a Noen Illinois nivesiy o yeas, eoe aking a ieeemen n Mau o a yea. Sne 983 he h een a meme o he Maemais and Comue Siene Division a gonne doing eseah in auomaeddeduon, logi ogammng, and aallel omuaon Fo he l wo yeas, he oused on aliaons o logi ogammng in oleua iology He is now

    on e Join Inomis Tk Foe, a woking gou dsg he NIH and DOEon omuaonal equemens o he Human Genoe naie

    D. So rr is an ssoiae Poesso n he Coue Sene Deamen aC in os ngeles He eeied his B n Maeas n 974 om neonnvesiy um laude, and hs D in Comue Sene n 978 om he nive

    sy o Illinois Beoe aiving a C he sen a eod o osdooa eseaha e nvesy o Genole n Fane Duing e yeas 984985 e seved dieo o esea on Knowedge-Bed Sysems a Silog, n, a os ngeles

    sau omany Hs ineess inlude logi ogang, daa and knowledgee sysems and onsained modeling

    r Rinj een a Meme o Tehnial Sa o e Mioeleonis Cene o No Caolina MCNC) sine 98 He eeied a BS in hysis om enesiy o Noh Caolina a Chael Hll whee he aso woked n he ComueGas aoaoy fe wo yeas wiing mioode and doing NX develomen wok o Daa Geneal Cooaion e oined MCNC whee e eenwoking on SCD sowae and e design o seial uose adwae o

    omuaional moleua iology He sen e yea 989 on loan om MCNC oIBM Cooaion, doing ehnologyanse n olog-ed CD ools

    n Sing is an ssoae Poesso in e Deamen o Come Engineen and Siene a Ce Wesen Reseve nivesiy (CW), and oDieo oe Cene o uomaion and Inelligen Sysems esea hee He eeiveds BShons) in Mahemais and Comue Sene om he nivesiy oMeloune in 976 and his D in Pue Mahemas om usaan Naionalnivesy in 98 He sen hee yeas n e ial nelligene Deamen

    a e nivesiy o Edinugh, and one yea a e Weizmann Insiue eoeoning CWR n 985 His ineess inlude log ogamming, exe sysems

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    19/330

    and nw fndatin fr articial intllgnc

    St uc a cintic itant n th Mathatic and Cptr Scinc

    Diviin at Argnn Natinal Laratry H rcvd h BA with a arin Mathatc fr St Olaf Cllg in 99. A an ndrgradat h ganwring at Argnn in a tdnt prgra ndr th prviin f R OvrDring thi ti h tdid and wrd n paralll cpting and lgic prgraing Aftr gradating fr St Olaf and n rif tr f gradat tdih gan hi crrnt pitn at Argnn Hi crrt itt incld cncrrnt lgc prgrang parall cptng and th apicatn f graphcal rintrfac t parall rgraing

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    20/330

    Introduction

    The raisn d'tre f this k is t encrage rgrammers t se rlg intheir daytday wrk ersnally I nd the langage eciting t se, and wisht share the ecitement with thers. re ragmaticaly, I ave seen w certainderatelysized ieces f sftware are far eier t write in rlg tn in anyther langage with which I am familiar. Frther, te cde if written clearly cane eiy aintained y ersns ther than the riginal atr.

    Why is the encrageent necessary? Why is rlg nt ing widely tght andsed in stware engineering rjects In fact, recetin t rlg has een miedranging frm ecitement in re, adtin y cnsenss in Jaan and rejdiced aivalence y the mainstream cmter science cmmnity in te UnitedStates A ajr reasn fr the mied recetin f rlg h een, in my inin,the relative inaccessiility f gd edcatinal material shwing hw the angageshld be sed. Indeed, ve years ag there w nly ne widely availale kn rg, the weknwn rier rgramming in rlg ? any lar

    iscncetins anded at the signicance f rlgs cnstrcts and rgraming technies, fr eamle the rle f ct, wi sggested that rlg nt a gd general langage. ar miscncetins take a lng tie t ssideand need new material t hallenge the ld

    The lack f intrdctry tets fr rlg as een addressed. ere heen an elsin f tets in ecent years, inclding e rt f rlg [?] n tisLgic rgraming Series. By and large hwever, te crren r f tesaddress rgramming in the small It is sill necessay t sw w t etend thesma eamles in the tets t rgramming rjects

    This k, in cntrt, is intended t hel rlg rgramming in the mderatet arge. It is a cllectin f rgramming rjects and licatins Each caterelains a articlar alicatin and resents a rlg rgram written t slvethe alicatin It stands aart in the level f detil and te shisticatin and

    ality f the cdeThe chaters are nt hmgenes, neither in writing style nr in the level f

    ackgrnd knwledge eected y the reader, nr in te eerience te thrshave in rgraing in rlg Hwever, therein lies a strength Tere is n

    single crrect way t deve cde in any rgramming langage, and rlg is necetin. This k de t the variety f atrs, sws a variety f styles fr

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    21/330

    eetively developin proras in Prolo Frtheroe, readers at dierent levelsof prorain expertise shold see that Prolo ay e sefl for the

    The oon thread etween the hapters is the eetive se of Prolo Foreah appliation, the athor w onvined of the appropriateness of Prolo, andorrowed and developed the neessary prorain tehniqes Prolo is notalways an ey lanae to se There are a lot of stle eets roht on ythe power of niation and aktrakin. Seeinly vey siilar proras anperfor very dierently owever with a lear loia nderstandin of a prole,a proraer an write a very lear prora, is istrated in eah hapter

    This ook is intentionally nsal in its level of detail of presentin ode nlike

    olletions of researh papers where ode is essentialy shnned, enoh of the ode

    is iven so that the reader knowledeale in the iven appliation area shold eale to reonstrt the appliation The siniant advantae ained in this ook isivin an appreiation of the praati isses that aise when developin a sizaleappliation in Prolo. Praati onsiderations annot e eily explained in anintrodtory textook or with sall proras Expressed eneralities, shonsiderations an sond very hollow n ontrt, in the ontext of a real exaple,the point oes throh forefly

    The rst hapter of this ook onerns the prooypin of dataes in Prolo

    It starts with a siple exaple of odellin a video rental store that wold oeeily to a stdent of relational datae tehnoloy ndeed a relatonal dataeis an exaple of a siple loi prora Jst this level of Prolo prorain issefl to rapidly onstrt a datae Lsk and Oveeek, two of the oathors ofthis hapter, sed Prolo dataes to oordinate the reviewin of onferene paperswhen they were prora onferene hairs At e Western Reserve Unversitythe radate stdent oee l h een aintained a Polo datae. Thispaper is onerned priariy, however, with a ore exitin exaple, naely howa Prolo datae an serve a resear tool for oelar ioloy, speially in

    the ontext of the an Genoe proet The pratality of Prolo for the sallexaple arries over to the lare and the athors sketh their datae desin andsoe of the iportant sses that arise when one is sin Poo for are dataes.

    The seond hapter also advoates the se of Proo a tool ths tie forthe opteraided desin of diital irits Speialy Preditor is desriedwhih is a pratial VLS AD syste There are two key advantaes laied ythe athor Peter Reintes The rst is the larity f he ode whih leads to itseier aintenane The Prolo version is an order of anitde saller than the

    onterpart The seond advantae is the extensiility of the tool de to theavailaility of Prolo for inferenin

    Copyrighted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    22/330

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    23/330

    mtod, spcialy for xprt systms.Finaly in tis introdction, I wold ik to acknoldg and tank t popl

    tat mad tis ook possi First and formost ar t ators of t captrsfor tir coopration and intrst in smling t ook. Witot tm trwod no ook Tis ook w prpard camra-rady copy sing TE X int Dpartmnt of omptr Enginring and Scinc at Wstrn RsrvUnivrsity. For logistic lp wit TE X, tanks ar d to rn Lakotia icalHowy Umit Yalcinalp and spcially Jwaar Bammi or is painstaking grapplingndd to wrstl wit t mystrios intractions o TE X icTX and t ITrss macros. or gnrally tanks to Trry Eling at IT rss for r patincand sris ditor Ed Sapiro for spporting tis ook. Tanks also to Frdrica

    Flanagan, Lynn stin and spcially arcy Sanford for tir gnral scrtarialspport.

    I concsion I op t applications ncorag radr to s rolog wn itwold lpfl. T idsprad s of roog is sil voping and t st programming tcniqs nd to com availal. I trst is ook is a contritionin tat dirction.

    Lon String

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    24/330

    Th Pactc of Polog

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    25/330

     

    Chapter 1

    Prototyping Databases in PrologToni Kazic

    Department of GeneticsWashington University School of Medicine

    St.Louis, MO 6310 USA

    Ewing Lusk, Robert Olson Ross Overbeek Seve ecke

    Mathematics and Computer Science ivisionArgonne National Labortory

    Argonne IL 60439, USA

    Abstract

    We discuss here sme f the iues that arise in designing databes and imple-

    menting them in Prlg The rst tw examples f databes fr a small videstre an fr a librar, are prente tutrial examples t illustrate sme f theiues in a simple cntext We then intrduce a ver real databe prblem, that fmaintaining the grwing bdy f genetic sequence data that is being mae availableby new labratr techniques in mlecular bil

    1 1 Inoducion

    One f the mt signicant pects fthe cmputer revlutin h been the cnceptf a databe the strage f infrmatin in a way that enhances ur abilit t use it atabes themselves are ld stne tablets The rst cmputerized databeswere at les little ierent frm the stne tablets except fr the cmputers abilityt stre them cmpactl and read them rapidl

    atabe technlg evlved swiftl riven b the rapid cmputerizatin f ex-isting manual datab during the 1970s First came the large sware systemscalle atabe Management Sstems BMSs These sstems ften requiredweeks f prgraming in a lwlevel language such COBOL, tgether with cn-

    sideable expertise in the language f sme particular BMS just t install a singlenew transactin tpe The are still in use

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    26/330

    2 Kic u ln verbee and uece

    Ba experence wth the system le t the sty atabes rm a mretheretcal stpnt Mst thery w evelpe n the cntext eltl

    atabes whch were mre abstrt than ther venrepenent preecessrEventally mplementatns the relatnal mel appeare ramatcally rec-ng the cst r creatng an acceng atab

    A greater level abstractn w neee hwever t ge the evelpment exble atabes that cl evlve beyn ther rnal prpses wtht majran expensve rerganatn The EttyRth{ER} Ach s ne the mre sccel meths rmlatng sel abstract mels By csngn the enttes an her relatnshps t strctre the way esgners apprachethe prblem creatng extensble atabes Graay the atabe cmmntybecame aware that the ER apprach w a pwer cnceptal tl an t becamethe key esgn a r atabes mplemente ner a we varety cmmercalyavalable systems Many esgners reae that the wrst mstakes were mae byalng t evelp an aeate vervew the ata t be acce an that makngthe mplementatn step sbstantally e clt c nt rectly are thsprblem The essental nee w t systematcaly escrbe the pects the wrlthat were t be mele by the atabe an t s wtht nclng any etals the mplementatn

    Relatnal atab have grwn raply n pplarty Hwever the crrent m-plementatns represent nly ne way t mplement a atabe relatns Prlgs a prgrammng langage that cntans wthn t the langage relatns Thecmplete langage allws even cmplex eres t be expresse cncsely t canths be se n a very rect way t mplement relatnal atabes Hwever ts stll necessary t begn wth an abstract mel that part the wrl abtwhch ne s tryng t manage ata

    In ths pape we escrbe a methlgy r esgnng atabes t begns wthan enttyrelatnshp mel prgresses n a straghtrwar way t a relatnalmel an cntnes n wth a translatn the relatnal mel nt Prlg Wewll begn wth a relatvely smple example n rer t llstrate the techne

    r mtves n ths artcle were nly t present a methlgy r atabesgn an mplementatn we wl then prgre t a mre cmplex applcatnthat wl be amlar t mt reaers Hwever anther mtve h nence rpresentatn: we beleve that lgc prgrammng h a namental rle t play nthe cmptatnal sppt mleclar blgsts an we wsh t encrage mem-bers the lgc prgrammng cmmnty t nvestgate ths partclar applcatn

    area Or rens r belevng that mleclar bl wll be an applcatn area partclar sgncance are llws

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    27/330

    Pyping Daab in Plg 3

    Breakthrughs in the technlg NA sequencing have prduced an immediate need t create and supprt a rapidl grwing databe

    The results eectivel string, maintaining, and using a bilgical databemight well prve critical t understanding exactl hw undamental mecha-nisms in the cell perate The ptential benets, bth in terms medicalapplicatins and in terms bic research, are immense

    Cputer users within the cmmunit bilgists have nt et cmmit-ted t specic cmputing envirnents and packages We believe that hgeneratin technlg can pla a useul rle in this particular area sci-ence, and the cnstructin an integrated databe represents ne bviuscntributin that can be made

    The prjects arising internatinall t map the human genme reprent ne the mt exciting erts in science the 20th centur

    Lgic prgramming ers an integratin databe technlg, highlevel prgramming, and lgic Mlecular bil is an applicatin area that will be drivenb a grwing, rapidl changing databe, and alread cmmands wide interest Ithgeneratin technlg h a rle t pla in the supprt science, this appli-catin is the place t demnstrate it

    Hence, we illustrate ur methdlg r databe design using an imprtantapplicatin r mlecular bilgists: the accumulatin and manageent datar mapping the genmes varius rganisms This prblem is presentl being

    apprached with cnventinal technlg Current bilgical datab exist inthe r at les r simple relatinal databs Attempts t rmulate anintegrated view are just emerging each the existing databes ers a vercircucribed view, with extremel limited abilities t search r integrate new rs data What is needed is an integratin the existing data int a single cnceptualramewrk, alng with a means eil extracting inrmatin rm it We believethat a prperl designed databe shuld be rapidl prttped in Prlg, andthat Prlg ers the quer capabilities required t supprt unpredictable requestsFinl because the riginal bilgical databs, while quite cmplex, will cntan

    a airl limited amunt data, we believe that the prttpe might well prvet be a useul prductin databe

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    28/330

    4 K, s, ln, vrk d u

    CU

    _

    ol r

     

    I

    L.

     

    Tp

    -

    Figur 1.1: A mple Moe

    1.2 Dsigning a Poog Daabas

    Prolog a ueu atabe mplementaton language but uch an mpementatonhoul onl be unertaken ater the atab proper egne In th ctonwe wll ecrbe an eectve egn proce an llutrate t wth a uton toa mple atabe probem In the next cton, we wl app th egn anmplementaton technue to a more compex example a atabe or a brarFnall, we wl coner a ute compex applcaton a atabe or mantannggenetc normaton

    11 raing h Eniy-Raionhip Mod

    Fo our rt example, we wl choo the atab that mght be reure to operatea mal veotape renta tore The tore nee to mantan ata on what tapt own t cutomer, an the rental o tap to cutomer The rt tep negnng the atabe to concentrate on the entte that the atab to kptrack o an how the relate to one another Th leve o the egn calle theEnttlatonhp Moel" In our exampe, the entte an relatonhp aregven n the norma ecrpton o the atab oun n the econ ntence oth paragraph Th atab w be about cutomer an tap an the entte

    are relate becau cutomer rent tap The atab wll mantan ata aboutthe two entte usomers an apes) an one reatonhp (nt) t oenuu to reprent th leve o a atab egn b a agram, n whch entte arereprente b rectangle an reatonhp b amon connecte to the enttethe relate S our moe look lke Fgure 11 Note that one mght later expanth atabe to kp track o more ata or example about the uppler romwhom the toe bu tap The bune ma expan llng tap to cutomera we a rentng them uture agram mght be a hown n Fgure 2 .

    I te orgna enttreatop moe one wt careu attenton to realor entte n the reatonhp ten one can expect t to be tabe a Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    29/330

    1 . Prttypn Databe n Pr 5

    Sir

    Comr T

    Figue : A Expae Mel

    el extee The ve stre a expa ts bsess r the at ata twats t mata bt (e hpes cster wll alas ret tapes Ol a ajr

    chage the bsess r the gals ts atabe l reqre a sbstatalchage t the ettrelatshp el

    1.22 Spefying he Relaiona Repreenaion

    Oce the verl abstract strctre a atabe h bee spece a ett-relatshp agram, the ext step s t ll mre etal b specg exactlwhch ata tes are t be cle the represetat each ett a eachreatshp These ata tems are calle the abue the ettes a relat-

    shps

    I r exaple let s sppse that all the ata we ee t kw r each tapes ts key (the qe etg mber r the tape, le a foa (VHS rBeta Nte that the ttle cat rve a ke beca the stre carres ltple

    cpes se tapes t s cveet t repret ths level etal r atabeesg b tables Fr the vetape ett the table h the llg strctre

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    30/330

    6 i u ln vebee and uece

    ae-d le fa3264 Raiders the t Ark VHS

    792 ET VHS3663 ET Beta

    Eac rw in the table reprents a single ae the entit in this ce aphsical tape The table r the umer entit might lk like this

    d ame he add234 Gerge Bates (32 7893423 72 First A venue

    Naperville, 605325678 Fred Jnes (85 7586757 234 Pleant Rad

    DeKalb I 605

    B cnventin the rst attribute the table is the keThe relatinship table includes the kes the entities being related tgether

    with attributes the relatinship itsel In ur ce suppse that all we want trecrd abut rentals is the date and whether r nt the tape h been returned

    ud ae-d dae eued234 3264 2//88 ntreturned

    234 3663 2/2/88 returned

    With the tables we have specied a relatinal representatin the databThis intermediate representatin the databe h mre detail than the entit-relatinship mdel and res veral decisins abut exactl what data will bemaintained in the databe et man implementatin decisins have been pst-pned allwing exibilit in implementatin

    12.3 Impemenaion Proog

    The prevus tw steps have laid the grundwrk r the implementatin Even ine were intending a nnPrlg implementatin the previus steps wuld still bethe apprpriate n Hwever it is particularl e t translate the relatinalreprentatin int Prlg since Prlg is a language relatins As a startingpint ne can ign a predicate t each entit and relatinship with an argumentr each attribute Thus ur Prlg datab wuld cntain:

    videoe (3264 'ders of e Los rk vs)

    Prlg als ers a particularl cnvenient means r representing a structuredattribute Fr eample the implementatin the umer entit might lk like

    Copyrighte Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    31/330

    Pototyping Datab n Polog

    cstomer( 234 ' George Bates ' teephone (32 789 3423)

    aess ( [ ' 72 First Av ' 'Site 7 ']

    'Iapervie ' ' L 60532»

    7

    Here the telephne number and address are reprented attributes with structure allwin sinicant subitems t be directl reerenced The use a list treprent a varin number unstructured lines in the addre is particuarl cn-venient Mst Pr sstems prvide builtin indein n the rst arument each predicate, s that sequential searches are avided much pssible whenthe rst arument is supplied Fr this ren the ke ed ccurs rst in ur Prlpredicates

    Once a Prl representatin the data eists there are a number was tsupprt queries

    . The simplest is t just have the user rmulate queries in Prl Fr thsewith a backrund in lic prrammin, this is bth natural and cnvenient

    2. In situatins in which ne can ei dene the cles queries t be supprted denin the Pr rutines t impement such custmzed acce is

    nrmall straihtrward3 Occinall, it makes nse t er natural anuae interaces t datab

    4 Fina, it is pibe t supprt a number structured quer lanuaes (mtntabl SQL in the Prl envirnment

    The best apprach depends n wh uses the datab hw ten the use it andhw man resurc can be epended t supprt quer capabilit

    The inventin relatinal databes represented a majr step rwards It al-lwed a particuarl natural representatin data ( tabes, and permitted anumber quer lanua t be invented There als arse a bd researchrelatin t nrmal rms r relatinal databes This wrk centered n deriv-in the crrect reatinal representatin a set attributes iven the attributesand unctinal dependencies amn attributes n retrspect it appears i theal w t autmaticall determine what entities and relatinships were beinrepresented Such a tk is quite dicult and it h prduced an enrmus num-ber hihl technical resear papers n ur pinin, these papers are are

    irrelevant t the actual a implementin welldesined databes althuhthe use nrmal rms des prvide ne means veriin a databe desin

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    32/330

    8 Kc n verbee and uece

    A good enttyelatonshp model oes the bt st step to a popely nomal

    ed elatonal mplementaton, and the best way to acque such an ER-model s

    though dscussons wth people famla wth the applcaton area The advantagof databes n nomal fom, namely the abnce of the deaded "update anoma

    les , accue natually to databes n whch enttes and elatonshps have been

    accuately dented

    .3 A Mor Avac Exampl

    Ou pevous example w a bt too smple to be ealstc even fo a small vdeo

    stoe As a next step towad a ealstic applcaton, we descbe n ths secton albay databe t shaes seveal concepts wth the vdeo stoe example, but hee

    we wll attempt to esh out the model a bt moe, whle followng pecsely the

    same methodology befoe

    131 An Eny-eonshp Mode for brry

    We wll stll make seveal smplfyng sumptons We attempt here to model only

    the pat of a lbay's actvtes havng to do wth loanng books to us of the

    lbay We also sume that the tems that the lbay deals wth ae books, thoughn pactce a lbay mght also loan out maganes, audo and vdeo tapes, lms,

    ecods, and vaous knds of equpment. t should be ey to genealze fom the

    dscusson gven hee

    It s mmedately obvous that two pmay enttes wll be e of the lbay andbk A lttle eecton emnds us that lbaes cay multple copes of books,and that the ndvdua copes, whch ae the enttes checked out to uses, ae not

    the same thngs the books epesented n the cad catalog Fo example, a

    use may equest that a book be eseved fo hm, but he does not cae whch copy

    he gets Ths leads us to consde two sepaate enttes: bk wth attbutes shaedby all copes of the same book, and y wth attbutes of the ndvdual copyThe enttes wll be elated by the bk/y elatonshp. t wll be necsayto acce the bk enttes n a vaety of ways besdes the unque dentngefeence numbes by autho, ttle, subject, and pehaps a lst of keywods The

    est of the ER dagam s shown n gue 3 f a use eseves a book, a equeelatonshp s ceated, lnkng the u to the book not to an ndvdual copyWhen he checks out a copy, a lan elatonshp node s ceated, contanng the date

    the copy s due f the use fals to etun t on tme, a ne node s ceated, elatedto the use by an we elatonshp and to the copy by the f elatonshp

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    33/330

    1 . ototypin Datab n oo

    Fiur 13: Lbrar ER Dagram

    132 Th Rlaional Rprnaion for h ibrary ab

    9

    The ex sep s o l ou he relaoal repreao b specg he arbueso each e ad relaoshp Oe se o choces s represeed Table . Theelds represeg he kes are aczed Srucured daa mgh be used or heuser address ad phoe, he vdeo sore example A reoable choce or heopynm s a par cossg o he refnm o he book deg he book ada uece umber deg he cop For example he opynm or he hrdcop o Semrops mgh be

    copyn ( QA 774 R4 3)

    s ha he represeao o he cop l would be

    copy(copyn( QA 774 R4 3) ' Science Reing Room )

    Aoher pe o srucured daa mgh be used or he ls o auhors ad ls o

    kewords ocaed wh a book We wll dscuss laer he opo o reag heauhors ad kewords parae ees

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    34/330

    0

    Etty

    bkusercpye

    eltspreuestles

    rbk/cpy

    Kc uk, n, veeek n uecke

    Attrbutes

    efnm ttle utrlst publser keyrdsem, me pe ddressopynm, lctjnenm, mut sttus (pd r upd

    Attrbutesefnm, enm, dteem, opynm, dte l dte dueem, nenm

    jnenm opynmefnm, opynm

    Tbe 1.1: Attrbutes r Lbrry Dtbe

    13.3 mpemening he iby be in Poog

    e rl mplemett mt te lbrry dtbe des s r te mtprt strtrrd te vde stre emple Hever te brr dtbeprvdes sett c severl e ues c be dscussed

    Impemenion of Eniie d eionhip e mt strtrrdpprc t trslt E mdel t rl dtbe mplemett s tee e lled te vde stre emple Ec de te E mdel becmes tble te reltl represett d te ec tble becmes rlpredcte te rl reprett s etete reltsp s

    ppelly smple but te perrmce te dtb c be mprved by teddt sme e rl predctes d te elmt ters

    Fr emple te smplemded trslt te lbrry dtbe E mdet rl uld prduce opyoook predcte t mplemet te book/opy rel-tsp Sce ur reltl mdel cludes dt cted t stce ts reltsp te ly rumets te opyoook predcte uld be te key te book etty (reum d te key te opy etty (cpyum e cse te opynm structure ct te bk's efnm, te te predcte s

    redudt: e c redly cce te cp bk ve ts efnm d ccesste bk ve ts opynm

    Copyrihte Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    35/330

    Pototyping Datab n Polog

    Aux Ae Sruure commo addi io is he icusio o exra predica o suppor ecie acce o he coes o he daab s a exampe

    cosider ookig up a book by oe o is auhors I is oibe o do his by wriighe query i Proog ike his:

    lookupauhor(Auhor Refn) -

    ook (Refnum Tile Auhorlis Keyordlis uisher) memer( Auhor Auhorlis)

    his predicae is caed wih he Auhor ariabe isaiaed o a gie ame buwih Refn uisaiaed i reurs he rs book wrie by he gie auhor

    ad o backrackig reurs a he oher books by ha auhor hus do whawe require bu does s ery ieciey sice i examies each book i he eiredaab. O he oher had i we icude a iersio" predicae

    lookupauhor(AuhorRefn)

    i our daabe he sadard Proog idexig o he rs argume proides uswih rapid acce o books by a gie auhor oe ha higheree queries whichmay ca he lookupauhor predicae eed o be aare o he impemeaio

    simiar iersio predicae woud be appropriae or keywordsI is worh oig ha he idex o auhors migh hae arise ia he sraigh-

    orward approach i we had reaed auhors eiies The he lookupauhorpredicae woud be he rasaio o he reaioship bew auhors ad heirbooks We choose o o ook a he auhor idex i his way because we are osorig ay aribues o auhors ad he approach seems ar ess aura i hece o say keywords Thereore we preer i his exampe o rea boh auhorsad keywords aribues o he book eiy.

    We ca ow dee he predicaes ha wi make up our ibrary daabe

    ook(RefnTie Auhoris uisher Keyordis )

    user(Usern e Address hone) copy( Copynum Locaion)

    fine(Finen Amo Saus )

    reques (Refn Usern Dae) lo(Use Copyn Lodae Daedue)

    owes(Use Finen) for(Finen Copynum)

    Copyrighted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    36/330

    12 Kazi, Lusk lson veeek an Tueke

    To illsrae he le o his approah we osider some sample qeries hawold e ey o express direly i Prolog:

    Wha ooks are heked o o r 2

    Wha ooks o iolo h Lsk ee ned or

    Wha rs hae heked o ooks o Aria arheolo i he l woyears

    1.4 A Dtbse to Suppot Moleul Bology

    ow we osider a more ssaial appliaio o he ide ha we hae eedisssig I his seio we wish o explore he prolem o reaig a daaeo sppor resear i molear iolo Or ie here is o o oer a ompleepreseaio o he ies ioled i he desig o ioloal daaes ideed hisis a area i whh ssaial resores are ow eig osed ad he es arear rom sraighorward oweer he ehiqes ha we ae e disssig doorm he odaio or examiig he relea ies ad we eliee he aea ae sed eeiely or prposes o illsraio

    1.4.1 New Probems ompuaional Bioogy

    We will egi his seio y oerig some relea pes o molelar ioloOr reame will e eessarily rie We will o aemp o oer a re ioloorial raher we will smmarize a miimal mer o oeps o allow hereader o ollow or disssio

    ppose ha yo were gie a disk drie ha oaied he operaig sysemad daa rom a alos omper Frher sppo ha i yo dersd howhe mahie ad he operaig sysem aally worked yo migh well hae hekeys o kowledge o iredile ale To properly moiae yor eor spposeha i appears ha yo wold ge keys o dersadig lie isel (mimally yowill e ale o re aer AD ad he ommo old oweer all yo haeis a disk drie ad he ailiy (wih a lo o eor o exra haraer seqeesrom he drie Yo do o kow he isrio se o he mahie or how ayo he algorihms implemeed o he mahie work. Howeer yo do kow haersios o he mahie aally do work ad oioally yo hae glimps o aoperaig mahie

    ppose ha yo hae already spe a ew years lookig a he prolem oeexraed a ew seqees rom a mer o spos o he disk ad hey seem

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    37/330

    1 Prototpig Datas i Prolog 13

    o come seer dere ypes I you mgh be ary sure ha somequeces corresd o progra. You hae ee ocaed he drecory where a

    o he operag sysem resdes Oher reds seem o be abe o recogze hesar o subroues I a ew ces hey ee kow wha he uco o some ohe roues mus be ahough hey usuay do' udersad how he acua codeo he mhe reaes o mpemeg he uco.

    Furher suppose ha a breakhrough occurs how o read queces rom hedsk so ha a o a sudde you ca sar ookg a a much arger sampg oqueces Oe o your more spred reds grpg he sgcace o progresso dae proposes ha eams cooperae o erac a o he sequeces rom he

    dsk. The k w be epese (hudreds o mos o doars w be requred)ad me cosumg ( w probaby ake 10-15 years) I s o ee cear hayou coud accuraey erpre he daa bu woud ceray ae a argescaeeor o reay e he probem

    The pece o deece work requred o urae he meag o he ecodedprogra woud ceray ake a subsaa eor The rs par o he eorwoud be o sar producg a compee o characers rom he dsk The secodpar woud be o gaher ad coordae sghs researers rom aroud heword sudy dere pecs o he probem Ths suao s may ways

    aaogous o ha acg moecuar boogss.Raher ha sequeces rom a compuer dsk boogss hae acqured he aby

    o read he geec sequeces ha specy he acy o g ces. DA s achemca ecodg o geec ormao I s bed o he 4characer aphabea, The geec ormao abou a per s ecoded og srgs o charac-ers rom hs ery med aphabe. These srgs coey srucos or budga o he arey o mechasms requred o me he orgasm uco properyome smpe orgaisms coa oy a sge arge moecue o DNA Howeer

    more compe orgasms each ce coas a umber o moecues; each o he scaed a hrmme A huma ce h 46 chromomes. The ere compemeo geec maera he se o chromomes o a parcuar orgasm s deed s eme" [Ass88] A oa o abou 3 109 characers make up he geome or ahum beg.

    Oer he e years subsaa echca adaces hae reduced he cos odeermg he sequeces o characers secos o DA. Esseay boogsshae deeoped a echoogy or cug up he chromomes ad he deermghe eac sequece o characers hese peces I eough oerappg peces o

    DA are sequeced he compee sequece o he orga chromome ca bedeermed o oy ca boogss ow do such hgs (whch se s amaz

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    38/330

    14 Kic ln, vb an

    ig) bu hey ca do i airy cheapy Hece he surge o ewyaaiabe daarepreig DA quec.

    Whe bioogiss decide o quece a eire geome hey parae he kio quecig each o e disic cromomes a make up e geome Theor each cromome hey cosruc a physal map y echiques we beyodhis discussio hey deermie a ordered quece o shor srigs Sl S2 S3, " Sn(caed retcto te) ha occur wihi e chromome (wih age ieraso ukow characers bewee he resricio si) Furhermore, hey are abeo esimae someimes ery accuraey, he umber o ukow characers haoccur bewee he resricio si. The he probem o sequecig he geome ispariioed io a se o smaer probemsig i he ukow ragmes.

    Occioay muipe maps o he same chromome may exis he c,i may be possibe o orm a more deaied composie map. he process, mkow sequec o D A ca be iged o oe o he smaer ukow regos. Iohers, he exac iera coaiig a specic quece o DA may be uow(eg. i migh oy be poibe o sae ha e quece occurs somewhere wihihree coiguous ragmes)

    To acuay deermie he sequece o a rae biooss ake may copio i chop hem io smaer ragmes ha ca be sequeced, ad he ook or

    oeraps i he shor queces o recosruc he sequece or he origa ogeragme The mehods used o sembe he quece o a ukow par o aresricio map ca i pricipe be scaed up o aow embig he sequece o aeire chromome This aows oe o aoid he iermediae sep o mappig hechromome urrey such a approach (caed hot eqe) is pracicaoy or airy sma chromomes

    A daabe or maagig he accumuaio o iormaio abou he sequecha make up a geome mus be abe o accuraey represe a e maps resric-io si ad kow sequeces

    The secod par o he daabe probem is o record kowedge abou he mea-ig o he sequeces This is irisicay a ar more compex probem, sice hesrucure impod o he daa by ecessiy reecs oy he curre udersadigThis wi chage radicay ew isighs occur, poiby causig major resrucur-ig o a e secios o he ierpreaio

    Aready a grea dea is kow beyod jus quec o DA We kow hacios o DA are copied io srigs i a secod aphabe (RA) , which are heused o buid proeis (which are srigs i ye a hird aphabe) Much o he acua

    ucio o he ce is achieed by ieracios bewee proeis Our kowedge isicrediby skechy i some ces, he exac mechais are we udersd whie

    Copyrighted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    39/330

    Prototpig Datas i Prolog 5

    i others oy the aguest theories exist. I short we are i the iitia stages ofthis mt icredibe piece of detectie work

    42 Level of ata

    Oer the ext 35 years there wi be a major eort to orgaize the data beigaccumuated by the bioogists Much of this data corresds to queces of DA .Ways must be foud to merge the output of umerous abs ito a cosistet resourcefrom which iformatio ca be eiy extracted o uderstad exacty how thismight occur it is usefu to thik of the data i at et two subdiisios

    . We wi ca the data reatig directy to maagemet of the kow DA

    sequece data the oe data. his pect of the databe is required justto keep track of which sectios of distict geomes hae successfuy beedetermied

    2. A far more compex category of data reates to iterpretatio of iformatioecoded i geomes. he data wi be required to estabish a computatioaframework to support the eorts of bioogists they graduay urae thesecrets stored i DA.

    Figure .4 depicts a Etityatioship mode for the core data.A brief descriptio of a miima reatioa represetatio of the core data show iFigure .4 woud be foows.

    genome A geome is the set of chromomes for some particuar orgasm hegeome for a simpe bacterium cotais a sige chromome whie a humageome icudes 46 chromomes. Here we use the term geome to refer toa abstrtio the coectio of sequece iformatio for a type of orgaism(rather tha the queces for a specic idiidua of that type . hus we

    speak of the geome of E ol , rather tha the geome of a specic straiof E ol We wi represet a geome by the reatio

    genoe(Orgis)

    Orgism is the uique idetier of a species for which sequece data is beigmaitaied.

    For exampe

    genome (ecoi)

    train For ay specic orgaism quec from mutipe strais must be maagedwithi the sige eoig datab. We represet such strais by the reatio

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    40/330

    6 Kazic Lsk Olso Oveeek an Tecke

    Figure 1.4: ore Daa ER Dagram

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    41/330

    . Pooing Daaes in Poog

    srain(Orgis Srain)

    Srain uiquey ideies oe o a se o srais or a gie orgaism. Forexampe

    srain( ecoi g655)

    hromoome Physicay, a chromome is a sige moecue o DNA Here, we usehe erm absracy. For exampe , we wi speak o he he E cl chromsome , ad by ha we wi reer o wha is kow abou he E cl chrmome o he sequece o he DNA rom a specic srai Here we wi

    represe he chromome bychroosoe (Organis Chroosoe)

    Chroosoe uiquey desigaes he DNA moecue or he paricuar or-gaism. For exampe, chromome 9 migh be used o desigae which ohe huma chromomes w beig represeed

    For exampe,

    chroosoe( ecoi coi chroosoe )

    phyia map A physica map is he ordered is o resricio sies o a chromsome or par o a chromome. is deed oows:

    physicaap( hysMap Orgis Chroosoe)

    hysMap is a uique ideier. For exampe,

    physicaap(koha ecoi coi chroosoe )

    phyial map fragmen A physica map is bui rom a ordered se o physicamap ragmes, each o approximaey deermied egh ad coaiig aporio o he ordered is o resricio sies. We represe a map ragme

    apragen(Fraen MinLengh MLengh)

    The owes ee o a physica map is a is o such ragmes. The reaioshipo physica map ragmes o he map is impemeed wih

    frageninap(hysMap Fragen osiionber)

    For ay secio o he physica map, oe ca dee oerappig ses o mapragmes. The reaioship bewee physica map ragmes is gie by

    fragencopose_of(Fragen . osiionNber Fragen2)

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    42/330

    18 Ki Lusk l veeek ad Tueke

    Oe u of he physica map is o keep rack of which are of a chromme hae kow quece aues. Durig he iiia sag of a quecig

    projec here are ery few kow quec daa become aaiabe heyare ped o he map ad he eire chromome is graduay ed i Whea quece ca be accuraey ociaed wih a map fragme i is doe wih his reaioship

    sequenceirgment(rent Sequence)

    For exampe suppose we kow a secio of he physica map ad ha sequece 88 occurs somewhere i his regio We represe his iformaio show beow. The mapframe eiies is each fragme i he order i

    appears o he map; he fameomposeoreaios gie he is of ear-es eighbor reaioships; ad he sequeeframe reaioships peeach kow quece o he map.

    For exampe suppose ha we had a cio of he map i which he foowigw kow:

    gtct tcg gtct

    Furher suppo ha we kow ha sequece 88 occurs somewhere i hisregio We woud propose o represe his

    mprent ( 6 6 ) mpfrent (2 780 790) mpfrent (3 5 5) mpfrent (4 540 620) mpfrent (5 6 6 ) mpfrent (6 3337 3427) frgmentcomposeof ( 6 ) frgmentcomposeof (6 2 2) frgment_composeof (6 3 3) rentcomposeof (6 4 4) rgmentcomseof (6 5 5 ) sequenceinfrgment ( 74 ) Y seq 74 is gtctsequenceinrgment(3 748) Y seq 748 is ggtcgsequenceinrgment (5 743) Y seq 743 is gggtctsequenceinrgment (6 878 )

    NA sequence A sequece of DA is a srig i he aphabe acg . uchsrigs wi be kep i wo disic forms. Oe represes a sequece acuay

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    43/330

    1 Prototpig Dtbs i Polog 9

    repored from a bioogica aboraory whie he cod repres a composiequece formed from a se of shorer quec The composie sequec

    are frequey caed irua sequec" We repre hese wo disicyp of queces wih he he same reaio

    sequence (Sequence Sring)

    The coecio bewee a irua quece ad he shor queces fromwhich i is composed wi be represeed by a reaioship of he form

    viruaromshor (Vi Vposiion Shor Shoros Lngh)

    For eampe

    sequence( 326 [a c a aJ ) sequence( 327 [a a g c g c ] )

    sequence(328 [ a a g c g c ] )

    viruafromshor ( 328 0 326 2 4) viruafromshort ( 328 0 . 327 2 . )

    Y shor squnceY shor squnceY irua sq

    The reaioship bewee srais ad quec is impemeed

    srainequence(Orgism. Srain Sequence) equecig proecs wi sar producig msie amous of daa oer he com-

    ig years The core daabe ha we hae described ca be used o record progreHoweer i does o adequaey srucure he daa o make i ruy usefu o biogiss To udersad wha we mea suppo ha you were aware of a magicebuepri of a woderfu oce buidig Furher suppose ha you coud paisakigy gai acc o sma pieces of he compee buepri The core daabewoud corresd o recordig eacy wha pieces had bee acquired ad which

    were si missig woud say ohig abou he coes of he pieces ha hadbee acquired I reaiy you woud be ieresed i he secios of he documeha described compee subuis The whie spaces bewee descripios wouded o be igored ecep hey aowed you o embe he compee picure

    geome is simiar o such a buepri The secios ha describe compeefucioa uis are caed ge iig ce is a amazigy compe eirome i which chemica reios susai ife s ew subsaces are requiredsecios of he buepri are used o goer heir maufacure much he way hebuepri of a buidig woud be used o guide he cosrucio of specic sec-

    ios Ideed here are ie machies i each ce ha are used o maufacuremoecues caed proeis The buepri icud deaied isrucios o how o

    Copyrighted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    44/330

    20 Kic Lusk n veeek n Tuk

    mufue eey pe eued mi he exsee f he e we sus hw ud he e sef Lfe s sused y hemi es

    h eue he pes mufued dg he uep. Seuees fsuh ecs ed pathway e used sfm eegy d mes usefu f. Udesdg exy hw hese phwys sus fe d hw heuep supps he es f hese phwys s e f he m exgse gs f mde gy

    F de e usefu mde gss mus ed me h jushe w seuee d I mus s ude fm eg he geesepeseed y suh d he hem ecs yzed y hse gee pdusd he e phwys h emdy he y f fe s hs dd suue h epeses fm esue f e uy he gsThe ER dgm shw Fgue 5 mpses mm es f hs ddsuue

    A skeh f he dd ees wud g fws

    gene A gee s se f he uep (e. hmsme h deses sge fu u. We w epese gee wh he e

    gene (Gene ReOTeGene)

    We w eed me es dese exy whe he gee s used (hs ude wh ds he gee s expessed" dd muh f he fm u he gee s eyed s eshps heees The gee s emded pu se f gsm (e g sge E col e seuee f DA Hwee ds ddus mghhe sghy eed ess f he gee due mus Hee whe weee he ey gee u DA uees we mus ed he se fkw s. Eh s ed ee" The m m

    es s ed he wd ype ee" We epese hs eshp f hegee seuee d wh

    geneaee(GeneSeueneWiType

    WiType w e ue" fse" If he ps f he gee physmp s kw he

    genepysicaap( Gene yap Lain)

    s used ed he d.

    gene fetur A gee ke se f uep my e mpsed f suusI he e f uep he desp f sge m wud ude

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    45/330

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    46/330

    22 c, k lo vereek an Teke

    door, wdow, ad mouldg. lar, a gee h ubu ha pladc rol The ubu we call gee feaure . Thee ae umeou

    p of ubu , he deal of whc go beod he cope of h dcuo We wll epe uch feaure w

    geneeature (Gene Feate RoeOfeFeatre )

    ad coec o allel wh

    geneeatureee(ene Feature Seuence iType)

    gn aiy Occoall daa ae ocaed wh a e of gee Th ca occuwhe gee are elaed o each oher me wa For eample ome gee ae

    alwa ured o a group ohe ce, eeaer have hpohezedha veral gee ae lkel o have evolved fom a commo aceo Toepre uch e, we u

    geneiy (GeneFiy TypeOf Set)

    ad he relaohp

    geneingeneiy(Gene eneFiy)

    ocu Sce he ee fucog of he cell deped o eaco bewee

    dere p of molecule DNA molecule RNA molecule, poe, ec. ,we wll eed o clude daa decrbg he molecule. The level of epreeao ca be fal abac o ca go o a mrad of deal almplemeao wll clude a fal mode amou of deal, whle eeachover he e eve decad wll be reured o ll fomao abou herucure ad fuco of ma of he molecule

    ration Whe bolog peak of he fuco of a gee , he ormall meahe role ha he produc produced fom he gee pla chemcal reo

    ormou amou of daa e decrbg eacl how dee moleculeerac ude peced codo For ow, we wll hk of a eo occurg bewee fou cle of molecule ubae, poduc ezme,ad eecor The mmal daa ha we eed o ecode clude

    reaction(ReactionKineticetersTheoynicareters)

    ad he elaohp

    moecueineaction(oecue Reaction RoeType)

    ration pathway A eaco pahwa a e of eaco ha ogeher aevewed a group We repee uch pahwa wh

    Copyrighte Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    47/330

    1 Prototypng atab in Prolog

    pathay (Path escipt ionOfFct ion

    ineticPeters TheoynicPeters )

    and

    pathayeactin(Path Reaction , Reactin2)

    23

    where we view the pathwa a set of "c onneting the dierent reactionsthat partiipate in the proess

    inkage ap A good idea of the position of genes on a hromome an be deter-mined through indiret merements. In partiular, biologists have arefllstudied reombination freuenies to determine whih genes or in loproimit This information h been used to onstrut linage maps Thebi data in suh maps an be represented with

    iage�ap(LinkageMap Orgism omose Resoution)

    and the relationship

    geneoinkage�ap(GeneLinkageMapLcation)

    In this short desription we have indiated how one might begin to onstruta databe to support geneti resear. Over the net two to four years inte-grated databes enomping the omponents that we have desribed will bemade The will form the starting point for research that will tae plae overdead Our goal h not been to oer a omplete design bt rather to suggestan approah towards produing sh a design.

    4 Ipeenting the Database

    The entityrelationship diagram given above reprents a fairy limited set of dataitems that, put into a single oherent framework, wold represent a signiant set

    to urrentl pratiing moleular biologists. This original databe wold then beepanded (both in term of the nmber of ourrenes of the original entities andthe nmber of dierent lses of entities) ogi programming oers a onvenientvehile for imposing a oherent representation It is our hope that suh a platformwill oer the following benets

    It oers a reprentation that is ompletel independent of an spei databeimplementation t is a straightforward tk to translate eisting sores ofdata into standard Prolog format from their present representations (whih

    range from harater ardimage les to relational databes in a varietof ommerial sstems)

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    48/330

    24 Ki, Lusk On Overbeek and eke

    I s val o we small Polog oga o cove secos of he daabo whaeve foma s eued b aoe usg aohe eeseao.

    I ovd a mavelous famewok fo logc ogammg advocaes o sudoe of he m eesg alcaos of comues mode scece.

    Thee ae hee ceal ues ha mus be addeed a eoable fho fosuch a mlemeao o be of u

    I mus be oble o oe eoable deg o he edcaes ha mle-me he elaoal vew ha s smle sagme deg whch soeed b m Polog ssems s adeuae.

    I mus be oble o solae he u of such a daabe fom chages such eedg he se of abues socaed wh a e o ag ewees.

    • I mus be oble o o o a commecall avalable Polog ssem has caable of maagg he amou of aw daa ha cuel ess

    The l wo os ca be adeuael hadled b eu ha ae wellkow

    wh he logc ogammg commu ad he s o ca be sasfacoladded a of veal was.

    Indxing on Mutip Argumnts Accs o daabes feuel eues eable dscmao o ohe ha he s agume adad daabe ss-es ae omall mlemeed b ceag vesos o ohe abues. Theseca el be mlemeed wh Polog Fo eamle, suose ha he elaoeqeeframet s mlemeed

    sequeneinfraent(raent Sequene)

    Fo eamle

    mgh be used o sae ha seuece 48 occus ma fagme 2 We mghve well have o acce uees of he fom

    1- sequeneinfraent(2 Seq)

    whch wll wok well usg sagume deg. O he ohe had, we eed oalso suo uees lke

    Copyrighted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    49/330

    1. Prototyping Data in Poog 25

    1- seqence_fraentFraent , 1748)

    whih would be ud o loae fragmes ha oai sequee 748. This is eildoe b deig equee_i_framet/2

    seqencefraent Fraent ,Seqence) ' -noFraent) >

    seqencenfraent_ataFraentSequence)

    ) . 

    nonSequence) >sequence_in_fraent_inexSequenceraent)

    sequence_n_fraent_ataFraen Sequence))

    where sequee_iframeLdata/2 onais he fs ha represen he relaioad sequee_i_frameLidex/2 is a impemeaion of he inversio o he se-od aribue A sligh modiaio o his ode would work eiel for es iwhih he relaioship iluded aribues oher ha he kes of he relaed eniiesI good Prolog implemeaions he above ode will no generae an ueearhoie poins ad i does oer adequae disrimiaion for our purposes.

    Isolating th U o Changs n th Databas Oe aor oern f-ig aone wriig fware ha mus ae daa from a daabe is o isolaehe soware from hang in he sruure of he daabe This beoes a majoroer whe a subsaial ivme is required o produe and aiain he sof-ware The maor sruural hages ha are required for a daabe ivolve addig

    more relaios (due o addig more eniies ad relaioships) or adding aribueso eisig relaios (due o a desire o epad he daa soiaed wih eiiesad relaioships) In almos a reonable daabe ssem he inroduion ofew eiies ad relaioships is sraighforward. I ma require soe eor b adaabe admiisraor o auall load he ew daa iems ino he daabe buha is required i a eve . The addiion of ew relaios o he daabe shouldo produe hages i user soware

    Oioall i wil be nesar o suppor new aribues for eisig eiiesad relaioships. One ould alwas avoid suh a hage b inroduig a ew

    reaio ha would oai onl he required ke alog wih he added aribues.This is a praial approah i m . O he oher had give a Prolog

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    50/330

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    51/330

    Prototyping atab in Poog

    bookRefn Tite Athorist Pbisher eyworist ) by

    book_tite Refn Tite) bookathors Refn thorist )

    bookpbisherRefn Pbisher)

    book_keyworsRefn eyworist)

    27

    Th eve ee o add ew abue o a e o elaohp eo eg ode wll have o be oded. The o he eed ze of hedaabe.

    upprtg th Rqrd Vu Whle he powe ad elegae of log pgag have bee wdel aeped hee h bee oe oe abou wheheo o Polog pleeao of daab ae paal. A ube of pohould be ade h egad

    • a eg daabe a be el hadled b eg oeal pleeao of Polog. Whle eoou daabe oad a gea dealof aeo he v ao of daab ae of ode ze. Fo eaple

    ode a peoel daabe wha peeage of opae have ove1000 eploee? I fa eg oal e ug o woko (whh a hold a le 3264 egabe of eo fo a elavelode pe) a uppo ao ae well above oe oveoaldkbed e.

    • I he ho age he abl o efe oeal Polog o eg eloal daabe e oe a paal wa o hadle uba daabe

    • The fwae develope fo eve fal all e feuel ake plaeove 5 ea . I uh a oe oe aep hould be ade o dguhue lao fo lao Tha I Polog allee a daabe age? Ou belef ha log pogagwll a fal ho e beoe a doa hee wh he daabeou ( alead oad fa oe aeo ha people would havehough poble eve 5 ea ago) ee pleeao wll ake leaha lao ae o f

    al we would lke o po ou oe paulal val appoah ha haowed u o epeeall hadle fal lage aou of gee daa. I he

    Copyrighted Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    52/330

    8 K, Lusk Oson Oveeek and eke

    ce of geeic daa uch of he acual orage pace i coued b log uec(or e coe relaig o he euec) while cople uere are bed o

    oher aribue. For eaple, he uerApproiael wha peceage of chrooe 14 for hua h beeueced?

    reuire a fairl cople copuaio accig daa fro a uber of eiie adrelaiohip do o however reuire accig he acual rig of kowA euec (uig he legh of uch rig are kow wihou eaiighe acual characer i he rig) . We have ipleeed a predicae

    extealstorage (ListOfAtomicEements Ref)

    ha i called wih eacl oe argue iaiaed Whe called wih he rargue iaiaed o a li of aoic daa ies, i copie he io eeraleor (i our ipleeaio oo a dik le) ad bid he ecod argueo a ieger ha ac a referece o he daa O he oher had, whe calledwih he cod argue iaiaed, i recoruc he lis ad bid he rarge.

    We repre he ei eesequee uig wo relaioe coaiig all

    aribue ecep he acual rig of characer ad a ecod ha acc herig. For eaple,

    seqece(SeqeceString) ' -sequenceata(Sequence tr) exteal_storage(String tr)

    whee sequeedaa/2 i a relaio coruced whe he daabe i oaded Thirivial echiue i eil ipleeed o coercia Prolog e uig

    a C ierfe ad i provid he reuired capaci wihou ipacig he uerfware he uer eed o be aware ha a predicae like sequeedaa/2 h bdeed)

    15 Summary

    I hi brief uorial we have preed a ehodolog for ipleeig daabeiall we advocae

    • begi b developig a eirelaiohip diagra ha eablihe he overlucre of he daab,

    Copyrighte Material

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    53/330

    Prototyping atab in oog 29

    • ll i the detls by costructig a relatioal reprentatio of the etitiesand elationships and

    • ileet the elatioal eprentatio i Prolog

    I addition we have aged that the cet developents in olecla biolomake it an ideal application area to deostrate the utility of this approach Webelieve that the systes that evolve in molecula biolo over the next few yeaswill include nueous entities and, perhaps, hundreds of relations. Attempts tofoulate a coherent view of the growing s of information repreent one ofthe mt interting probles in the eld of datab desig Succs ould oe a

    fameork to adde the truly fundaental iues no being invtigated by biolgists We believe that logic pograing ill ultiately play an instrumental olein this developing invtigation. Only time ill tell hether or not our mentis accuate

    16 Background

    We rge the reade to ead e of the bette guides available. n paticular wehighly recoend the folloing four sourc:

    1 . The Caoo Guide o Geeis [GW83] by Larry Gonick and Mark Whlisis one of the bt pieces of tutorial iting available t covers an aazingaout of aterial in an etemely pleat format

    . "s the Genetic Code Arbitray? by Dougl Hofstadte appears in the bookMeamagial Themas [Ho5], a collectio of Hofstadte's aticl t is abeatiful suay of hat is meant by "the genetic code .

    3. Chapter XVI in Godel Esher Bah [Ho9 by Dougl Hofstadter containsa slightly ore coplete epition

    4. "Mapping Our Gees is a epot that w prepared for Congs by the Oceof Techolo Assent [Ass88 t cotas a good tutoial that covesies relatig diectly to "apping the h geoe It also incldiforatio elatig to the sigicace of the current geetics projects

    Copyrighted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    54/330

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    55/330

    32 Peter . inj

    • Ipleetig a bic CAD capabilit i a logic prograig eviroet createa olid foudatio for ore advaced ork i telliget CAD

    The t coo critici of ftare developed i Prolog i the perforacepealt paid for thi level of abtractio Hoever advace i Proog copilatiotogether ith the eergece of high-perforace orktatio have ade e ofthe arguet oblete Athough oe CAD algorith ru etee ad 4tie loer tha their couterpart i C the iteractive repo of the editor icoparale to a iil progra ritte i C

    . Overvew

    221 Dsign Rprsnaion

    The rt copoet of thi Proogbed VLS CAD te i a ulti-ligualtralator for hardare decriptio laguage Thi traator ca exit either the tad-aloe progra AUNT A versal Netst aslator) or the databupport ub-te of PREDTOR AUNT curret uppot readig ad ritigcircuit decriptio i eight laguage Thi talatio i achieved cotructiga coo logical for fro the circuit decriptio

    With AUNT the laguage hadig ub-te of Preditor a iue ofdeig repreetatio ad iterchage forat ca e igored the deiger Thecoo forat the Logical For Laguage LFL arrived at epiricall TheLFL i ipl the t of Prolog ter required to repreet all iforatio i theuperet of the upported hardare decriptio laguage A upport for dieretlaguage i added the LFL a be odied to accoodate e feature Becaue the editig te operate ol o the LFL buit the AUNT ubteit i lagel idepedet of a pecic circuit decriptio aguage

    The datab i cotructed of pritive ter repreetig electroic copet ad collectio of thee copoet hich for coplex circuit or ells.Coplex hierarchical circuit are deed treatig other iper circuit copoet Thu a digita iverter circuit cotai trator, ie ad cotactpritive do a traiio gate circuit A hi-regiter circuit cotaiistaes of iverter ad traiio gate circuit u-circuit

    The folloig ter repreet the trator ire ad cotact copoet

    TRASSTOR

    RECOECTO

    r(eTypeoinMosSGDEx)

    ire (e Layer Wih Lis e Ex )conac (e Type oin Mos e Ex )

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    56/330

    2 PREITOR A oo VLSI o 33

    The ter for the trasstor otais a uique idetier (e) the trasistorTyp its oatio (Point ) its idth gategth ad orietatio (os ) the aes

    of the odes oeted to the trasistors ure S gate G ad drai 0, ada eteio ed to hod iforatio hih do ot t i the other eds (xt) Not al of this iforatio is avaabe fro every iruit desriptio aguage. Foreape, ot a iruit guag ig idividua uique aes to eah trasstorI this e, the e arguet oud remai uistatiated

    Ciruits are repreted ell/5 fats i the databe

    ce( e ements ets Pins BBox)

    A iruit or ell otais a ist of iruit eeets i eents pratie thesists otai fro 10 to 50 items ad so a ore ope data struture h ot beesary Soe of the objets i ements repret bi eetria opoetssuh the trasistors, ires, or otats But the eemet it may ao otai aspeia objet repretig a istae of aother iruit.

    instce( e Cene os Connections atrix xt )

    This struture is aaogous to the hierarhy foud i oftare, here a paraeterized agorith appears a ubroutie (the e) ad a ubroutie a (theistae) auses the agorith to exeute i a ertai otext ie a program, airuit desig i deed by a partiuar ell/5 fat hih i the euivaet of a maiprogram routie A of the other es i the databe i appear itaesuder this topeve e

    ah istae/ ithi a paret iruit h oatio ad orietatio iforatiohih speie its reative paeet ithi that iruit ie the arguets of asubroutie this iforatio speies the otext for thi partiuar itae of theprototype e

    Oe the trasator h traformed the iruit dei to roog aue sasae roog progras a be ritte by the deiger to aer uetios aboutthe desig For eape the fooig i determie he uber of trators i

    a partiuar iruit.

    [ser trsistors (e er)

    ce(e ements ) .

    agof (T (memer(T ements) fnctor( T tr » Ts)

    length(Ts er)

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    57/330

    34

    - trsistos (multiplexor ber)

    ber 2

    yes

    Peer Reinj

    Oce rnor b ritte precte c be rtte t eterme hichcircut h the gretest umber f trsistrs

    mosttrsistors (ellne itount) -

    bag (cot (be e) tnits ( ) it) sort(ist Sist)

    append( [cot(rsistunt lln» it )

    A query f the frm -mosttistos(ell b) i ufy ell ber ith the me umber f trsistrs f the est crcut

    Be meht mre usfu precte s prs f eectrc es cehch re eectricy cecte thuh they he stct mes he nn termsink the textu mes f eectric es the crcut escripti nuge thusttte rb repret the eectric cect Eery bject th eectrc cect t prtcur e he cect rbe ueith tht e's c rgut.

    horted(ellne e . 2) -

    cell(ellne ods )

    member ((e1 et 1 ) odes)

    ember ((e2 et2) ods)

    not(e == e2)

    et == et2

    If the circuits i the tb f the cet tht per suppy esre me power grund the uery 1- shortd(ll po d) irch the tbe fr ces th shrte per suppy cectis

    222 Graphical Dispay

    The c cmpet f the system s grphic ispy system hch supprtsfur isuizti etg ees hese ees re: cumett urtrctepctur text schemtc symbic yut. Thus sige prgr gthe desiger cc t fur ees f bstrti The isuizt etig

    subsystem is cmp f prect fr the ispy secti ietcti fthe esig bjects

    Copyrghte Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    58/330

    2 PREDITOR A Prolog-bad VLSI Edtor 35

    bus

    -bus

    B-bus

    ontol wod

    igu 2.1 Duenin

    The highes level f esign n e esie a he ein f n uninepeepiue epening uenin-eel visuliin f iui. Suh piue is n iy llein f lines e une plygns, n ex

    The nex highes level is he shei leel The gil jes his levelnss f f lgi sys (n, n, inee nsin ge) ih n

    nein pins This is sil he uenin level exep h he piivees e lgi ges, lgi ks (suh a es is) nsiss, n

    wi inse flines, plygns n ex. Fuhee, he shei epeseninnins iinl seni infin u nneiviy eeen pnens.Shei epenins e si e ehnlgy inepenen eu he seshei ul esie iui ipleene in CMOS, nMOS Bi-pl eh

    nlgyThe nex level is he syli lyu leve. ee he jes e sie nsss, wi, ns, n pins ple n n evenly spe gi. This evel f esipin is ienil h fun in he MULGA n VVD™ sli yusyses The piiive es in sli esipin e genelly teologyspei F exple, si esign in CMOS ehnlgy is quie ieen fn nMOS esign eu hey hve ieen eils n nss yes A syli esign is desig-le idepedet, hweve sine he ex sie n spingf he nens is n spee Syli lyu esipins e nvee

    physil lyus wih ex iensins y pin pgAs in he shei level, i he

    I!ymbol c

    lyu level e esie y Copyrghted Mteril

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    59/330

    36 ete B. Reintj

    a

    cb

    a2 I

    q

    b

    Tb2 c

    igur 2.2: Smat

    igur 2.3:Symbolic

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    60/330

    2 PRTR A Proog-b VLS itor 7

    igur 2.4: Phsica Laut

    ist f pints Hwvr unik schmatic wirs and transists smbic bjctshav ciatd paramtrs whch giv th rativ siz f th phsic ut bjctwhich wi b gnratd b th cmpactr

    Th phsica at v dirs frm th thr prvius vs in that th crdnat sstm wthn th c crrpnds t th acta phsica dimnsins f thpattrns n th ntgratd crct prcng mk A srspcid sca factrdtrn th crrpndnc btwn phsca dmnsns in th circut and thdspagrid sca Whnvr th sr s prfrming pratns nsid th prtr

    f th phsica at c, a crdinat ar spcd n phsic dmnsns Just th smbc digns wr tchng spcc phsica auts r tchngand dgnru spcic

    Th schmatc and smbic vws f ths crcits ar th ssntia structurarprntatins and ar cmpt cntaind in th ell/5 fcts. f cumntatinr at dcriptins xist fr a c ths wi appar in t t spaatell/6 facts, wth th xtra argumnt ndicatng hw t ntpt t cmpnntsin th strctur

    223 Editing

    Aftr biding a datab frm th txtua circut dscriptins n prviding adispa sstm th nxt cmpnnt wi aw th usr t prfm it pratinsn th bjcts in th datab an s th chang n an intctiv dispa

    Statd in gic prgramming trms th diting sstm is mt-intrprtrwhich whn givn a cmmand and a datb wi prduc a n dtb and a

    stram f graphcs cmmands.

    Th datab cnsists f a cctin f ell/5 facts wh ntin inividua

    circit dscrptins, a predorde/8 fact which cntains ft vus f tbjcts cratd b th ditr and a predorJe3 fact whih cntins infrmatin

    Copyrghted Mtenl

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    61/330

    38 Peter Reites

    au h currn sa h ir. An r all h prica ma changuring an i prain

    r xampl i a signr is iing h cll adder u hn ms h cursrr a nighring cll register an l a ransisr h llng changswill ccur in h ir

    • Th prediorse3 will chang rc ha h currn cll ing is egiste nsa adder

    • Th prediordes8 ll upa rprn h ha h currn jc s a ransisr h p l

    • Th cell5 crrsning h egister circui l ha h slc ransisr rm rm is lis cmpnns.

    Th ransisr ill r rm h scrn.

    Th pll h ir is h inerc prica. This prca rpal gs a cmman rm h usr prrms h cmman n h aa hmenop an hn ails ack repe unl h cmman h am quitA qui cmman crrsns a menuop claus which s nhng u hn

    h iner prica ill cmpl succull

    inteat :

    setdefaults

    repeat

    pi(od)

    menuop(od)

    od = quit

    Sing h aul alus r h ir sa inclus rang a sup l an/rprmping h usr r h nam h rs circu Ths inran gsin a glal srucur call prediorse3

    pitorstate (ell (Vell V_BBo)

    eell (ell nste E_BBo)

    ma t ri (A B D E F»

    n gnral h cll ing i an h cll ng ar rn T allh signr i a crcu n cnx rir ill ing a parn cll

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    62/330

    2. RETOR oogb VS or 39

    ) ic coais e edi cel l3) a subcicui Te hid agume pdior9 is a mai hic maps he coodiaes i e desig space o

    e gapic displa.Te pedicae muop is he dispach able o he diee meu opeaios

    I e u did o lec a meu iem e agume ill be he aom f ied" idicaig a e cu i he or aea. his siuaio muop illcall he di predicae discusd i secio . .

    menu_op(fied) ' edit

    menu_op(zoom) - zoom ( in)

    menu_op(zoom) - zoom(out)

    enuop (dispay) -

    pritorstate( ce(e _) _ _)

    pot_cehierchy(e matri( »

    2 3 e Coordinate Systm

    cocee VI epeseaio such a m layou is lile more ha a specicaio o geomeic relaioships. For his leel o descripio he primary role ohe daabe is o maiai spaial iormaio Ee a ore absrac ie o aelecical eo such a scheaic depeds upo copoe posiios ad helocaio o coecig lies a all leels o descripio i PREDOR hecommo equieme is he eed o represe spaial elaioships

    log i he daab equieme o spaial iormaio ere is a eesie eed o geomeic compuaios ppoimaely 20% o he goals i hePREDITOR pogram iole mappig geomeric repeseaios rom oe coodiae ssem o aohe Tree ypical C poblems ae gie belo ogeherih bie descipios o ho hey are soled ih coodiae rasomaios

    emie hich objec i a cople hierarhy he user h seleced ih hecuso h boudig bo o h ubirui o h rn r normd or oordi d omprd wih h uror loio o idn whi irui

    h uror i ovr. A w m rlin r oordin o oordinINSIDE h irui i ud o rnorm uror loio o oin inid h

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    63/330

    40 ete njs

    ( )

    ( )

    Figue 2 x/5 e

    circui. hs crcui is hn srchd rcursvl fr n subcrcus r bjcs whichli undr h rnsfrmd cursr lcn

    • Pl lyu ecle he scee h cr pns f rprsnngh lu rcngl o(X , , Coo) mus b rnsfmd nd ndusng m which rls h crdns n h subcll h dspl scrn

    • Fd he ecec ps succus cel hs prinrqurs liss f ll pns n h pimrs f subclls hs pns r rnsfrmdfrm ch subcircu s crdns n h prn cll crdins h pinswhich cincd whn nsfmd h prn cll r hn chcd fr nrcnglccl cmpnns

    My pes ece CAD syse del h he dspy d apul jecs desl pe The ed pes peedy he u e d up he ecs eee jecs hs pe eccu exc d des ule chec e essh u syse desl ss e he uese jecs he CAD sysee pecs he syse e ely spled The rnsfrm/3 pedce sdeed s y V jec cud ps sss eu emsiss jecs d y he cpud jecs c sp

    231 The sfomation Matix

    Te cde pp s uses e elee s -

    as ps d jecs wdesl spce The lues ee eees s i e lwys ed s we ly eed ai s

    Copyrhte Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    64/330

    2 REITOR ologbad VS Edito

    [X T = [ X y ] E F 1igur 26 Coodae asomao

    Translation :X' Y' ] = [X Y

    Rotation [X' yl (

    ] = [X ] s s( Ocos(o

    Scaling [X' Y' ] = [ Y

    igur 2.7 Tasomaio Compoes

    4

    ese values. Te epesso rorm( X marx (A B C D E F » cabe ead a he poi (X Y is rsormed wih he mrix(A B CD EF o gehe poi (X Y. Ts epessio dees e ma opeao gue 26.

    Tis asomaio ma elae e locao o a objec i e desg space ois displa scee cooda Te asomaio mai ca bes be udesdb cosdeig e dvidual compoes o dmesoal asomao

    Fgue 7Te t opeao is simpl a combie opeao c dees e daa sucue

    coaig e o cooda o a poi. I a Polog ssem does o allo opeao deios eve occuece o X i e pogam could be caged opo I ) . Te s clau o e pedcae rsorm3 dees e po as

    omao

    Copyrghted Mterl

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    65/330

    42

    torthEat

    forthWet

    Yax rror)

    i

    EtSoth

    (+9 deee)

    igur 28 Fu Eigh Oieis

    troXYXYt rx B D E F»

    X X + + E Y BX + DY + F

    r B Rnjs

    f )

    WtNorth

    (9 de)

    The wig cuses dee he si VS es i e his

    pi si. The bo5 e is used epese physi yu euesdeed ecgu egi piu ei

    troboxX 1 Y1 X2 Y2 D) boxRX1 RY1 R2 RY2 D) Ktrx) -I. ,troX1Y1 IX1IY1 Ktrx)

    troX2Y2 IX2IY2 Ktrx)

    nIX1 IX2 1 ) axIX1 IX2 R2)

    nIY1 IY2 RY1 ) IY1 IY2 RY2)

    Ne h he eiship ewee he wee d uppegh es is iied wih min3 d m3. The eie psiis he wee d uppeigh ces is iei ii.

    me jecs, sch siss, isces, d g he su whihdeped p e gee i iei Eigh ieis e piewhe u 90degee is e ied wih he w peis iigu he X Y a The de, NhE iei is epeseed y he j d ee i is A 9degee cwise i

    his iei esus i he ESuh iei wih is e di a h.

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    66/330

    2 RETOR A oo VS o 43

    e ormr pedcae eae a oueeme mai o eac o e egoeao mae oeaio ma cod o e oaio ub

    mai o e geea aomaio mai

    oratrx, orJatrx 1 , , , 1 oratrx , orJatrx , 1 , 1 , or_atrxv, or_atrx (1 , , , 1 ormatrxv ormatrx , 1 , 1 , » or_atrx, or_matrx , 1 , 1 , or_atrx oratrx 1 , , 1 » or_matr xv or_atrx , - 1 , 1 , or_matrxv orJatrx - , 1

    I e oowig cau e aio' locaio poi i aomed ad e ioeao ma i aomed o ge a ew mai (ad coepodig oieao)

    trotrI ,T ,Pt ,od Or Wd, Ln) S , G , D Ext) ,

    trI ,T , IPt ,odIOr Wd Ln) , S , G D ,Ext) ,Matrx) -I

    ,troPt , IPt Matrx) ,

    oratrx Or Or_Matrx)

    trormOr_Matrx w_Matrx , Mrx) ,

    ormatrx IOr wMatrx)

    A wre5 coai a i o poi a we a omao abou e wie wid admaeia A aomed wie i impy a wie wi a aomed poi li.

    trowrI L ,W ,Pt I ,E) wrI L W,TP , I E) Mrx) -!  , 

    trorm P P , Mtrx)

    Te aomaio o a i o objec i ju a li o e aomed objec. Tiimpe caue ecuivey ade ioli

    tro Obj T] , TObj T] , Mtrx) -

    ! ,

    troObj , TObj , Mtrx) ,troT,,Matrx)

    Copyrghted Materal

  • 8/20/2019 0262193019 {936BCB0C} the Practice of Prolog [Sterling 1990-10-30]

    67/330

    44

    [Na

    NcNe

    eter B Reintj

    Z� �l = : g� � Nf 1 Ce Cf 1 Eeigu 2.9: Max ansfman

    he nex w claus mplemen max mulplcans he aales hae hepex C and emphze he use f hs pean n cean new enn

    men mac when edn su-cells. he lcal max a ccu nsance (C) smulpled by he cuen ennmen max (E), e a new ennmen (N

    trsfo(atrix(Ca, Cb ,Cc , , C ,Cf) ,trix(a, Ib c d , f) ,

    atrix(,b,c,,,Ef»

    I a is Ca*a + Cb*c ,

    b is Ca*b + Cb*d,c is Cc*Ea + Cd*c ,

    d is Cc*Eb + Cd*Ed, is C*Ea + Cf*Ec + ,f is C*Eb + Cf*d + Ef

    An enan max s smply he fu-elemen sumax whch den anenan whu anslan

    trsfo(oratrix( Ca, Cb , Cc , Cd) , or_atrix(a b , c d) ,

    atrix(b,c,,_,_»

    a is Ca*a + Cb*Ec ,

    b is Ca*b Cb*Ed,

    c is Cc*a Cd*c,

    d is Cc*b + Cd*d

    he b ce f he ls ansfman s he same f all nnemec bjecssnce nhn needs be dne All such bjecs ae handled by he l clau