28.04.2013 Views

3.3 Teoria de la demostració - La Salle

3.3 Teoria de la demostració - La Salle

3.3 Teoria de la demostració - La Salle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Dec<strong>la</strong>ració <strong>de</strong> <strong>la</strong> secció Facts<br />

<strong>La</strong> secció Facts o Database (són dos noms equivalents per a <strong>la</strong> secció i s’han<br />

mantingut per compatibilitat <strong>de</strong> versions) permet <strong>de</strong>c<strong>la</strong>rar predicats que seran<br />

consi<strong>de</strong>rats fets dinàmics durant l’execució <strong>de</strong>l programa.<br />

Tots els predicats <strong>de</strong>finits en aquesta secció formen part <strong>de</strong> <strong>la</strong> mateixa base <strong>de</strong> da<strong>de</strong>s.<br />

Això és important ja que l’operació save, que veurem més endavant, guarda a fitxer<br />

tots els predicats <strong>de</strong> <strong>la</strong> base <strong>de</strong> da<strong>de</strong>s.<br />

Visual Prolog permet tenir diferents bases <strong>de</strong> da<strong>de</strong>s, és a dir, diferents grups <strong>de</strong><br />

predicats re<strong>la</strong>cionats. És possible tenir doncs diverses seccions facts cadascuna amb<br />

un nom diferent. A continuació es mostra l’estructura d’un programa amb una so<strong>la</strong><br />

secció Facts i amb diverses.<br />

Exemple amb una única secció facts:<br />

Domains<br />

.....<br />

Facts<br />

......<br />

Predicates<br />

.....<br />

C<strong>la</strong>uses<br />

.....<br />

Exemple amb diverses seccions facts:<br />

Domains<br />

.....<br />

Facts - nom1<br />

......<br />

Facts - nom2<br />

......<br />

Facts - nom3<br />

.....<br />

Predicates<br />

....<br />

C<strong>la</strong>uses<br />

......<br />

Restriccions<br />

Hi ha les següents restriccions en <strong>la</strong> utilització i <strong>de</strong>c<strong>la</strong>ració <strong>de</strong> facts:<br />

- Els noms <strong>de</strong>ls predicats utilitzats en les diferents seccions facts han <strong>de</strong> ser únics.<br />

- <strong>La</strong> secció facts només admet fets i no regles.<br />

- Els fets dinàmics que afegim no po<strong>de</strong>n contenir variables lliures.<br />

130

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!