Shen Prolog to get ASSERT and RETRACT

51 views
Skip to first unread message

Mark Tarver

unread,
Sep 21, 2022, 4:07:22 AM9/21/22
to Shen
I've been limping along with the FTP and trying to work
around not having ASSERT and RETRACT.  However the
results are not satisfactory.  I think I have a method of
introducing these features into Shen Prolog which is 
reasonably efficient (RETRACT will be very fast).

If successful this will be the second time that Shen Prolog
has been upgraded via the FTP.  It was humungous size
of FTP computations that forced the development of a
Prolog garbage collector for the S series kernel.  Prior to this
a Shen Prolog computation could only run for a few seconds.

Mark


Mark Tarver

unread,
Sep 21, 2022, 8:08:06 AM9/21/22
to Shen
ASSERT is in place.

(2-) (dynamic f)
[f]

(3-) (defprolog f
       b <--;)
(fn f)

(4-) (time (asserta [[f a] <--]))
run time: 0.015600100000000117 secs
(fn fA)

(5-) (prolog? (f a))
true

Next RETRACT.

Mark

Mark Tarver

unread,
Sep 21, 2022, 8:20:08 AM9/21/22
to Shen
ASSERT is constant time wrt to whatever code is attached to f.

Mark

nha...@gmail.com

unread,
Sep 21, 2022, 5:42:44 PM9/21/22
to Shen
'declare' and the sequent compiler might as well use assert too.

Mark Tarver

unread,
Sep 22, 2022, 3:32:19 AM9/22/22
to Shen
Shen, www.shenlanguage.org, copyright (C) 2010-2022, Mark Tarver
version: S34, language: Common Lisp, platform: SBCL 2.0.0
port 3.2, ported by Mark Tarver

(0-) (time (prolog? (asserta [[f a] <--;])))
run time: 0.015000000596046448 secs
true

(1-) (prolog? (f a))
true

(2-) (time (prolog? (retract [[f a] <--;])))
run time: 0.0 secs
true

(3-) (prolog? (f a))
false

retract just involves changing the value returned by  a pointer and 
does not invoke the Prolog compiler.  Ergo the speed.

Mark

Mark Tarver

unread,
Sep 22, 2022, 3:34:55 AM9/22/22
to Shen
On Wednesday, 21 September 2022 at 22:42:44 UTC+1 nha...@gmail.com wrote:
'declare' and the sequent compiler might as well use assert too.

Well you have include and preclude for type theories.

M. 

nha...@gmail.com

unread,
Sep 22, 2022, 9:55:05 AM9/22/22
to Shen
For the Chez/SWI backend of Shen I have t-star call shen.lookupsig directly,  and the implementation of 'declare'  just asserts and retracts as needed.

Seems much more straightforward, and probably faster on this particular port due to FFI overhead. 

Mark Tarver

unread,
Sep 23, 2022, 3:11:54 AM9/23/22
to Shen
Seems sensible, you can also have overloaded types that way.

M.

Reply all
Reply to author
Forward
0 new messages