[squeak-dev] [ANN] Prolog update

rabbit rabbit at callistohouse.org
Tue Oct 4 21:52:13 UTC 2022


Cool! This sounds interesting. I’m still trying to stabilize my image 
before loading this package. Would you mind posting to us with some 
example squeak code using Prolog? Or in some examples in Prolog if your 
classes use a different compiler…it has been a minute since my only 
small contact in grad school with this language. What makes it 
interesting, Stéphane? A logic language?

Yes I googled her:

https://athena.ecs.csus.edu/~mei/logicp/prolog/programming-examples.html

       ?- Example 1 :Below food table shows the facts, rules, goals and
    their english meanings.

Facts
	English meanings
food(burger). 	// burger is a food
food(sandwich). 	// sandwich is a food
food(pizza). 	// pizza is a food
lunch(sandwich). 	// sandwich is a lunch
dinner(pizza). 	// pizza is a dinner

	
Rules 	
meal(X) :- food(X).

	// Every food is a meal OR
Anything is a meal if it is a food

	
Queries / Goals 	
?- food(pizza).
	// Is pizza a food?
?- meal(X), lunch(X).
	
// Which food is meal and lunch?
?- dinner(sandwich).
	
// Is sandwich a dinner?

---

I’m thinking this may be an alternative approach for expressing ELinda 
(eventually match reactors) matching [really Linda matching].

Here's some eventual linda matching going on....

    /Installer ss project: 'Promises'; install: 'ELinda'./

    "with 2 seperate #evals"
        | pattern count |
         ETupleSpace clearDefault.
         count := 0.
         pattern := ( 'factorial' ! Integer ! Integer ).
         ( 'factorial' ! 3 ! [ 3 factorial] ) eval.
         (Delay forMilliseconds: 3) wait.
         pattern *rde* whenResolved: [:tuple | count := count + 1].
         self assert: (ETupleSpace default *scan*: pattern copy) size = 1.
         ( 'factorial' ! 6 ! [ 6 factorial] ) eval.
         (Delay forMilliseconds: 3) wait.
         self assert: (ETupleSpace default *scan*: pattern copy) size = 2.
    ETupleSpace clearDefault.

    "with 1 #eval and 2 eventual reactor registrations with #rde (read
    eventual)"
    ETupleSpace clearDefault.
         count := 0.
         self assert: (count = 0).
         pattern *rde* whenResolved: [:tuple | count := count + 1].
         ( 'factorial' ! 6 ! [ 6 factorial] ) eval.
         (Delay forMilliseconds: 3) wait.
       self assert: (count = 1).
         self assert: (ETupleSpace default *scan:* pattern copy) size = 1.
         pattern *rde* whenResolved: [:tuple | count := count + 1].
         (Delay forMilliseconds: 3) wait.
         self assert: (count = 2).
    ETupleSpace clearDefault.

    "with 1 #eval and 2 eventual reactor registrations #ine (publish
    eventual)"
    ETupleSpace clearDefault.
         count := 0.
         self assert: (count = 0).
         pattern ine whenResolved: [:tuple | count := count + 1].
         self assert: (count = 0).
         ( 'factorial' ! 6 ! [ 6 factorial] ) eval.
         (Delay forMilliseconds: 3) wait.
         self assert: (count = 1).
         pattern ine whenResolved: [:tuple | count := count + 1].
         (Delay forMilliseconds: 3) wait.
         self assert: (count = 2).

Here is the Linda ETuple>>#match: method

    match: anotherTuple
         "Returns true if there is matching"

         | pSelf pOther |

         anotherTuple isEventual ifTrue: [^ anotherTuple match: self].
         ( self arity = anotherTuple arity ) ifFalse: [ ^ false ].

         1 to: self arity do: [ :i  |
             pSelf := self parameter: i.
             pOther := anotherTuple parameter: i.
             (self matchElements: pSelf and: pOther)
                 ifFalse: [ ^ false ]].
         ^ true

Could this be easily done using Prolog?

Have a Good One; Keep it, Light.
Kindly,
rabbit
. .. … ‘…^,^


Sent from Callisto House :: decentralized mobile homeless solutions

> On Oct 4, 2022, at 16:52, Stéphane Rollandin <lecteur at zogotounga.net> 
> wrote:
>
> Hello,
>
> After about 13 years (!) I went back to Prolog and released a new 
> update, with some major refactoring, which loads fine in 6.0.
>
> It's there:
> http://www.zogotounga.net/comp/squeak/prolog.htm
>
> and on SqueakMap:
> http://map.squeak.org/package/cb6c7afe-d517-470f-8857-d764ef321725/autoversion/21
>
> BTW I noticed on SqueakMap that the licence is SqueakL from Disney
> It is possible to make it MIT? What would it take?
>
> Stef
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20221004/542c3a88/attachment-0001.html>


More information about the Squeak-dev mailing list