Содержание
- 2. Peculiarities of Visual Prolog Visual Prolog is a compiled language Other versions have elements of interpretation
- 3. Program sections compiler directives CONSTANTS – section of constants description DOMAINS – section of domains description
- 4. Peculiarities of Visual Prolog All sections can be in any order Predicates and domain must be
- 5. Program containing only the goal GOAL write("hello"), readchar(_).
- 6. Compiler directives trace – to trace the program nowarnings – to suppress the message that a
- 7. Peculiarities of Visual Prolog You can start tracing only for the definite predicate If there is
- 8. Constants CONSTANTS pi=3.14 path="c:\\prolog\\bgi"
- 9. Domains integer – an integer number (-32768...32767) real – a float number (±e-307...±e308) char – a
- 10. Description of your own domain = or file = ; ...; or = * Examples: DOMAINS
- 11. Description of a structured domain = ( , ..., ) [; (...)]* Examples: flatpoint = p(integer,
- 12. Description of predicates ( , ..., ). Examples: PREDICATES mother(string,string). member(integer,integer*). member(real,real*). member(char,char*). member(string,string*). One and
- 13. Standard predicates readln(_) readint(_) readreal(_) readchar(_) readterm(name_domain, term_domain) write([ ,…]) writef – format output nl upper_lower(_,_)
- 14. Standard predicates div() mod() trunc() round() random(_) random( ,_) All embedded predicates are determinated
- 15. Program “Relatives” DOMAINS s=string PREDICATES nondeterm mother(s,s) nondeterm grandmother(s,s) CLAUSES mother("Наташа","Даша"). mother("Даша","Маша"). grandmother(X,Y):- mother(X,Z), mother(Z,Y). Well-formed
- 16. Execution management Method of a depth search (backtracking) Method of a rollback after a failure Cut
- 17. Backtracking DOMAINS s=string PREDICATES mother(s,s) grandmother(s,s) CLAUSES mother(“Dasha",“Masha"). mother(“Natasha",”Dasha"). mother(“Natasha",”Glasha"). mother(“Dasha",”Sasha"). grandmother(X,Y):– mother(X,Z), mother(Z,Y). GOAL grandmother(B,V).
- 18. Method of a rollback after a failure DOMAINS s=string PREDICATES mother(s,s) grandmother(s,s) CLAUSES mother(“Dasha",“Masha"). mother(“Natasha",”Dasha"). mother(“Natasha",”Glasha").
- 19. Method of a rollback after a failure DOMAINS s=string PREDICATES mother(s,s) grandmother(s,s) CLAUSES mother(“Dasha",“Masha"). mother(“Natasha",”Dasha"). mother(“Natasha",”Glasha").
- 20. Method of a rollback after a failure DOMAINS s=string PREDICATES mother(s,s) grandmother(s,s) show_names CLAUSES mother(“Dasha",“Masha"). mother(“Natasha",”Dasha").
- 21. Method of a rollback after a failure DOMAINS s=string PREDICATES mother(s,s) grandmother(s,s) show_names2(s) CLAUSES mother(“Dasha",“Masha"). mother(“Natasha",”Dasha").
- 22. Cut and rollback DOMAINS s=string PREDICATES mother(s,s) grandmother(s,s) show_names3(s) CLAUSES mother(“Dasha",“Masha"). mother(“Natasha",”Dasha"). mother(“Natasha",”Glasha"). mother(“Dasha",”Sasha"). grandmother(X,Y):– mother(X,Z),
- 24. Скачать презентацию