1 Logic Programming based Internet Technologies 2000 International Summer School in Computational...
-
Upload
bernard-briggs -
Category
Documents
-
view
214 -
download
0
Transcript of 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational...
![Page 1: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/1.jpg)
1
Logic Programming based Internet Technologies
2000 International Summer School in Computational LogicAcquafredda di Maratea (Basilicata, Italy) September 3-8, 2000
Copyright © 2000, Paul Tarau
Paul TarauUniversity of North Texas
&BinNet Corporation
![Page 2: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/2.jpg)
2
Logic Programming based Internet Technologies
Paul TarauPaul Tarau
[email protected]@cs.unt.edu
http://www.cs.unt.edu/~tarauhttp://www.cs.unt.edu/~tarau
http://www.binnetcorp.comhttp://www.binnetcorp.com
![Page 3: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/3.jpg)
3
PART I: An Overview of Internet Development Trends
• A Goal Oriented view:
– WHY to develop for the Internet?
– WHAT to develop for the Internet?
– HOW to develop for the Internet?
![Page 4: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/4.jpg)
4
Internet Growth: driven by E-Commerce
• Critical mass needed: ~20% online
• from random graphs: sudden emergence of a big component
• Growth of E-commerce (US)1998 -> $29 billion1999 -> $98.4 billion2003 -> $1.2 trillion (source: eMarketer)
![Page 5: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/5.jpg)
5
Buying over the Internet
• Initial markets: software, travel, books, CDs - MP3
• online stock trading: Schwab, E-Trade, Suretrade
• online grocery: back to the future:-) HomeGrocer, NetGrocer
• online drugstores, cars, jobs, entertainment, etc.
![Page 6: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/6.jpg)
6
Auctioning systems/electronic markets
• eBay, priceline
• price comparison/item matching agents:
– EBay's Personal Shopper
– Amazon’s book recommandations
• more conventional shopping chart?
• refereal programs: Amazon, priceline
![Page 7: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/7.jpg)
7
Trends in E-Commerce
• Integration of e-commerce and corporate data processing systems– backend databases: DB2, Oracle
• Complete e-commerce solutions vs. component based e-commerce systems– complete solution offerings: IBM– CGI scripts (Perl), servlets, SSI, Active
Server Processes (ASP), Java based JSP
![Page 8: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/8.jpg)
8
Internet based e-commerce infrastructure
• WWW - still in exponential growth for the next few years
• payment is just Information Exhange - subject to automation!
• Shopping by features: search, online browsing can do it better than asking a (not always) knowledgeable salesperson
• place for LP/CP: the need for intelligent knowledge processing
![Page 9: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/9.jpg)
9
Encryption, digital signatures
• conventional cryptography: DES, BlueFish• public key cryptography: RSA, PGP• confidentiality: PGP only a given group can
decode, no need for key exchange• authentication
– digital signature, certificates - VeriSign etc. – new US law – Fall 2000 !!!
• virgin territory for LP/CP: cryptography! Code breaking: a CLP problem !!!
![Page 10: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/10.jpg)
10
Secure transactions
• SSL basic security built in most browsers, alternative: SHTTP– still much better than conventional paper
based security
• DES: is it good for business transactions? (40 bit ok, 128bit - truly secure)
![Page 11: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/11.jpg)
11
Forms of electronic payment
• Electronic Money
– anonymus, unforgeable, “sound” - a place for LL?
• smart cards - downloadable from online account
• is third party certification needed?
• E-checks vs. credit cards vs. e-cash
![Page 12: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/12.jpg)
12
Predictions/Trends?
• E-commerce will completely reshape financial institutions
• it is likely to replace various forms of catalog and mail order businesses
• successful in information based (books, CDs), high margin/low volume, expensive to keep in inventory products, B2B
![Page 13: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/13.jpg)
13
Search Engines, Portals, Service Sites
• Trend: from Information to Knowledge - a place for LP/CP
• Search engines: Google, AltaVista, Snap, AskJeves - NL
• Portals: Yahoo, Lycos• Specialized service sites:
– books: www.amazon.com– travel: www.travelocity.com
![Page 14: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/14.jpg)
14
Complete Knowledge Management Solutions
• http://www.excalib.com/ RetrivalWare, Internet Spider, WebExpress
• Intelligent search, knowledge management
• Very highly priced complete solutions:
– Document management, paperless office, multiple formats, intranet/Internet search
– A chance for LP: Prolog as SuperPerl !!!
![Page 15: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/15.jpg)
15
Typical Features of KM tools - WebExpress 2.0
• SGML, XML and meta-tag support
• Multiple language plug-in architecture
• High-level Java API customization
• Support for over 200 data types, including popular web formats such as HTML and PDF
• Easy LP link: Jinni 2000 – all in Java
![Page 16: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/16.jpg)
16
File Sharing Communities
• NAPSTER - virus-like sharing: downloads become automatically uploadable
• Gnutella - no central server - GNU license
• MP3.com => Rio Player -> Sony?
• complex legal issues - piracy vs. legitimate sharing - similar to giving a CD to a friend?
![Page 17: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/17.jpg)
17
Basics of Internet Infrastructure: TCP/IP
• packet switching vs. dedicated point-to-point link
• Post Office (small packets ) vs. Phone Center (point-to-point link)
• IP header: address 129.120.44.123 vs.
• domain based naming: www.cs.unt.edu
![Page 18: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/18.jpg)
18
Static vs. Dynamic IP addresses
• self contained server and web site: static IP
• connecting through an ISP: dynamic IP:-(
– in fact, this comes from running out of available IP addresses - upcoming extended IP numbers might solve this - it is quite humiliating for users to be: cust007.my_isp.com instead of being www.JamesBond.com :-)
![Page 19: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/19.jpg)
19
How to create and register a new domain?
• www.internic.net: (not a NSI monopoly anymore!)
• new agency: http://www.icann.org/
• http://www.networksolutions.com/
• Whois service: http://www.nsiregistry.com/
![Page 20: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/20.jpg)
20
How to create a Web Site?
• Dedicated server – static IP, domain name– T1 (large volume, high cost) or ISDN
(metered, slow, starts to look outdated)– new: DSL: ADSL vs. SDSL)– What OS? Linux+Apache (more flexible)
NT (compatible with other MSoft tools)• Through Web hosting (inexpensive and
reliable but less flexible)
![Page 21: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/21.jpg)
21
Hypertext Markup Language (HTML) basics
• <HTML>
• <HEAD>
• <TITLE> Welcome To My Page </TITLE>
• </HEAD> <BODY>
– other html code
• </BODY>
• </HTML>
![Page 22: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/22.jpg)
22
Adding Links
• <A HREF=
• “http://www.mycompany.com”>
• My Company
• </A>
• In the Web page it looks like this:
– … My Company …
• <A HREF="mailto:[email protected]">my email</A>
![Page 23: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/23.jpg)
23
Including Images and Sound
• <IMG SRC=pictures/me_and_my_dog.gif>
• good compression: JPG
• animated GIFs - easy to make - size can be a problem
• Sound: MID (small) WAV, AU (older formats) MP3 (high quality)
• static (tag: EMBED, BGSOUND) vs. streaming audio/video: RealAudio
![Page 24: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/24.jpg)
24
Including CGI scripts
• <form method="post”
• action="http://a.b.c.d/cgi-bin/myscript.exe?query=who" >>
• <input type="submit" size="40" value="Search">
• </form>
![Page 25: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/25.jpg)
25
Including Java Applets
• <applet
• code=”myapplet.class"
• height="200" width="600” >
– <param
• value=”999”
• name=”default_price" >
• </applet>
![Page 26: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/26.jpg)
26
Tools for Building Web Sites
• HTML, tables, forms, CGI scripts
• server side tools: SSI, ASP, servlets
• Media formats: GIF, JPEG, MPEG, real audio
• Executable content: Java
![Page 27: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/27.jpg)
27
Design tools
• Composer, Microsoft Word, FrontPage
– Generating HTML
• Generating Java applets: Symantec, J++ 6.0
• Generating 3D content: VR Creator, TrueSpace
• LP/CLP tools need to interoperate with them!
![Page 28: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/28.jpg)
28
Alternative Content Formats
• VRML - now supported also by Java3D
– has links like in HTML
– has superior navigation
– has higher information density
• The future is 3D - the Nintendo generation grows up:-)
• LP/CLP tools should interoperate with the emerging 3D Web
![Page 29: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/29.jpg)
29
Conclusion of PART I
• LP/CLP comes late into the Internet Business
• it should get into fast growing or still emerging areas– e-commerce, B2B, KM, vertical markets– intelligent search, knowledge processing,
agents– 3D Web, new Internet infrastructure
![Page 30: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/30.jpg)
30
Basic Internet Programming
see also online demos at:
• http://www.binnetcorp.com
![Page 31: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/31.jpg)
31
CGI Scripts - BinProlog: counter
main:-header,inc(X),show_counter(X).
header:- write('220 ok'),nl, write('content-type: text/html'),nl,nl.
show_counter(X):-write(counter(X)),write('.'),nl.
inc(X):- F='cstate.pro', ( see_or_fail(F)-> see(F),read(counter(X)),seen ; X=0 ),X1 is X+1, tell(F),show_counter(X1),told.
![Page 32: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/32.jpg)
32
Installing a CGI Script
• Put the bp executable+script in a directory like cgi-bin
• Call it from a HTML page as follows:
<TITLE> BinProlog CGI counter</TITLE><HTML><BODY>Try a BinProlog based<A HREF= "/bp_inet/bin/bp.exe?$/bp_inet/cgi/counter.pro"> CGI Web-counter! </A> </BODY></HTML>
![Page 33: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/33.jpg)
33
A BinProlog Query Evaluator
• A more complex script (see files cgi/query.pro and cgi/query.html) needs to be used to pass information from a HTML file to the Prolog script.
• BinProlog's cgi_lib.pro library uses POST method for sending information to the server.
• This means, that after some basic header exchange, the client will read and parse from the standard input field names/field data pairs.
• This is achieved by components in cgi_lib.pro, the script itself matches the expected parameters and proceeds with its specific tasks.
![Page 34: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/34.jpg)
34
CGI script for querying BinProlog over the net
:-['../library/cgi_lib'].
:-['../library/http_tools'].
main:-run_cgi(5,body).
% POST method body
![Page 35: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/35.jpg)
35
CGI query script - continued
body:-
(get_cgi_input(Alist)->true;test,fail),
Alist = [
login=Ls, passwd=Ps,email=Ms,
home=Hs,query=Qs,editor=Es
]
->
( run_it(Ls,Ps,Ms,Hs,Qs,Es)->true
; write('Error in query: '),write_chars(Qs),nl
)
; ( write('Non matching fields in form'),fail ; nl).
![Page 36: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/36.jpg)
36
BinNet HTTP Client
• reconsult_url(AtomicURL): reconsults a Prolog file from a Web server i.e. replaces each predicate with a new definition found there, asserted to the current database
• http2line(AtomicURL,Line): Opens a URL, then gets a stream of lines of chars from the WWW server. It will backtrack over them.
![Page 37: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/37.jpg)
37
URL example:
AtomicURL='http://…/test.txt’ pointing to the a file containing the lines:
This
is
a test.
![Page 38: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/38.jpg)
38
URLs as files -how it works?
?- http2line('http://…/test.txt',Line).
....
.... % some header lines
....
Line=[84,104,105,115];
Line=[105,115];
Line=[97,32,116,101,115,116,46];
no
![Page 39: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/39.jpg)
39
VRML in Prolog: a Case Study in Classic Internet Programming
• a Prolog to VRML mapping allowing generation of dynamic VRML pages through CGI and server side Prolog scripts – Assumption Grammars are used to mimic VRML
syntax and semantics – integrated knowledge processing and 3D data
visualization applications – self-contained BinProlog application: Web Server,
Data Extraction module and an Assumption Grammar based VRML generator
– Web programming: a simple CGI-script
![Page 40: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/40.jpg)
40
Motivation
• Internet programming: a richer infrastructure than HTML based "flat" WWW
• Goal: `intelligent' agent programming in multi-user Virtual Worlds (VRML'97, Java3D, synchronized worlds) unified and scalable framework for coordination, remote execution, Web connectivity, remote execution mechanisms, mobile code
• Virtual Worlds: Social computing in a visual (3D, VRML 2.0, animated) framework
![Page 41: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/41.jpg)
41
Overview of VRML
• the VRML scene is composed of nodes and routes • scalings, rotations and translations => transform nodes
(may be nested) • sensors
associated with geometry for sensing time interpolator nodes: keys => keyValues
• sensors can respond to: proximity to an avatar, mouse clicks/movement
• events are propagated with ROUTE statements between chained nodes
![Page 42: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/42.jpg)
42
VRML and Prolog: why?
• hierarchical space representation + event propagation for animation = VRML'97
• declarative SPACE representation and TRUTH representation share the same difficulties w.r.t TIME and change
• Prolog+VRML synergy: knowledge processing, inference <=> 3D visualization, animation, Internet
![Page 43: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/43.jpg)
43
Assumption Grammars
• AGs: multi-stream DCGs with implicit arguments and temporary assertions, scoping over the current AND-continuation
• Assumed code, intuitionistic and linear implication Clause=>Goal or [File]=>Goal ?- *a(13),-a(X),-a(Y)
• succeeds: (13) matches both a(X) and a(Y).Clause-:Goal or [File]-:Goal ?- +a(13),-a(X),-a(Y).fails: a(13) is usable only once!
![Page 44: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/44.jpg)
44
The Assumption Grammar API
*A and A=>B: add intuitionistic assumption A+A and A-:B: add linear assumption A-A: matches an assumption in curr. scope or fails#<Tokens : initializes/unifies the DCG stream#Token: matches or inserts a Token#>State: returns the current State?- #<[a,b,c,d],#A,#B,#>LeftOver.A=a, B=b,LeftOver=[c,d]?- #<Xs,#a,#b,#c,#>[].Xs=[a,b,c]
![Page 45: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/45.jpg)
45
Why AGs?
• The combination of DCG stream operations and assumptions is particularly well suited for generating hierarchical data structureswhere properties hold for selected subobjects.
![Page 46: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/46.jpg)
46
A syntactical mapping: VRML is Prolog
• VRML: hierarchical decomposition of the space in regions
• Prolog: terms as trees• concrete syntax: arguments are named, not
positional • VRML 2.0 ROUTES are structurally similar
to DCGs:• they are used to thread together streams of
change
![Page 47: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/47.jpg)
47
Pseudo VRML in Prolog: a PROTO
proto anAppearance @[ exposedField('SFColor')=color(1,0,0), exposedField('MFString')=texture@[]] @{ 'Appearance' @{ material='Material' @{ diffuseColor is color }, texture='ImageTexture' @{ url is texture }}}.
![Page 48: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/48.jpg)
48
How it looks in VRML?
VRML V2.0 utf8 PROTO anAppearance [ exposedField SFColor color 1 0 0 , exposedField MFString texture [] ] { Appearance { material Material { diffuseColor IS color } texture ImageTexture {url IS texture} } }
![Page 49: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/49.jpg)
49
Some Prolog Macros
shape(Geometry):- % based on scoped assumptions (=>) default_color(Color), toVrml( aShape @{ geometry(Geometry@{}), Color }
).
![Page 50: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/50.jpg)
50
Simple Shapes
sphere:- shape('Sphere').
cone:- shape('Cone').
cylinder:- shape('Cylinder').
box:- shape('Box').
![Page 51: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/51.jpg)
51
Using Prolog macros
group @{ children @[ `transform( translation(0,10,4),scale(2,2,2), rotation(0,0,0,0), [`sphere, `cone] ), `transform( translation(5,0,0),scale(1,3,6), rotation(0,1,0,1.5), [`box])]}.
![Page 52: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/52.jpg)
52
Using assumptions in the VRML generator macros
using a scoped implication to color blue a complete sub-object (cone) expressed itself as a macro:
![Page 53: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/53.jpg)
53
Saucer
def saucer = `transform( translation(0,1,1),scale(0.6,0.2,0.6), rotation(0.5,0.5,0,1.5), [ `sphere, % propagates a color over a region `(color(blue)=>>cone) ])
![Page 54: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/54.jpg)
54
From the Translator: (with Assumption Grammars)
toVrml(X):-number(X),!,#X.
toVrml(X):-atomic(X),!,#X.
toVrml(A@B):-!,#indent(=), toVrml(A), toVrml(B).
toVrml(A=B):-!,toVrml(A), toVrml(B).
toVrml(A is B):-!,#indent(=), toVrml(A), #'IS', toVrml(B).
toVrml({X}):-!,#'{',#indent(+), toVrml(X), #indent(-),#'}'.
toVrml(`X):-!,X.
toVrml(X):-is_list(X),!,
#'[',#indent(+), vrml_list(X), #indent(-),#']'.
toVrml(X):-is_conj(X),!,vrml_conj(X).
toVrml(T):-compound(T), #indent(=), vrml_compound(T).
![Page 55: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/55.jpg)
55
What's generated?
Group { children [ Transform { translation 0 10 4 scale 2 2 2 rotation 0 0 0 0 children [ # aShape is a VRML 2.0 PROTO! aShape { geometry Sphere{} color 0.7 0.8 0.8} , aShape { geometry Cone{} color 0.6 0.3 0.9} ] } , ..... ] }
![Page 56: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/56.jpg)
56
CGI based generator
• Figure
![Page 57: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/57.jpg)
57
Using the CGI based Generator
• the user clicks on button or VRML anchor
• a CGI script is invoked by the HTTP server
• the BinProlog based VRML generator is activated
• the dynamic VRML page is sent back to the client
• the browser's VRML plugin displays the results
![Page 58: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/58.jpg)
58
Server Side GeneratorFigure
![Page 59: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/59.jpg)
59
Using the Server Side Generator
Generator embedded in a Prolog server: • the user clicks on a button in a HTML form or on
VRML anchor • the VRML generator working as a server side
Prolog thread is activated• the dynamic VRML page is sent back to the client• the browser's VRML plugin displays the results
![Page 60: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/60.jpg)
60
Server + Web Agents
• Figure
![Page 61: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/61.jpg)
61
Prolog HTTP Server With VRML Generator, Web Data
Extraction and Persistent State
• multi-agent architecture
• multi-threaded Prolog engine
• blackboard constraints
• Linda coordination
• VRML/Java3D based visualization agents
• Prolog based reasoning agents
![Page 62: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/62.jpg)
62
Some cross-fertilization opportunities:
• Prolog is a great VRML syntax checker! • Prolog as a powerful macro language/static optimizer for
VRML• Prolog as an AI planner for complex intelligent avatar
movement in VRML• Prolog as a scripting language: TERMS represent well
trees of 3D object groupings! • completely powerless: Javascript • unnecessarily complex: Java+EAI
![Page 63: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/63.jpg)
63
MUDs, MOOs and Virtual Worlds
• traditionally direct phone links connect to MUDs, MOOs using telnet for chat and game playing - the Internet itself - a giant MUD?
• The standard container object is called a room
• People can move around the rooms in the virtual world and interact with other users
• MUDs come with a programming language that the users can use to program the behavior of objects in the environment
• User extensibility: a MUDs allow creation of new rooms and new objects, and to define their behaviors
• Virtual Worlds: MOOs in a visual (3D, VRML 2.0, animated) framework
![Page 64: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/64.jpg)
64
The LogiMOO project:
• a toolkit for creating Prolog based virtual worlds for distributed group-work over the Internet
• embedded in Netscape or Explorer
• NL interface: `controlled english'
• LogiMOO: unification for pattern retrieval - exclusively deterministic operations, unlike most Prolog based Linda systems
![Page 65: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/65.jpg)
65
Related work
ILPS'97 LP and Internet Tutorial
WWW and LP/CLP languages: M. Hermenegildo, M. Caro, G. Pueblo (the Madrid group)
they also did visualisation of program execution traces main difference: the ability to use assumptions to parameterize deep components of VRML trees a code transformer needs to be written to replace cylinders by cones in the Prolog sources of a VRML page we can expand a generic macro shape and then pass the actual value (cone or cylinder) as an intuitionistic assumption, when themacro is called, the effect of the assumption will generate either
![Page 66: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/66.jpg)
66
Conclusion PART II
• Prolog as a program generator for special purpose languages without processing abilities like VRML
• syntax-mapping: reuse of VRML programming skills
• Web based architectures for generating dynamic VRML, persistent server side state and multi-user synchronization
• Prolog can be used as a macro language for building compact template files
• typical AI components like Prolog planners can be used for realistic avatar movement in VRML worlds
• interesting synergy between Prolog’s Internet data extraction ability and VRML's animated 3D visualization.
![Page 67: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/67.jpg)
67
PART III Internet and Network Programming with Jinni
• LP languages are OLD - Prolog is already 20++• We need to specialize LP languages, transform
them, adapt them, change them radically, if needed, e.g:– Reading from a URL should be as simple as
reading from a file– Interacting over a socket should be as simple as
interacting on a local console– Computations should be able to move across
the network transparently
![Page 68: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/68.jpg)
68
Why we need a pure Java based Logic Programming Language?
• LP needs to be specialized for high level networking, easy handling of URLs, client-server computations, execution of multiple “agent” threads, handling of various Internet protocols
• Transparent access to zillions of Java libraries – it just seems the most pragmatic way to provide main stream programming patterns to logic programmers
![Page 69: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/69.jpg)
69
Jinni 2000: fast Prolog in pure Java
• 1 million LIPS Java based Prolog• integrates Kernel Prolog with fast continuation
passing BinWAM engine• runs even on Palm, Handspring (with Sun’s new
Java engine: K-machine) palmtops • blackboards, threads, remote predicate calls• agents: generalization of class and object based
OO systems – local and remote delegation mechanism
![Page 70: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/70.jpg)
70
Jinni Ontology
• Places: blackboards + a server thread listening on a port
• Things: Prolog terms, in particular Prolog clauses• Agents:
– a set of mobile threads initiated by a unique goal at a given Place
– coordination: through blackboards - some local, some remote
![Page 71: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/71.jpg)
71
Orthogonal Execution Mechanisms
• engines (1MLips compiled or lightweight)• threads + hubs• remote predicate calls• derived: blackboard operations
– basic Linda coordination, associative search
– blackboard constraints - react when something becomes true
![Page 72: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/72.jpg)
72
Engines as Generalized Iterators (Fluents): keep state minimal
Engine = an LD Resolution Interpreter with first order control: constructor+iterator– new_engine(Goal,AnswerPattern, Handle):
creates a new interpreter Handle solving Goal– new_answer(Handle,AnswerInstance): If
AnswerInstance is no then stops the engine, otherwise either returns a new answer, of the form the(AnswerInstance) or returns no if there are no more answers.
![Page 73: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/73.jpg)
73
findall/3
findall(X,G,Xs):- new_engine(G,X,E), new_answer(E,Answer), collect_all_answers(Answer,E,Xs).
collect_all_answers(no,_,[]). collect_all_answers(the(X),E,[X|Xs]):-new_answer(E,Answer), collect_all_answers(Answer,E,Xs).
![Page 74: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/74.jpg)
74
Thread Operations: minimal!
• bg(Goal,ThreadHandle)
• hub_ms(Timout): syncs M producers N consumers
• thread_join(T)
• sleep_ms(Duration)
• current_thread(ThisThreadHandle)
• Derived: thread_resume/1, thread_suspend/1
![Page 75: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/75.jpg)
75
Remote Predicate Calls
• run_server(Port,Pwd):
• ask_server(X,GX,Pwd,Host,Port,Result)
• abstract transport layer
– unicast sockets
– RMI, Corba, multicast sockets
![Page 76: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/76.jpg)
76
Basic Linda Operations (now derived)
• out(X): puts X on the blackboard
• in(X): waits until it can take an object matching X from the blackboard
• all(X,Xs): reads the list Xs matching X currently on the blackboard
• derived operations: cin/1, rd/1
![Page 77: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/77.jpg)
77
Assertional Constraints vs. Binding Constrains
• From: when nonvar(X) ...
• => when provable(X) … re-execution
• => when a_fact(X)… more realistic
• constraints on variable bindings are too fine-grained for distributed programming!
![Page 78: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/78.jpg)
78
Beyond Linda: Blackboard Constraint Operations
• wait_for(Pattern,Constraint): waits for a Pattern on the blackboard, such that Constraint holds, and when this happens, it removes the result of the match from the blackboard
• notify_about(Pattern): notifies about this Pattern one of the blocked threads which waits for it with a matching constraint
![Page 79: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/79.jpg)
79
Coordination with Blackboard Constraints
• Two threads: T1 (prod) and T2 (cons)
• ?-notify_about(stock_offer(aol,91)). %T1
• ?-notify_about(stock_offer(aol,89)). %T1
• % action triggered in T2 => Price=89
• ?-wait_for(stock_offer(aol,Price), %T2 less(Price,90)).
![Page 80: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/80.jpg)
80
Mobile Threads: Motivation
– paradigm shift towards networked, mobile, ubiquitous computing with increasingly complex patterns of interaction
– threads: needed for programming reactive/proactive mobile agents
– back to pure LP - a good thing - but let’s give it an expressiveness lift:-)
![Page 81: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/81.jpg)
81
mobile threads: WHY?
• Large database, small agent
• Speed-up: move to a fast processor and back, transparently
• here/there switch: same code can be run locally or remotely
• fault tolerance - move->run->come back
![Page 82: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/82.jpg)
82
mobile threads with First Order AND-continuations
• a:-b,c,d.• binarization: a(C)::-b(c(d(C))).• get_cont(C,C)::-true(C). % binarized• mobile threads algorithm:
– move/0: get continuation, send over the net, resume execution on target
– return/0: send back new continuation, resume execution back home
![Page 83: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/83.jpg)
83
A Simple API for mobile threads (Jinni 98, BinProlog 7.x)
• run_server/0, here/0, there/0, where/1: => local or remote focus
• set_this_host/1, set_this_port/1, set_that_host/1,set_that_port/1
• move/0, return/0 vs. remote_run/1• the(Pattern,Goal,Answer): runs Goal to
produce the(Answer) or no => here/there switch =>local/remote
![Page 84: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/84.jpg)
84
mobile threads vs. RPCs: move once, compute many times
• ?-for(I,1,1000), remote_run(println(I)), eq(I,1000).
• ?-there, move, for(I,1,1000), println(I), eq(I,1000).
![Page 85: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/85.jpg)
85
Examples of mobile threads
• Window 1: a mobile thread
• ?- there, move, println(on_server), member(X,[1,2,3]), return, println(back).
• Window 2: a server
• ?- run_server.
![Page 86: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/86.jpg)
86
The (Pseudo) Server-in -the Client Pattern
• a client thread emulates server functionality (works behind a firewall!):– pseudo_sever:-
in(todo(X)),call(X),pseudo_server.– ?- there,pseudo_server.
• the real client: there,out(todo(…))• communication: through a blackboard on a
(shared) real server
![Page 87: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/87.jpg)
87
Shared Virtual Worlds
• set-up a registration mechanism for agents on server
• publish state changes to shared blackboard on server with out/1
• one thread for each “ghost” (remote client) - too expensive!
• => NEED FOR MULTICAST
![Page 88: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/88.jpg)
88
A Classic Design Pattern, Publish/Subscribe: with mobile
threads + Linda operations• a reactive channel listener: in/1 loop
• ?-listen(fun(_)).
• selective channel publisher: out/1 loop
• ?-talk(fun(jokes)).
• will not match:
• ?-talk(stocks(quotes,nasdaq))
![Page 89: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/89.jpg)
89
The (Pseudo) Server in The Client Pattern
• a client thread emulates server functionality (works behind a firewall!):– pseudo_sever:-
in(todo(X)),call(X),pseudo_server.– ?- there,pseudo_server.
• the real client: there,out(todo(…))• communication: through a blackboard on a
(shared) real server
![Page 90: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/90.jpg)
90
The Octopus Agent Pattern
• branch out multiple Reactive Agent threads to various places using RPCs or mobile threads
• watch for patterns containing returned results on the local blackboard
• failure or non-termination of one thread have minimal effect: fault tolerance
![Page 91: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/91.jpg)
91
Designing Jinni Agent Classes
• Java layer: – code and type inheritance– reaction to events– libraries: Java3D, XML, special devices etc.
• Prolog layer– knowledge processing– reaction to blackboard constraints– mobile threads
![Page 92: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/92.jpg)
92
Design Patterns in Visual Jinni
• drives Java objects through handles
• meta-programming is essential
• Java events interoperate with blackboard coordination
• easy extension to incorporate access to Java2D and Java3d libraries
![Page 93: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/93.jpg)
93
Java Objects in Visual Jinni
jdialog(Query,Answer):-
new_frame('Jinni Dialog',border,F),
new_label(F,Query,_),
new_panel(F,flow,P),
new_button(P,'Cancel', out(bc(P,cancel))),
new_button(P,'Ok',out(bc(P,ok))),show(F),
in(bc(P,Answer)),destroy(F).
![Page 94: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/94.jpg)
94
Shared Virtual Reality Agents
• Web based: browser+EAI+Java+Jinni
• Jinni Server + Thin Jinni Applet Connector
• BETTER: Java 3D virtual worlds connected in a peer-to-peer Jinni network
![Page 95: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/95.jpg)
95
Educational Agents
• chat, self organizing groups, shared VR
• alerts triggered by blackboard constraints
• reusable agent hierarchies
• Wizard of Oz help desk: combined human and programmed agents
![Page 96: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/96.jpg)
96
A Multicast Layer for Jinni
• Multicasting:In a network, a technique that allows data, including packets, to be simultaneously transmitted to a selected set of destinations (Some networks, such as Ethernet, support multicast by allowing a network interface to belong to one or more multicast groups).
• API– run_mul_server(Host, Port)– remote_mul_run(Host, Port, X, G, PW,
Res)
![Page 97: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/97.jpg)
97
Basic Linda Operations with Unicast and Multicast
![Page 98: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/98.jpg)
98
Impact on Mobile Computers and transient IP systems
– Server/Servant duality - pulling commands through multicast - applets as servers
– SETI-style distriuted computing– mobile agents for mobile devices
![Page 99: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/99.jpg)
99
Applications: Tele - Teaching
• LANs are Multicast Capable• Student machines join multicast group of teaching
server (run_mul_server)• Messages and todo tasks Multicasted to student
machines (remote_mul_run(out(todo(X)))• The server can collect responses from local
blackboards with expanded concept of blackboard remote_mul_run(mul_all(answer(X))
![Page 100: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/100.jpg)
100
Dynamic Multicast based Tele-Teaching Chat
Work Done by Ravi Kiran Guntupalli
![Page 101: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/101.jpg)
101
Dynamic Multicast based Performance Rater
Work Done by Ravi Kiran Guntupalli
![Page 102: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/102.jpg)
102
Application: Java3d Games• API new_obj(name), move_obj(name,x,y,z), remove_obj(name)
• multicast - synchronization
• blackboard - preserve state.
• Prolog intelligent Logic Programming of agents
![Page 103: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/103.jpg)
103
Future Work on Multicast Agents
• multicast: UDP based unreliable Protocol
• number of places attached unknown
• blocking reads unreliable
• experimentation with Reliable Multicast
• experimentation outside LANs i.e. with Routers capable of multicast
![Page 104: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/104.jpg)
104
Conclusion of PART III
• Synergy between high performance networking and Prolog agents
• promising applications - networked AI games, tele-teaching, shared VR
![Page 105: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/105.jpg)
105
PART IV Programming with Fluents in Jinni 2000
Copyright © 2000, Paul Tarau
Paul TarauUniversity of North Texas
&BinNet Corporation
![Page 106: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/106.jpg)
106
Motivation
• uniform interface for controlling multiple interpreters and external stateful objects
• redesigning Prolog's system of built-in predicates: OO hierarchy (other Fluents)
• interoperation with the underlying Java system =>
• elegant integration of Internet Programming patterns
![Page 107: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/107.jpg)
107
What’s wrong with Prolog’s builtins?
• LP => forever young!• old, deprecated builtins - early Fortran, C
inspired design - consolidated into “industrial strength” ISO standard :-)
• Zeppelins vs. air plains => the paradigm consolidation disease (do we have it?)
• messy flat function set => we need a modern, clean, compositional OO hierarchy
![Page 108: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/108.jpg)
108
What’s wrong with Prolog’s reflection?
• call(X): control is not reflected properly - for instance backtracking is not a “first order” citizen
• basic things difficult: i.e. source level definition of exception handling
• general problem: lack of genericity (lists operations => conjunctions?)
![Page 109: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/109.jpg)
109
What are Fluents?
• simple stateful entities - evolving through an abstract set of stepping operations
• Files, URLs, client/server interaction streams, GUI event streams
• Prolog interpreters (and runtime engines): just other Fluents!
• => a way to map linear recursion to fast iteration
![Page 110: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/110.jpg)
110
Refactoring Prolog: a Fluent based design
• Kernel Prolog: a collection of Horn Clause Interpreters (Answer Sources) running LD-resolution on a given clause database and calling built-in operations
• a constructor: goal + answer pattern => answers can be explored one by one
• the Fluent encapsulating the state of the interpreter is very similar to a file or URL descriptor encapsulating the state of a Reader!
![Page 111: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/111.jpg)
111
Fluent Classes
class Fluent extends SystemObject {Fluent(Prog p) {trailMe(p);}protected void trailMe(Prog p) {
if(null!=p) p.getTrail().push(this);
}public void stop() {}protected void undo() {stop();}
}
![Page 112: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/112.jpg)
112
Source Fluents
abstract class Source extends Fluent {
Source(Prog p) {
super(p);
}
abstract public Term get();
}
![Page 113: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/113.jpg)
113
Sink Fluents
abstract class Sink extends Fluent {
Sink(Prog p) {super(p);}
abstract public int put(Term T);
public Term collect() {
return null;
}
}
![Page 114: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/114.jpg)
114
Fluent Composers I
• append_sources/3: creates a new Source with a get/2 operation such that when the first Source is stopped, iteration continues over the elements of the second Source.
• compose_sources/3: a cartesian product style composition, get/2 returnins pairs of elements of the first and second Source
• reverse_source/2 builds a new Source such that its get/2 returns in reverse order
![Page 115: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/115.jpg)
115
Fluent Composers II
• split_source/3 creates two Source objects identical to the Source given as first argument - allows writing programs which iterate over a given Source multiple times
• join_sinks(S1,S2,S) creates a sink S such that its put operation go to both S1 and S2
• discharge(Source,Sink): sends all the elements of the Source to the given Sink
![Page 116: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/116.jpg)
116
Fluent Modifiers
Fluent modifiers allow dynamically changing some attributes of a give Fluent
• set_persistent(Fluent,YesNo) is used to make a Fluent survive failure, by disabling its undo method, which, by default, applies the Fluent's stop method on backtracking
![Page 117: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/117.jpg)
117
Interpreters (and run-time engines) as Fluents
Engine = LD Resolution Interpreter with first order control: constructor+iteratoranswer_source(+Goal, +AnswerPattern,
-Handle): creates a new interpreterget(+Handle, -AnswerInstance): returns a
new answer the(AnswerInstance) or no if no more answers
stop(+Handle): frees resources
![Page 118: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/118.jpg)
118
Building some “built-ins”
% returns the(X) or no as first solution of G
first_solution(X,G,Answer):-
answer_source(X,G,Solver),
get(Solver,R),
stop(Solver),
eq(Answer,R).
![Page 119: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/119.jpg)
119
once/1 and not/1
% binds G to its first solution or fails
once(G):-first_solution(G,G,the(G)).
% succeeds without binding G, if G fails
not(G):-first_solution(_,G,no).
![Page 120: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/120.jpg)
120
Reflective Meta-Interpreters
% metacall/1: just reflects backtracking
% through element_of/2
metacall(Goal):-
answer_source(Goal,Goal,E),
element_of(E,Goal).
![Page 121: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/121.jpg)
121
Reflecting backtracking
element_of(I,X):-
get(I,the(A)),
select_from(I,A,X).
select_from(_,A,A).
select_from(I,_,X):-
element_of(I,X).
![Page 122: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/122.jpg)
122
Findall with Source Operations
findall(X,G,Xs):-
answer_source(X,G,Solver),
source_list(Solver,Xs).
![Page 123: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/123.jpg)
123
Internet Related Fluents:
• URL and ZIP/JAR reader fluents
• => consult(‘http://…./progs/test.pl’)
• url2tokens(‘http://…/test.html’,Tokens).
• URL, file, database, socket fluents – look all the same – this also extends to local and remote Prolog interpreters
![Page 124: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/124.jpg)
124
Conclusion of Part IV
• uniform interoperation of Horn Clause Solvers with stateful entities (Fluents)
• Integration of LP with external class libraries• a simplified Prolog built-in predicate system• => transparent handling of Internet objects and
protocols
![Page 125: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/125.jpg)
125
Links to LP/CLP Web resources
• http://www.clip.dia.fi.upm.es/miscdocs/pillow/pillow.html
• http://www.cs.mu.oz.au/~swloke/logicweb.html
• http://www.cs.kuleuven.ac.be/~bmd/PrologInJava
• http://www.amzi.com, http://www.lpa.co.uk
• http://www.ifcomputer.com
• http://www.mozart-oz.org/
• http://www.binnetcorp.com
• http://www.cs.unt.edu/~tarau
![Page 126: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/126.jpg)
126
LP & Web Tutorials
• Manuel Hermenegildo's tutorials:– http://www.clip.dia.fi.upm.es/lpnet/
pillow_sl_imperial/pillow_sl_imperial.html– http://www.clip.dia.fi.upm.es/lpnet/distrib_imp
erial/distrib_imperial.html• Mozart-Oz Documentation• http://www.mozart-oz.org/documentation
![Page 127: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/127.jpg)
127
LP & WWW workshops
• http://www.clip.dia.fi.upm.es/lpnet/iclp97.html
• http://www.informatik.uni-bonn.de/~jicslp96
• http://www.cs.vu.nl/~eliens/WWW6
• http://www.mpi-sb.mpg.de/conferences/CP97
• http://www-lp.doc.ic.ac.uk/lp-internet.html
![Page 128: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/128.jpg)
128
Conclusion
Internet Programming and LP:
• integrated with high level networking, agent programming, external components, various client-server protocols, mobile code
• essential use of multi-threading
• from CGI scripts and HTML to Java and new Web languages VRML, XML etc.
![Page 129: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September.](https://reader038.fdocuments.net/reader038/viewer/2022110209/56649e425503460f94b34497/html5/thumbnails/129.jpg)
129
Acknowledgements
• Partly based on joint work with Veronica Dahl, Koen DeBosschere, Bart Demoen, Stephen Rochefort, Satyam Tyagi, Anima Gupta, Devender Gollapalli
• Cross-influences –various LP/CLP groups, Madrid, Mozart-Oz, commercial Prologs
• Peter Wilson – port of BinWAM to Java• Java, VRML w3.org – free libraries and tools