1 logic programming based internet technologies 2000 international summer school in computational...

129
1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September 3- 8, 2000 Copyright © 2000, Paul Tarau Paul Tarau University of North Texas & BinNet Corporation

Upload: bernard-briggs

Post on 27-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Logic Programming based Internet Technologies 2000 International Summer School in Computational Logic Acquafredda di Maratea (Basilicata, Italy) September

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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