home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / sci / logic / 2643 < prev    next >
Encoding:
Internet Message Format  |  1993-01-27  |  27.8 KB

  1. Xref: sparky sci.logic:2643 sci.math:18780 comp.lang.prolog:2457
  2. Newsgroups: sci.logic,sci.math,comp.lang.prolog
  3. Path: sparky!uunet!inmos!fulcrum!bham!warwick!doc.ic.ac.uk!citycs!mb108
  4. From: mb108@cs.city.ac.uk (omo ADELAKUN T K)
  5. Subject: Temporal logic (re)sources: A summary (900+ lines!)
  6. Message-ID: <1993Jan27.140803.4254@city.cs>
  7. Sender: news@city.cs (News)
  8. Organization: City University, London
  9. Date: Wed, 27 Jan 93 14:08:03 GMT
  10. Lines: 895
  11.  
  12. The number of responses I got seems to suggest much interest in the area -
  13. which is why I'm posting a collated summary. Responders, thanx for your
  14. responses (special thanx to Dr. Chris Johnson of York for the interpreter
  15. implementation). To everyone else, enjoy (if you will):
  16.  
  17. From kym@bingsuns.cc.binghamton.edu Sun Jan 24 04:31:13 1993
  18.     id AA08677; Sat, 23 Jan 93 23:23:31 EST
  19. Date: Sat, 23 Jan 93 23:23:31 EST
  20. From: kym@bingsuns.cc.binghamton.edu (R. Kym Horsell)
  21.     id AA00797; Sat, 23 Jan 93 23:18:34 EST
  22. To: mb108
  23. Subject: Re: Definitive temporal logic source
  24. Newsgroups: sci.logic,comp.lang.prolog,sci.math
  25. Organization: Binghamton University
  26. Cc: 
  27.  
  28. TOKIO is an old Prolog program that interprets some form
  29. of temporal reasoning. You'll have to look it up in
  30. either the Int Conf on Auto Deduction, or the Int/Nat
  31. Conf on Sym Log; I don't know where I saw it.
  32.  
  33. -kym
  34.  
  35. From mcovingt@aisun3.ai.uga.edu Sun Jan 24 04:51:42 1993
  36.     id AA08343; Sat, 23 Jan 93 23:45:25 EST
  37. Date: Sat, 23 Jan 93 23:45:25 EST
  38. From: mcovingt@aisun3.ai.uga.edu (Michael Covington)
  39. To: mb108
  40. Subject: Re: Definitive temporal logic source
  41. Newsgroups: sci.logic,comp.lang.prolog,sci.math
  42. Organization: AI Programs, University of Georgia, Athens
  43. Cc: 
  44.  
  45. Ask Dr. Dov Gabbay over in Imperial College London.
  46. dg@doc.ic.ac.uk is his email address.
  47.  
  48.  
  49.  
  50.  
  51. -- 
  52. :-  Michael A. Covington     internet mcovingt@uga.cc.uga.edu :    *****
  53. :-  Artificial Intelligence Programs       phone 706 542-0358 :  *********
  54. :-  The University of Georgia                fax 706 542-0349 :   *  *  *
  55. :-  Athens, Georgia 30602-7415 U.S.A.     amateur radio N4TMI :  ** *** **
  56.  
  57. From cmenzel@kbssun1.tamu.edu Sun Jan 24 21:35:06 1993
  58.     id AA18510; Sun, 24 Jan 93 15:31:11 CST
  59. Date: Sun, 24 Jan 93 15:31:11 CST
  60. From: cmenzel@kbssun1.tamu.edu (Chris Menzel)
  61. To: mb108
  62.  
  63. To: mb108@cs.city.ac.uk (omo ADELAKUN T K)
  64. Subject: Re: Definitive temporal logic source
  65. Newsgroups: sci.logic,comp.lang.prolog,sci.math
  66.  
  67. In article <1993Jan23.114811.28054@city.cs> you write:
  68. : Can anyone point me to a very good text on temporal logic?
  69.  
  70. J. van Bentham, {\it The Logic of Time: a model-theoretic
  71. investigation into the varieties of temporal ontology and temporal
  72. discourse} (Reidel, 1983), is about the best I've seen.
  73.  
  74. Chris Menzel
  75.  
  76. From kono@csl.sony.co.jp Mon Jan 25 06:09:46 1993
  77.     id AA04755; Mon, 25 Jan 93 15:03:03 JST
  78.     id AA10142; Mon, 25 Jan 93 15:03:28 JST
  79. Return-Path: <kono@csl.sony.co.jp>
  80. To: mb108 (omo ADELAKUN T K)
  81. Organization: Sony Computer Science Laboratory, Inc.
  82. Reply-To: kono@csl.sony.co.jp
  83. Subject: Re: Definitive temporal logic source 
  84. Date: Mon, 25 Jan 93 15:03:26 +0900
  85. From: Shinji Kono <kono@csl.sony.co.jp>
  86.  
  87. >Can anyone point me to a very good text on temporal logic? 
  88.  
  89. I recomend Manna's Book (I forget its title....). 
  90.  
  91. And CSLI report
  92. @book{Goldblatt87,
  93.         author = "Robert Goldblatt",
  94.         series =        "CSLI Lecture Notes",
  95.         title =  "Logic of Time and Computation",
  96.         publisher = "CSLI",
  97.         volume = "7",
  98.         year = 1987
  99. }
  100.  
  101.  
  102. >In the same
  103. >vein, does anyone know of a temporal logic interpreter (something along
  104. >the lines of Prolog or extensions thereto)?
  105.  
  106. There are many....
  107.    Tokio (which has both interpreter and compiler) based on interval 
  108.           temporal logic), which I wrote.. 
  109.          Colse to Tempura, but supports non-deterministic execution.
  110.  
  111. @article{tokio86,
  112.         author =        "M. Fujita and S. Kono and H. Tanaka",
  113.         address =       "London",
  114.         year =          "July 1986",
  115.         journal =       "Proc. of Int. Conf. on Logic Programming",
  116.         title =         "Tokio: Logic Programming Language based on Temporal Log
  117. ic and its compilation to Prolog"
  118. }
  119.  
  120.    Temporal Prolog
  121.    IB-Templog
  122.           Both supports Mcdamott's interval temporal logic.
  123.           You can find an article in Journal of logic programing
  124.    Sakura's Temporal Prolog
  125.           supports linear time temporal logic
  126.    Molog
  127.           Modal logic extention of Prolog
  128.           There is an article in "New generatoin computing".
  129.    In CMU, some one working on CTL extention of Prolog.
  130.  
  131. >Thanx for any responses - which I'd prefer to come to me direct so I can 
  132. >post a summary.
  133.  
  134. Please send it to me... :-)
  135. ---
  136. Shinji Kono @           kono@csl.sony.co.jp
  137. Sony Computer Science Laboratory, Inc,Japan
  138.  
  139. From jcrw@fmg.bt.co.uk Mon Jan 25 09:55:20 1993
  140.           id <sg.05431-0@ben.uknet.ac.uk>; Mon, 25 Jan 1993 09:48:39 +0000
  141.           id <17704-0@zaphod.axion.bt.co.uk>; Mon, 25 Jan 1993 09:48:01 +0000
  142.           Mon, 25 Jan 93 09:42:10 GMT
  143. From: Jeremy Wilson <jcrw@fmg.bt.co.uk>
  144. Date: Mon, 25 Jan 93 09:48:24 GMT
  145. To: mb108 (omo ADELAKUN T K)
  146. Subject: Re: Definitive temporal logic source
  147. Newsgroups: sci.logic,comp.lang.prolog,sci.math
  148. Organization: British Telecom
  149.  
  150. I can't give you a definitivce text and would like to know one myself but 
  151.   I can recommend Executing Temporal Logic by Moszkowski, 1986, published by 
  152.  Cambridge Univeristy Press. If I remember correctly there is a language
  153.  called Tempura fro which there exists an interpreter.
  154.  
  155.  
  156. +---------------------------------+----------------------------------------+
  157. ! Jeremy Wilson              !    email: jcrw@fmg.bt.co.uk           !
  158. ! Room 3-07                       !     Telephone: 0473-227822             !  
  159. ! BT Development and Procurement  !     International: +44 473-227822      !
  160. ! Bibb Way              !     Facsimile: 0473-210182             !
  161. ! IPSWICH                         !     International: +44 473-210182      !
  162. ! Suffolk  IP1 2EQ                !     Telex: 987705                      !
  163. ! United Kingdom                  !     International: +51 987705          !
  164. !                    !                        !
  165. +---------------------------------+----------------------------------------+
  166.  
  167.  
  168. From jack@dcs.gla.ac.uk Mon Jan 25 14:59:29 1993
  169.           with LOCAL SMTP (PP) id <09263-0@goggins.dcs.gla.ac.uk>;
  170.           Mon, 25 Jan 1993 14:52:51 +0000
  171.           Mon, 25 Jan 93 14:52:45 GMT
  172. Date: Mon, 25 Jan 93 14:52:45 GMT
  173. From: jack <jack@dcs.gla.ac.uk>
  174. To: mb108
  175. Subject: Re: Definitive temporal logic source
  176. Newsgroups: sci.logic,comp.lang.prolog,sci.math
  177. Organization: COMANDOS Project, Glesga Yoonie, No Mean City
  178.  
  179. The best single book I know of is J.F.A.K. van Benthem: "The Logic of Time",
  180. published by Elsevier.
  181.  
  182. cheers - jack
  183.  
  184.  
  185.  
  186. -- 
  187. --  Jack Campin    room G092, Computing Science Department, Glasgow University,
  188. 17 Lilybank Gardens, Glasgow G12 8RZ, Scotland   TEL: 041 339 8855 x6854 (work)
  189. INTERNET: jack@dcs.glasgow.ac.uk or via nsfnet-relay.ac.uk    FAX: 041 330 4913
  190. BANG!net: via mcsun and uknet     BITNET: via UKACRL    UUCP: jack@glasgow.uucp
  191.  
  192.  
  193. From maler@vercors.imag.fr Tue Jan 26 09:25:07 1993
  194.   (5.65c8/IDA-1.4.4 for <mb108@cs.city.ac.uk>); Tue, 26 Jan 1993 10:18:17 +0100
  195.     id AA28496; Tue, 26 Jan 93 10:18:42 +0100
  196.     id AA02694; Tue, 26 Jan 93 10:18:27 +0100
  197. Date: Tue, 26 Jan 93 10:18:27 +0100
  198. From: maler@vercors.imag.fr (Maler)
  199. To: mb108 (omo ADELAKUN T K)
  200. Subject: Re: Definitive temporal logic source
  201.  
  202.  
  203. Manna and Pnueli, The Temporal Logic of Concurrent and Reactive
  204. Programs, Springer, 1991.
  205.  
  206. -- 
  207. ===============================================================
  208. Oded Maler, LGI-IMAG (Campus), B.P. 53x, 38041 Grenoble, France
  209. Phone:  76635846  Fax: 76446675   e-mail: maler@vercors.imag.fr
  210. ===============================================================
  211.  
  212. From rwsh@cam.sri.com Tue Jan 26 10:34:01 1993
  213.     id AA24286; Tue, 26 Jan 93 10:26:24 GMT
  214. Date: Tue, 26 Jan 93 10:26:24 GMT
  215. From: rwsh@cam.sri.com (Roger Hale)
  216.     id AA22339; Tue, 26 Jan 93 10:26:25 GMT
  217. To: mb108
  218. Subject: Definitive temporal logic source
  219.  
  220. Here are a few books on various aspects of temporal logic. How good you
  221. think they are will depend to a very large extent on what you want them for
  222. (logical theory, applications, survey, ...).
  223.  
  224. @book{prior:tl,
  225.     author = "Prior, A. N.",
  226.     title = "Past, Present and Future",
  227.     publisher = "Clarendon Press",
  228.     address = "Oxford",
  229.     year = 1967
  230. }
  231.  
  232. @book{manna-pnueli:tl-book-v1,
  233.     author = "Manna, Z. and Pnueli, A.",
  234.     title = "The Temporal Logic of Reactive and Concurrent Systems: 
  235.         Specification",
  236.     publisher = "Springer-Verlag",
  237.     year = 1992
  238. }
  239.  
  240. Rescher & Urquhart: Temporal Logic, Springer-Verlag.
  241.  
  242. Kroger: Temporal Logic of Programs, Springer-Verlag.
  243.  
  244. Goldblatt: Logics of Time and Computation, CSLI.
  245.  
  246. @inproceedings{
  247.         ...
  248.     booktitle = "Temporal Logics and Their Applications",
  249.     editor = "Galton, A.",
  250.     publisher = "Academic Press",
  251.     address = "London",
  252.     pages = "91--119",
  253.     year = 1987
  254. }
  255.  
  256. @inproceedings{
  257.         ...
  258.     booktitle = "Temporal Logic in Specification",
  259.     editor = "Banieqbal, B. and Barringer, H. and Pnueli, A.",
  260.     publisher = "Lecture Notes in Computer Science, number 398, Springer-Verlag",
  261.     address = "Berlin",
  262.     year = 1989
  263. }
  264.  
  265. There are a number of designs for programming languages based on temporal
  266. logic, some of them have resulted in interpreters. To my knowledge, the
  267. best developed systems are those based on Interval Temporal Logic: Tempura
  268. and Tokio. Tempura is imperative, Tokio is more prolog-like. Shinji Kono,
  269. who implemented Tokio, is now working on a nice little verifier for
  270. propositional ITL.  I think Howard Barringer has also worked on an
  271. implementation of a conventional TL language, but I've no idea of its
  272. status. I believe that Manna and Abadi's proposed language was never
  273. implemented. Here are some refs.
  274.  
  275. @book{moszkowski:exec,
  276.     author = "Moszkowski, B. C.",
  277.     title = "Executing Temporal Logic Programs",
  278.     publisher = "Cambridge University Press",
  279.     address = "Cambridge, England",
  280.     year = 1986
  281. }
  282.  
  283. @techreport{hale:thesis,
  284.     author = "Hale, R. W. S.",
  285.     title = "Programming in Temporal Logic",
  286.     institution = "Computer Laboratory",
  287.     address = "University of Cambridge, England",
  288.     number = "173",
  289.     year = 1989
  290. }
  291.  
  292. @inproceedings{abadi:templog,
  293.     author = "Abadi, M. and Manna, Z.",
  294.     title = "Temporal Logic Programming",
  295.     booktitle = "Proc. IEEE Symposium on Logic Programming",
  296.     year = 1987
  297. }
  298.  
  299. @inproceedings{gabbay:manchester,
  300.     author = "Gabbay, D. M.",
  301.     title = "The Declarative Past and Imperative Future: Executable
  302. Temporal Logic for Interactive Systems",
  303.     booktitle = "Temporal Logic in Specification",
  304.     editor = "Banieqbal, B. and Barringer, H. and Pnueli, A.",
  305.     publisher = "Lecture Notes in Computer Science, number 398, Springer-Verlag",
  306.     address = "Berlin",
  307.     year = 1989
  308. }
  309.  
  310. @inproceedings{fujita-etal:tokio,
  311.     author = "Fujita, M. and Kono, S. and Tanaka, H. and Moto-oka, T.",
  312.     title = "Tokio: Logic Programming Language based on Temporal Logic and Its Compilation to Prolog",
  313.     booktitle = "Proceedings of the Third International Conference on Logic Programming",
  314.     organisation = "",
  315.     address = "London",
  316.     year = 1986,
  317.     month = jul
  318. }
  319.  
  320. From jampel Tue Jan 26 11:26:26 1993
  321. From: Michael Jampel <jampel>
  322. Date: Tue, 26 Jan 1993 11:24:30 GMT
  323. To: mb108
  324. Subject: temporal logic
  325.  
  326.  
  327. Rescher is in the City University library.
  328.  
  329. From jampel Tue Jan 26 11:27:28 1993
  330. From: Michael Jampel <jampel>
  331. Date: Tue, 26 Jan 1993 11:25:33 GMT
  332. To: mb108
  333. Subject: temporal logic
  334.  
  335.  
  336. There is also a book on TEMPURA - a temporal logic language - its a thin
  337. blue book, but I foregt who its by.
  338.  
  339. From johnson@minster.york.ac.uk Wed Jan 27 09:16:28 1993
  340. From: johnson@minster.york.ac.uk
  341. Date: Wed, 27 Jan 93 09:08:53
  342. To: mb108
  343.  
  344. I've got a version of the Tokio interpreter.
  345. I'll mail you the source - for references you
  346. might try to get a copy of my thesis - there
  347. is a huge lit survey in it.
  348.  
  349. Hope this helps,
  350.   Chris.
  351.  
  352. @phdthesis{Johnson:92t,
  353.         TITLE = "A Formal Approach To The Integration Of Human Factors And Systems Engineering",
  354.         AUTHOR = "C.W. Johnson",
  355.         SCHOOL = "Department Of Computer Science, University of York",
  356.         ADDRESS = "York, United Kingdom",
  357.         YEAR = "1992"}
  358.  
  359. or:
  360.  
  361. @incollection{Johnson:91a,
  362.         TITLE = "Applying Temporal Logic To Support The Specification And Prototyping Of Concurrent Multi-User Interfaces",
  363.         AUTHOR = "C.W. Johnson",
  364.         BOOKTITLE = "People And Computers VI: Usability Now",
  365.         PAGES = "145-156",
  366.         EDITOR = "D. Diaper and N. Hammond",
  367.         PUBLISHER = "Cambridge University Press",
  368.         ADDRESS = "Cambridge, United Kingdom",
  369.         YEAR = "1991"}
  370.  
  371.  
  372.  
  373.  
  374. From johnson@minster.york.ac.uk Wed Jan 27 09:26:31 1993
  375. From: johnson@minster.york.ac.uk
  376. Date: Wed, 27 Jan 93 09:10:50
  377. To: mb108
  378.  
  379. %------------------------------------------------------------%
  380. %
  381. %              TOKIO INTERPRETER 
  382. %
  383. %   File: tokio.pl
  384. %   Author : S. Kono, T. Aoyagi, M. Fujita and H. Tanaka
  385. %   Implemented by: C.W. Johnson,
  386. %   Address: Department of Computer Science,
  387. %            University of York,
  388. %            Heslington,
  389. %            England.
  390. %            Y01 5DD.
  391. %   Date: 23/11/89.
  392. %
  393. % NB Poorly documented in the original article, had to make
  394. % ammendments to get it to work, specifically systemp()
  395. % and tnot() - in order to expand non temporal predicates.
  396. % Source published in:
  397. %     Springer Verlag Notes on Computer Science No. 221
  398. %
  399. % Acknowledgement:
  400. %       Chris Roast (at the above address) helped at many
  401. % stages of the implementation of this code and helped to
  402. % port it from CProlog to LPA Prolog to Sicstus Prolog.
  403. %
  404. % See:
  405. %    C.W. Johnson and M.D. Harrison, Declarative
  406. %    Graphics And Dynamic Interaction, F.H. Post
  407. %    and W. Bath (eds.), EUROGRAPHICS'91, 
  408. %    Elsevier, North Holland, 1991. pp 195-207.
  409. %
  410. %    C.W. Johnson, Applying Temporal Logic To
  411. %    Support The Specification And Prototyping
  412. %       Of Concurrent Multi-User Interfaces, 
  413. %    D. Diaper and N. Hammond (eds.), People
  414. %    And Computers VI: Usability Now, Cambridge
  415. %    University Press, Cambrdige, U.K. pp 145-156.
  416. %
  417. %_________________________________________________________%
  418.  
  419. % Key to temporal operators:
  420. %     @(X) is true if X is true in next interval.
  421. %     #(X) is true if X is true in all intervals.
  422. %     Y===X is true if X unifies with Y in present interval.
  423. %     Y<--X is true if X unifies with Y in all intervals.
  424. %     <>(Y) is true if Y is eventually true.
  425. %     until(X, Y) is true if X is true until Y is true.
  426. %
  427. % TOKIO must be regarded as a hybrid form of temporal logic
  428. % for example an assertion (X<--3) is not, in effect, a global
  429. % temporal assignment because all variable are `lost' at the
  430. % end of each clause.   One way of interprating it's behaviour
  431. % is to regard the scope of the clause as an interval, so the 
  432. % variable is globally assigned over the scope or interval
  433. % of that clause.   This view leads to conflicts with the
  434. % <> operator because in TOKIO this requires global termination,
  435. % rather than clause completion, giving the operator an
  436. % unorthodox interpretation in this implementation.
  437.  
  438. :- prolog_flag(single_var_warnings, X, off).
  439. :- nl,nl,nl,
  440.    write('TOKIO'), nl,
  441.    write('Loading file...'),
  442.    nl,nl,nl.
  443.  
  444. %_________________________________________________________%
  445. %-Entry to TOKIO.
  446. temp(A) :-
  447.     t_reduce(A, 0, Fin).    
  448. %_________________________________________________________%
  449.  
  450. %_________________________________________________________%
  451. %-Define operator precedence. 
  452. :- op(810,xfx, '<--').
  453. :- op(810,fx,#).
  454. :- op(810,fx,@).
  455. :- op(810,xfx,'*u*').
  456. :- op(810,xfx, '<-').
  457. :- op(810,xfx, 'gets').
  458. :- op(810,xfx,'&&').
  459. :- op(100,xfx, '===').
  460. %_________________________________________________________%
  461.  
  462. %_________________________________________________________%
  463. %-Expand temporal formulae to reveal temporal operators in 
  464. % bodies of dependent clauses.
  465. t_reduce(true, Now, Fin) :-integer(Fin),Now>Fin,!.
  466. t_reduce(Formula, Now, Fin) :-
  467.     i_reduce(Formula,Next,Now,Fin,_),
  468.     NextT is Now+1,
  469.     t_reduce(Next,NextT,Fin).
  470. %_________________________________________________________%
  471.  
  472. %_________________________________________________________%
  473. %-Interval reducer reduces Formula Now and executes either
  474. % finite queue or keep que.
  475. i_reduce(Formula,Next1,Now,Fin,OuterFin):-
  476.     qcl(Next,EmptyFlag,Q1,Q2),
  477.     reduce(Formula,Q1,Now,Fin),
  478.     force_finite(EmptyFlag,Now,Fin,OuterFin),
  479.     exec_fin_keep(Next,Next1,Q1,Q2,Now,Fin).
  480. %_________________________________________________________%
  481.  
  482. %_________________________________________________________%
  483. %-Interval terminates.
  484. exec_fin_keep(Next,true,Q1,Q2,Now,Fin) :-
  485.     Now==Fin,!,
  486.     get_fin(F,Q1),
  487.     reduce(F,Q2,Fin,Fin).
  488. exec_fin_keep(Next,Next,Q1,Q2,Now,Fin) :-
  489.     get_keep(K,Q1),
  490.     reduce(K,Q2,Now,Fin).
  491. %_________________________________________________________%
  492.  
  493. %_________________________________________________________%
  494. %-Cut off finite interval.
  495. % NB TOKIO will terminate as soon as it can instantiate and 
  496. % OuterFin and meet it's commitments.
  497. force_finite(free,Now,Fin,OuterFin):-
  498.       var(Fin), Fin is Now+1,
  499.     (nonvar(OuterFin),OuterFin=Fin,! ; true).
  500. force_finite(_,Now,Fin,OuterFin).
  501. %_________________________________________________________%
  502.  
  503. %_________________________________________________________%
  504. %-Reduce temporal formula.
  505. reduce((A,B),Q,Now,Fin):- 
  506.     qap(Qa,Qb,Q),!,
  507.     reduce(A,Qa,Now,Fin),
  508.     reduce(B,Qb,Now,Fin).
  509. reduce(A,Q,Now,Fin):-
  510.     systemp(A),!,
  511.     myexec(A,Q,Now,Fin).
  512. reduce(A,Q,Now,Fin):-
  513.     t_clause(A,B),
  514.     reduce(B,Q,Now,Fin).
  515. %_________________________________________________________%
  516.  
  517. %_________________________________________________________%
  518. %-System predicates; added to original code.
  519. %-These predicates are either temporal or need not be further
  520. % expanded for temporal operators.
  521.  
  522. %PROLOG
  523. %These are Sicstus system predicates which need not be expanded by TOKIO.
  524. systemp(\+(A)).
  525. systemp(nonvar(X)).
  526. systemp(var(X)).
  527. systemp(true).
  528. systemp(fail).
  529. systemp(A = B).
  530. systemp(A =< B).
  531. systemp(A - B).
  532. systemp(A * B).
  533. systemp(A + B).
  534. systemp(A is B).
  535. systemp(A \== B).
  536. systemp(setof(X,Y,Z)).
  537. systemp(write(X)).
  538. systemp(writeq(St, X)).
  539. systemp(close(St)).
  540. systemp(open(St)).
  541. systemp(open(F, Mode, St)).
  542. systemp(read(X)).
  543. systemp(read(St, X)).
  544. systemp(!).
  545. systemp(call(A)).
  546. systemp([H|T]).
  547. systemp(see(X)).
  548. systemp(seen(X)).
  549. systemp(tell(X)).
  550. systemp(told(X)).
  551. systemp(nl).
  552.  
  553. %UTILITIES
  554. %These are general utilities which need not be expanded by TOKIO.
  555. systemp(swap(X, Y, L1, L2)).
  556. systemp(read_all_of_stream(St, X)).
  557. systemp(write_all_of_list(St, L)).
  558. systemp(to_string(X,Y)).
  559. systemp(append(X,Y,L)).
  560. systemp(member(X, L)).
  561.  
  562. %TEMPORAL
  563. %These predicates are the temporal operators supported by TOKIO.
  564. systemp(tnot(A)).                      % temporal not
  565. systemp(#A).
  566. systemp(A===B).
  567. systemp(length(A)).
  568. systemp(halt(A)).
  569. systemp(empty).
  570. systemp(notEmpty(A)).
  571. systemp(wnext(A)).
  572. systemp(fin(A)).
  573. systemp(keep(A)).
  574. systemp(A && B).
  575. systemp('$int'(A,B,C)).
  576. systemp(A<-- B).
  577. systemp(t(A)).
  578. systemp(@A).
  579.  
  580. %GRAPHICAL
  581. %These predicates implement primitive system calls for graphics system Prelog
  582. % for more on this see Johnson and Harrison `89.
  583. %systemp(mtab(R)).                     %write tab to region R
  584. %systemp(regborder(R, Width)).         %border of Width pixels for region R
  585. %systemp(regwrite(R, Text)).           %write Text to region R
  586. %systemp(regnl(R)).                    %write newline to region R
  587. %systemp(regclear(R)).                 %clear region R of graphical content
  588. %systemp(bread(Text)).                 %block on read from Prelog
  589. %systemp(clear(R)).
  590. %systemp(pswrite(R, T)).
  591. %systemp(rnl(R)).
  592. systemp(send(I)).
  593. %systemp(clear(R)).
  594. %_________________________________________________________%
  595.  
  596. %_________________________________________________________%
  597. t_clause(A,B):-
  598.     functor(A,Head,N),
  599.     functor(AA,Head,N),
  600.     clause(AA,B),
  601.     unify_all(A,AA).
  602. %_________________________________________________________%
  603.  
  604. %_________________________________________________________%
  605. %-Execute system predicate and perform relevant queue
  606. % manipulation.
  607. myexec(true,Q,_,_):- 
  608.     !,nonq(Q).
  609. myexec(length(N),Q,Now,Fin):- 
  610.     !, nonq(Q),
  611.     Fin is Now+N.
  612. myexec(empty,Q,Now,Fin) :- 
  613.     nonq(Q),!,
  614.     Now=Fin.
  615. myexec(notEmpty,Q,Now,Fin) :- 
  616.     !,enq_nonEmpty(halt(Fn),Q).
  617. myexec(halt(F),Q,Now,Fin):-
  618.     reduce(F,Q,Now,Fin),
  619.     !,Now=Fin.
  620. myexec(halt(F),Q,Now,Fin):- 
  621.     unifyNext(F, RFn),
  622.     enq_nonEmpty(halt(Fn),Q).
  623. myexec(#F,Q,Now,Fin):-
  624.     qap(Q1,Q2,Q),
  625.     enq_nxt(#Fn,Q1),
  626.     unifyNext(F,Fn),!,
  627.     reduce(F,Q2,Now,Fin).
  628. myexec(@F,Q,Now,Fin):-               % strong next
  629.     !,enq_nonEmpty(Fn,Q),
  630.     unifyNext(F,Fn).
  631. myexec(wnext(F),Q,Now,Fin):-           % weak next
  632.     enq_nxt(Fn,Q),
  633.     unifyNext(F,Fn),!.
  634. myexec(fin(F),Q,Now,Fin):-
  635.     !,((Now==Fin,!,reduce(F,Q,Now,Fin));
  636.     qap(Q1,Q2,Q),enq_fin(F,Q1),unifyNext(F, Fnn), enq_nxt(fin(Fnn),Q2)).
  637. myexec(keep(F),Q,Now,Fin):-
  638.     !,qap(Q1,Q2,Q),
  639.     enq_nfin(F,Q1),
  640.     unifyNext(F,Fnn),
  641.     enq_nxt(keep(Fnn),Q2).
  642. myexec((A && B),Q,Now,Fin):-
  643.     !,sub_exec(A,B,Q,Now,Fin,SubFin).
  644. myexec('$int'(A,B,SubFin),Q,Now,Fin):-
  645.     !,sub_exec(A,B,Q,Now,Fin,SubFin).
  646. myexec(A===B,Q,Now,Fin):- 
  647.     qap(Q1,Q2,Q),!,
  648.     eval(A,Va,Q1,Now,Fin),
  649.     eval(B,Vb,Q2,Now,Fin),
  650.     unifyNow(Va,V),
  651.     unifyNow(Vb,V).
  652. myexec(call(X),Q,Now,Fin):- 
  653.     !, reduce(X,Q,Now,Fin),
  654.     nonq(Q).
  655. myexec(tnot(X),Q,Now,Fin):- 
  656.     !, \+(reduce(X,Q,Now,Fin)),
  657.     nonq(Q).
  658. myexec(A<--B,Q,Now,Fin):-
  659.     !,eval(B,Vb,Q,Now,Fin),
  660.     unifyNow(Vb,A1),
  661.     unify_all(A,A1).
  662. myexec(S,Q,Now,Fin):-
  663.     unifyNow(S,SN),!,
  664.     SN,
  665.     nonq(Q).
  666. %_________________________________________________________%
  667.  
  668. %_________________________________________________________%
  669. %-Execute subinterval Now.
  670. sub_exec(F,L,Q,Now,Fin,SubFin):-
  671.     i_reduce(F,Fnext,Now,SubFin,Fin),
  672.     sub_exec_later(L,Fnext,Q,Now,Fin,SubFin).
  673. %_________________________________________________________%
  674.  
  675. %_________________________________________________________%
  676. %-Execute subinterval later.
  677. sub_exec_later(L,Next,Q,Now,Fin,Subfin):-
  678.     Now==SubFin,!,
  679.     reduce(L,Q,Now,Fin).
  680. sub_exec_later(L,Next,Q,Now,Fin,SubFin):-
  681.     unifyNext(L,Ln),
  682.     enq_finNext(L,'$int'(Next,Ln,SubFin),Q).
  683. %_________________________________________________________%
  684.  
  685. %_________________________________________________________%
  686. %-Evaluate functions.
  687. eval(Atom,Atom,Q,Now,Fin):-
  688.     (atomic(Atom) ; var(Atom); functor(Atom,'$t',2)),
  689.     nonq(Q),!.
  690. eval(@Var,Next,Q,Now,Fin):-
  691.     !,eval(Var,NowValue,Q,Now,Fin),
  692.     unifyNext(NowValue,Next).
  693. eval(A+B,V,Q,Now,Fin):-
  694.     !, qap(Q1,Q2,Q),
  695.     eval(A,Va,Q1,Now,Fin),
  696.     eval(B,Vb,Q2,Now,Fin),
  697.     unifyNow(Va,Vna),
  698.     unifyNow(Vb,Vnb),
  699.     V is Vna+Vnb.
  700.  
  701. eval(A-B,V,Q,Now,Fin):-
  702.     !, qap(Q1,Q2,Q),
  703.     eval(A,Va,Q1,Now,Fin),
  704.     eval(B,Vb,Q2,Now,Fin),
  705.     unifyNow(Va,Vna),
  706.     unifyNow(Vb,Vnb),
  707.     V is Vna-Vnb.
  708.  
  709. eval(S,S,Q,_,_):-
  710.     nonq(Q).
  711. %_________________________________________________________%
  712.  
  713. %_________________________________________________________%
  714. % NB. Difference lists used - very opaque code!!!
  715. % In the TOKIO interpreter (as opposed to compiler) there is a
  716. % single queue of the form: $t(N,F,K,C), where N is the next queue
  717. % F is for the fin queue, K  is for the keep queue and C keeps
  718. % the internal variables and current time.
  719. %-Queue structure 1      2      3         4
  720. %           q(Next-Next,Fin-Fin,Keep-Keep,Empty-Flag)
  721. qcl(Next,EmptyFlag,
  722.     q(Next-Next1,Fin0-true,Keep0-true,EmptyFlag),
  723.     q(Next1-true,Fin1-true,Keep1-true,EmptyFlag)).
  724. %_________________________________________________________%
  725. %-Queue append the 1 2 and 3 of first two arguments
  726. % so long as 4 is the same in both.
  727. qap(q(Next2-Next1,Fin2-Fin1,Keep2-Keep1,EmptyFlag),
  728.     q(Next1-Next,Fin1-Fin,Keep1-Keep,EmptyFlag),
  729.     q(Next2-Next,Fin2-Fin,Keep2-Keep,EmptyFlag)).
  730. %_________________________________________________________%
  731.  
  732. %_________________________________________________________%
  733. %-This true for 1 2 and 3 being empty
  734. nonq(q(Next-Next,Fin-Fin,Keep-Keep,EmptyFlag)).
  735. %_________________________________________________________%
  736.  
  737. %_________________________________________________________%
  738. %-Weak next
  739. enq_nxt(N, q((N,Next)-Next,Fin-Fin,Keep-Keep,EmptyFlag)).
  740. %_________________________________________________________%
  741.  
  742. %_________________________________________________________%
  743. %-Strong next
  744. enq_nonEmpty(N, q((N,Next)-Next,Fin-Fin,Keep-Keep,nonEmpty)).
  745. %_________________________________________________________%
  746.  
  747. %_________________________________________________________%
  748. enq_fin(F, q(Next-Next,(F,Fin)-Fin,Keep-Keep,EmptyFlag)).
  749. %_________________________________________________________%
  750.  
  751. %_________________________________________________________%
  752. enq_nfin(K, q(Next-Next,Fin-Fin,(K,Keep)-Keep,EmptyFlag)).
  753. %_________________________________________________________%
  754.  
  755. %_________________________________________________________%
  756. enq_finNext(F,N, q((N,Next)-Next,(F,Fin)-Fin,Keep-Keep,nonEmpty)).
  757. %_________________________________________________________%
  758.  
  759. %_________________________________________________________%
  760. get_fin(F,Q):-
  761.     arg(2,Q,F-_).
  762. %_________________________________________________________%
  763.  
  764. %_________________________________________________________%
  765. get_keep(K,Q):-
  766.     arg(3,Q,K-_).
  767. %_________________________________________________________%
  768.  
  769. %_________________________________________________________%
  770. get_nonEmpty(EmptyFlag,Q):-
  771.     arg(4,Q,EmptyFlag).
  772. %_________________________________________________________%
  773.  
  774. %_________________________________________________________%
  775. nonEmpty(Q,Now,Fin):-
  776.     Now==Fin,!,
  777.     fail.
  778. nonEmpty(Q,Now,Fin):-
  779.     get_nonEmpty(nonEmpty,Q).
  780. %_________________________________________________________%
  781.  
  782. %_________________________________________________________%
  783. /* unifiers */
  784. unify_all(G,D):-
  785.     (var(G) ; var(D)),!,
  786.     G=D.
  787. unify_all(F1,D):-
  788.     functor(F1,'$t',2),!,
  789.     unify_flt(F1,D).
  790. unify_all(D,F1):-
  791.     functor(F1,'$t',2),!,
  792.     unify_flt(F1,D).
  793. unify_all(Sa,Sb):-
  794.     functor(Sa,H,N),
  795.     functor(Sb,H,N),
  796.     unify_arg(N,N,Sa,Sb).
  797. %_________________________________________________________%
  798.  
  799. %_________________________________________________________%
  800. unify_arg(0,N,_,_):-!.
  801. unify_arg(M,N,Sa,Sb):-
  802.     arg(M,Sa,Aa),
  803.     arg(M,Sb,Ab),
  804.     unify_all(Aa,Ab),
  805.     M1 is M-1,!,
  806.     unify_arg(M1,N,Sa,Sb).
  807. %_________________________________________________________%
  808.  
  809. %_________________________________________________________%
  810. unify_flt('$t'(Now,Nxt),'$t'(Now,Nxt1)) :-
  811.     !,unify_all(Nxt,Nxt1).
  812. unify_flt('$t'(Now,Nxt),S) :-
  813.     unifyNow(S,Now),
  814.     unifyNext(S,Nxt1),
  815.     unify_all(Nxt,Nxt1).
  816. %_________________________________________________________%
  817.  
  818. %_________________________________________________________%
  819. %-Unify present identity of variables and predicates
  820. % (i.e. St(Y,X) and St(U,V) if Y===U).
  821. unifyNow(X,X1):-
  822.     myatomic(X),!,
  823.     X=X1.
  824. unifyNow('$t'(Now,_),Now1):-
  825.     !,Now=Now1.
  826. unifyNow(S,Sn):-
  827.     functor(S,H,N),
  828.     functor(Sn,H,N),
  829.     unifyNowArg(N,N,S,Sn).
  830. %_________________________________________________________%
  831.  
  832. %_________________________________________________________%
  833. %-Unify present identity of predicate arguments
  834. % (i.e. St(Y,X) and St(U,V) if Y===U).
  835. unifyNowArg(0,_,_,_).
  836. unifyNowArg(M,N,Sa,Sb):-
  837.     arg(M,Sa,Aa),
  838.     arg(M,Sb,Ab),
  839.     unifyNow(Aa,Ab),
  840.     M1 is M-1,!,
  841.     unifyNowArg(M1,N,Sa,Sb).
  842. %_________________________________________________________%
  843.  
  844. %_________________________________________________________%
  845. %-Unify next identity of variables and predicates
  846. % (i.e. St(Y,X) and St(U,V) if X===V).
  847. unifyNext(X,X):-
  848.     myatomic(X),!.
  849. unifyNext('$t'(_,Next),Next1):-
  850.     !,Next=Next1.
  851. unifyNext(S,Sn):-
  852.     functor(S,H,N),
  853.     functor(Sn,H,N),
  854.     unifyNextArg(N,N,S,Sn).
  855. %_________________________________________________________%
  856.  
  857. %_________________________________________________________%
  858. unifyNextArg(0,_,_,_).
  859. unifyNextArg(M,N,Sa,Sb):-
  860.     arg(M,Sa,Aa),
  861.     arg(M,Sb,Ab),
  862.     unifyNext(Aa,Ab),
  863.     M1 is M-1,!,
  864.     unifyNextArg(M1,N,Sa,Sb).
  865. %_________________________________________________________%
  866.  
  867. %_________________________________________________________%
  868. %-More modifications 
  869. myatomic(X):-
  870.     nonvar(X),
  871.     atomic(X).
  872. %_________________________________________________________%
  873.  
  874. %_________________________________________________________%
  875. %-This clause is a loop hole back to PROLOG will suspend
  876. % the tokio interpreter for duration of call.
  877. t(X) :-
  878.     X.
  879. %_________________________________________________________%
  880. %_________________________________________________________%
  881. /* Predefined utilites */
  882. <>(F):-
  883.     (true && (F)).
  884. A gets B:- 
  885.     keep(B === (@A)).
  886. stable(A):-
  887.     keep(A === (@A)).
  888. B<-A:-
  889.     C<--A,
  890.     fin(B===C).
  891. tskip:-
  892.     length(1).
  893.  
  894. until(P, Q) :- tnot(Q), P, @(until(P, Q)).
  895. until(P, Q) :- Q.
  896.  
  897. %_________________________________________________________%
  898.  
  899.  
  900. *********** END
  901.  
  902. Sincerely,
  903. Toyin.
  904.  
  905.                 pOBODY'S Nerfect    - Anon.
  906.