PAC library for develop version available

classic Classic list List threaded Threaded
23 messages Options
12
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PAC library for develop version available

Kuniaki Mukai
Hi,

I have uploaded PAC library at

  http://web.sfc.keio.ac.jp/~mukai/pac-lite.zip

The PAC library defines term_expression/2, which implements following featues
on SWI-Prolog *develop*  version (> V7.1).

1.  anonymous predicates as meta-arguments,
2.  a limited functional expressions including applications, and
3.  regular expressions in DCG phrases.

To try PAC library:
1. unzip pac-lite.zip
2. % swipl   -f  '<path-to-the>/pac-lite/start-pac'
3. run sample queries  in the test-log.pl

I have announced the PAC library already, for instance, at a thread on
"[SWIPL] Conditional equations with a directive for flipping
arguments."  Still no documentation is available except the uploaded
source files.  Although I have been using the PAC library for years
for many small applications, many bugs may be there.

The zip file contains:

Readme this file
engine.pl helper predicates
expand-etc.pl expand etcetra    (for, repeat, sed, ...)
expand-pac.pl expand (compile)  pac  expressions
expand-word.pl expand words in phrase (e.g. regex)
interval-boole.pl compute boolean operation on intervals for regex.
math.pl demo on conditional equations
misc.pl misc
op.pl operaters declaration.
pac-init.pl initialization for pac.
pac-loader.pl loadging files
pac.pl include file for term_expansion
reduce.pl making generated goals slim
start-pac.pl main
test-log.pl sample queries.


I will appreciate for any comment or feedback.

Regards,

Kuniaki Mukai




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20140927/c91aceb9/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PAC library for develop version available

Michael Hendricks
On Sep 26, 2014 10:42 AM, "Kuniaki Mukai" <[hidden email]> wrote:
> I have uploaded PAC library at
>
>   http://web.sfc.keio.ac.jp/~mukai/pac-lite.zip

This sounds very useful. It would be great if you could bundle this up as a
package as described at http://swi-prolog.org/howto/Pack.html

That would allow others to run pack_install(pac) at the top level to
install and reuse the code locally.

Cheers.

Michael
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PAC library for develop version available

Kuniaki Mukai

On Sep 27, 2014, at 4:15, Michael Hendricks <[hidden email]> wrote:

> On Sep 26, 2014 10:42 AM, "Kuniaki Mukai" <[hidden email]> wrote:
>> I have uploaded PAC library at
>>
>>  http://web.sfc.keio.ac.jp/~mukai/pac-lite.zip
>
> This sounds very useful. It would be great if you could bundle this up as a
> package as described at http://swi-prolog.org/howto/Pack.html

Thank you for the pointer. Having visited the page, I think it is
one of the most useful and necessary information for me now.
I will learn and try the packaging system after your advice.

Kuniaki


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20140927/7fc73fd7/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PAC library for develop version available

Kuniaki Mukai
In reply to this post by Michael Hendricks
Hi,

I met an error message  while  "pack_install"-ing on SWI-Prolog V7.22
via GIT on Mac OSX Mavericks:

   % Contacting server at http://www.swi-prolog.org/pack/query ... ok
   Install callgraph@0.3.2 from https://github.com/samer--
   /prolog/raw/master/callgraph/release/callgraph-0.3.2.tgz Y/n?
   dyld: lazy symbol binding failed: Symbol not found:
   _archive_read_support_filter_all

    Expected in: flat namespace

Rembering similar troubles in the past, I have edited the build file of the
pl-develop directory so that LIBRARY_PATH and CPATH does not refer to
/usr/lib :

# On MacOS you need this to get some libraries from Homebrew (not Macports)
if [ "`uname`" = Darwin ]; then
  export LIBRARY_PATH=/usr/local/Cellar/readline/6.2.4/lib:/usr/local/Cellar/gmp/5.1.3/lib:/usr/local/Cellar/libarchive/3.1.2/lib
  export CPATH=/usr/local/Cellar/gmp/5.1.3/include:/usr/local/Cellar/readline/6.2.4/include:/usr/local/Cellar/libarchive/3.1.2/include

After this change of the build file, the pack_install  has worked fine.
Excluding "/usr/lib/"  seems a typical workaround for Mac OSX
SWI-Prolog users. I am not sure  on the exact reason why
such editing works, but  I hope this note will be useful for mac prolog users
who is suffering from similar trouble.

Kuniaki

> On Sep 27, 2014, at 4:15, Michael Hendricks <[hidden email]> wrote:
>
>> On Sep 26, 2014 10:42 AM, "Kuniaki Mukai" <[hidden email]> wrote:
>>> I have uploaded PAC library at
>>>
>>> http://web.sfc.keio.ac.jp/~mukai/pac-lite.zip
>>
>> This sounds very useful. It would be great if you could bundle this up as a
>> package as described at http://swi-prolog.org/howto/Pack.html
>
> Thank you for the pointer. Having visited the page, I think it is
> one of the most useful and necessary information for me now.
> I will learn and try the packaging system after your advice.
>
> Kuniaki
>


_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to cancel a package ?

Kuniaki Mukai
In reply to this post by Michael Hendricks

Hi,

I have uploaded two packages at http://www.swi-prolog.org/pack/list,
but unfortunately one of which is a wrong bundle.
Is there a way to cancel a package ?  The other package
is a recovery for the wrong one.

Thank you for your help in advance.

Regards

Kuniaki Mukai

_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

predutils package available (Re: PAC library for develop version available)

Kuniaki Mukai
In reply to this post by Michael Hendricks

Hi Michael,

I have managed to install "predutils" package, which I am calling pac library.
(ERROR message below is for  minor updates.)  

% swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.23-28-g70f014a)
Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- [library(predutils)].
true.

?- module(pac).
true.

pac:  ?- phrase(w("[^\\n]*$", A), `abc\n`, R).
A = [97, 98, 99],
R = [] ;
A = [97, 98, 99],
R = [] ;
false.

pac:  ?- val((X\X)@1, X).
X = 1 .

pac:  ?- maplist(pred([X, Y, X-Y]), [1,2,3],[a,b,c], R).
R = [1-a, 2-b, 3-c].

pac:  ?-

Anyway I have to write user manual for predutils  package.

BTW, the above query  "?- module(pac)."  is not necessary on my
local non_package version,  but as for installed package,  
without changing module,  the above three pac queries
do not work, with "undefined val/2", for example.
Maybe I am missing something related module behaviours in packaging
of SWI-Prolog.   I am new to packaging, and it is not easy task for me,
though I am enjoying a little also.

I am looking forward to exploring into your regex package soon.

Thank you for introducing packaging to me.


Kuniaki Mukai

On Sep 27, 2014, at 4:15, Michael Hendricks <[hidden email]> wrote:

> On Sep 26, 2014 10:42 AM, "Kuniaki Mukai" <[hidden email]> wrote:
>> I have uploaded PAC library at
>>
>>  http://web.sfc.keio.ac.jp/~mukai/pac-lite.zip
>
> This sounds very useful. It would be great if you could bundle this up as a
> package as described at http://swi-prolog.org/howto/Pack.html
>
> That would allow others to run pack_install(pac) at the top level to
> install and reuse the code locally.
>
> Cheers.
>
> Michael
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20140930/dbc54227/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to cancel a package ?

Jan Wielemaker-5
In reply to this post by Kuniaki Mukai
Hi Kuniaki,

On 09/29/2014 10:26 PM, Kuniaki Mukai wrote:
>
> Hi,
>
> I have uploaded two packages at http://www.swi-prolog.org/pack/list,
> but unfortunately one of which is a wrong bundle.
> Is there a way to cancel a package ?  The other package
> is a recovery for the wrong one.

Pity.  The way to recover from a wrong upload is simply to upload
a new version with a higher version number and then install that
yourself.  I think that "pac" is a better name as you call it
like that a long time and "predutils" is just a very generic
and non-descriptive name.

Once that is settled, I can throw the one you want to get rid
of out of the DB by hand.  For now, the pack refuses to be
analysed.  I'm sure someone will help sorting that out!

Congrats with your first pack!

        Cheers --- Jan

>
> Thank you for your help in advance.
>
> Regards
>
> Kuniaki Mukai
>
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Michael Hendricks
In reply to this post by Kuniaki Mukai
On Tue, Sep 30, 2014 at 12:22 AM, Kuniaki Mukai <[hidden email]>
wrote:

> I have managed to install "predutils" package, which I am calling pac
> library.
> (ERROR message below is for  minor updates.)
>

Congratulations on getting it working.  When I tried to install the pack, I
got an error message saying that the tarball contents had changed.  I
verified this by comparing the current tarball's SHA1
(2a551f0bd4fa491d03e2433eaf706e570b1e16d2) against the one listed on the
website (5679d4f08644a9d5eb1b5e50cb3b9e29ad129d1a).

If you need to change the contents of your pack, modify pack.pl to
increment the version number.  Then create a new tarball named after that
version number.  This preserves a history each pack and assures users that
they're downloading the right code.



> ?- [library(predutils)].
> true.
>

For what it's worth, I prefer the pack name "pac" as you tried with your
initial upload.  If you upload your next version as "pac", let Jan know and
he can delete the "predutils" pack.

?- module(pac).
> true.
>

This is needed because library(predutils) doesn't export the predicates
from module pac.  The documentation on modules should help:
http://swi-prolog.org/pldoc/man?section=modules

I hope that helps.

--
Michael
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Kuniaki Mukai

On Sep 30, 2014, at 23:29, Michael Hendricks <[hidden email]> wrote:

> On Tue, Sep 30, 2014 at 12:22 AM, Kuniaki Mukai <[hidden email]>
> wrote:
>
>> I have managed to install "predutils" package, which I am calling pac
>> library.
>> (ERROR message below is for  minor updates.)
>>
>
> Congratulations on getting it working.  When I tried to install the pack, I
> got an error message saying that the tarball contents had changed.  I
> verified this by comparing the current tarball's SHA1
> (2a551f0bd4fa491d03e2433eaf706e570b1e16d2) against the one listed on the
> website (5679d4f08644a9d5eb1b5e50cb3b9e29ad129d1a).
>
> If you need to change the contents of your pack, modify pack.pl to
> increment the version number.  Then create a new tarball named after that
> version number.  This preserves a history each pack and assures users that
> they're downloading the right code.

Thanks. I will keep this in mind.
>
>
>> ?- [library(predutils)].
>> true.
>>
>
> For what it's worth, I prefer the pack name "pac" as you tried with your
> initial upload.  If you upload your next version as "pac", let Jan know and
> he can delete the "predutils" pack.

I have named "pac". Thanks.

Let me explain about the acronym"
In my mind, "pac" means "Parametric Anonymous Clauses",
As in Prolog a predicate is a set of (definite) clauses,
so "pac" is nearly an acronym for "parametric anonymous predicate".
"pac" package  allows recursive predicate definitions like append/3.

This feature has been used in "pac" to compile regular expressions
in DCG phrases. By "parametric" I mean "globals".
I will be happy if "pac" will contribute to a coherent
extension of DCG phrases or meta argument expansion in Prolog.

>
> ?- module(pac).
>> true.
>>
>
> This is needed because library(predutils) doesn't export the predicates
> from module pac.  The documentation on modules should help:
> http://swi-prolog.org/pldoc/man?section=modules

Thanks. I will reread it.  Once I had some difficulty to understand
basic notions on module something like difference between "namespace"  
or "predicatebase". So I skipped it as my usual way.
I feel I have been paying to the skipping.  
For instance, it is only recent (few hours ago !) for me to notice that
assert(a:(b:-c)) is not equivalent to  assert(a:b :- c).

Kuniaki

>
> I hope that helps.
>
> --
> Michael
> -------------- next part --------------
> HTML attachment scrubbed and removed
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141001/e51dd9bf/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to cancel a package ?

Kuniaki Mukai
In reply to this post by Jan Wielemaker-5

Hi Jan,

For name of the package I have choosed "pac",
following suggestion of you and Michael. Thanks.

The url of the latest version  is
http://web.sfc.keio.ac.jp/~mukai/pac-0.5.5.tgz
which is also the initial version.

However, the packaging system indicates some failing to process pack "pac":
http://www.swi-prolog.org/pack/list?p=pac

Did I something wrong on packaging system ?  I am afraid so.

But, I have installed successfully "pac" package
on my machine by using the full URL:

?- pack_install("http://web.sfc.keio.ac.jp/~mukai/pac-0.5.5.tgz").

And, the "pac" package is working fine as I expected.

On the other hand, the query with package name without location fails with
exception error message:

?- pack_install(pac).

ERROR: open/3: source_sink `'pac/pack.pl'' does not
exist (No such file or directory)

   Exception: (6) prolog_pack:pack_install(pac) ?

I have no idea what to do with this problem.


Kuniaki


On Sep 30, 2014, at 16:11, Jan Wielemaker <[hidden email]> wrote:

> Hi Kuniaki,
>
> On 09/29/2014 10:26 PM, Kuniaki Mukai wrote:
>>
>> Hi,
>>
>> I have uploaded two packages at http://www.swi-prolog.org/pack/list,
>> but unfortunately one of which is a wrong bundle.
>> Is there a way to cancel a package ?  The other package
>> is a recovery for the wrong one.
>
> Pity.  The way to recover from a wrong upload is simply to upload
> a new version with a higher version number and then install that
> yourself.  I think that "pac" is a better name as you call it
> like that a long time and "predutils" is just a very generic
> and non-descriptive name.
>
> Once that is settled, I can throw the one you want to get rid
> of out of the DB by hand.  For now, the pack refuses to be
> analysed.  I'm sure someone will help sorting that out!
>
> Congrats with your first pack!
>
> Cheers --- Jan
>
>>
>> Thank you for your help in advance.
>>
>> Regards
>>
>> Kuniaki Mukai
>>
>> _______________________________________________
>> SWI-Prolog mailing list
>> [hidden email]
>> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>>
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141001/cc49a0f5/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Jan Wielemaker-5
In reply to this post by Kuniaki Mukai
Hi Kuniaki,

I've deleted the predutils registration.

?- pack_install(pac) works fine here.

I didn't really look into the details why the pack is not processed,
but quite likely it has to do with modulariry and operator usage.  The
pac package adds a lot of really generically named files to your library,
a number of which are not modules and seem  to fulfil diverse roles.

Things that server example purposes should go into a directory
`examples` instead of into the prolog directory.  Files there are
not analysed and do not end up in your (extended) Prolog library,
so you can put there whatever you like.

Helper files should also be banned from the prolog directory, especially
if they have generic names.  Many classical programs have a file `util.pl`.
If we allow for that habbit it packs, library(util) will be ambiguous.
The normal solution is to create a subdirectory, so you get

pac
  pac/prolog/pac.pl
  pac/prolog/pac/reduce.pl

Any .pl file below pac/prolog should be a module file and should use
:- use_module(...) to get its requirements.  The helper modules in
prolog/pac should typically start with e.g., :- module(pac_reduce, ...)
to avoid name conflicts.  Modules should export whatever needs to be
accessible from the outside, including operators.  Code using modules
should import the module using use_module/1 or use_module/2 and use
non-qualified calls.

A good thing to read is Michael Richter's tutorial on modules.

Writing libraries is a different thing than writing a program in user
space ...  I hope this helps

                --- Jan

On 10/01/2014 08:49 AM, Kuniaki Mukai wrote:
>> > This is needed because library(predutils) doesn't export the predicates
>> > from module pac.  The documentation on modules should help:
>> > http://swi-prolog.org/pldoc/man?section=modules
> Thanks. I will reread it.  Once I had some difficulty to understand
> basic notions on module something like difference between "namespace"  
> or "predicatebase". So I skipped it as my usual way.
> I feel I have been paying to the skipping.  
> For instance, it is only recent (few hours ago !) for me to notice that
> assert(a:(b:-c)) is not equivalent to  assert(a:b :- c).
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Kuniaki Mukai

Hi Jan,

On Oct 1, 2014, at 16:29, Jan Wielemaker <[hidden email]> wrote:

> Hi Kuniaki,
>
> I've deleted the predutils registration.

Thank you for spending the extra care.

>
> ?- pack_install(pac) works fine here.
>
> I didn't really look into the details why the pack is not processed,
> but quite likely it has to do with modulariry and operator usage.  

That sounds likely.  In fact, I am on the way to make the package
modular. I know how to do, except the pac top level (user) behaviour
around "expand_query". It will take some time.

> The pac package adds a lot of really generically named files to your library,
> a number of which are not modules and seem  to fulfil diverse roles.
> Things that server example purposes should go into a directory
> `examples` instead of into the prolog directory.  Files there are
> not analysed and do not end up in your (extended) Prolog library,
> so you can put there whatever you like.

I see.

> Helper files should also be banned from the prolog directory, especially
> if they have generic names.  Many classical programs have a file `util.pl`.
> If we allow for that habbit it packs, library(util) will be ambiguous.
> The normal solution is to create a subdirectory, so you get
>
> pac
>  pac/prolog/pac.pl
>  pac/prolog/pac/reduce.pl

I see.

> Any .pl file below pac/prolog should be a module file and should use
> :- use_module(...) to get its requirements.  The helper modules in
> prolog/pac should typically start with e.g., :- module(pac_reduce, ...)
> to avoid name conflicts.  Modules should export whatever needs to be
> accessible from the outside, including operators.  Code using modules
> should import the module using use_module/1 or use_module/2 and use
> non-qualified calls.

I see well.

> A good thing to read is Michael Richter's tutorial on modules.
>
> Writing libraries is a different thing than writing a program in user
> space ...  I hope this helps

Thanks for the quick and long reply.  I think it is not difficult
to transform  the "pac" package into fully modular one in a week,
using emacs grep heavily. The library should restrict interference to others
as minimal as possible.  Of course, I agree on this.  

Kuniaki


> --- Jan
>
> On 10/01/2014 08:49 AM, Kuniaki Mukai wrote:
>>>> This is needed because library(predutils) doesn't export the predicates
>>>> from module pac.  The documentation on modules should help:
>>>> http://swi-prolog.org/pldoc/man?section=modules
>> Thanks. I will reread it.  Once I had some difficulty to understand
>> basic notions on module something like difference between "namespace"  
>> or "predicatebase". So I skipped it as my usual way.
>> I feel I have been paying to the skipping.  
>> For instance, it is only recent (few hours ago !) for me to notice that
>> assert(a:(b:-c)) is not equivalent to  assert(a:b :- c).
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141001/76ef1955/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Richard A. O'Keefe
In reply to this post by Kuniaki Mukai

On 1/10/2014, at 7:49 PM, Kuniaki Mukai wrote:
> Let me explain about the acronym"
> In my mind, "pac" means "Parametric Anonymous Clauses",
> As in Prolog a predicate is a set of (definite) clauses,
> so "pac" is nearly an acronym for "parametric anonymous predicate".
> "pac" package  allows recursive predicate definitions like append/3.

Drat.  When I saw the name "PAC" I hoped it had something
to do with Probably Approximately Correct learning (see
http://www.cs.iastate.edu/~honavar/pac.pdf), a major theory
of machine learning.

"Parametric" really shouldn't mean "globals".

_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Kuniaki Mukai

On Oct 2, 2014, at 7:48, Richard A. O'Keefe <[hidden email]> wrote:

>
> On 1/10/2014, at 7:49 PM, Kuniaki Mukai wrote:
>> Let me explain about the acronym"
>> In my mind, "pac" means "Parametric Anonymous Clauses",
>> As in Prolog a predicate is a set of (definite) clauses,
>> so "pac" is nearly an acronym for "parametric anonymous predicate".
>> "pac" package  allows recursive predicate definitions like append/3.
>
> Drat.  When I saw the name "PAC" I hoped it had something
> to do with Probably Approximately Correct learning (see
> http://www.cs.iastate.edu/~honavar/pac.pdf), a major theory
> of machine learning.

Thank you for comment. I should have been careful.
Yes, PAC learning is now major, seems still rapidly developing.  
In fact, I am interested in the their recent
mathematical frameworks.

> "Parametric" really shouldn't mean "globals".

In general, differences between  usages of the following terms
are not not clear for me:
parameter
globals
variable
indeterminate
argument (place).

As far as my "PAC" concerns,  
the first argument of pred/2 and rec/2 term is simply called  "parameter",
and the occurrence of the "pred" and "rec" term in meta argument context
is replaced by an appropriately generated unary term with the parameter, and
with the definition of the unary term being asserted as
prolog standard predicate. For me, the behaviour of the parameter
looks very much like that of free variables of lambda calculus, (aside unification).
That is my reason for using "parametric" as "free".

Kuniaki





>
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141002/ab53879b/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Kuniaki Mukai
In reply to this post by Jan Wielemaker-5

Hi Jan,

I have updated pac to V-0.5.6 from V-0.5.5, following the guideline
in the tutorial in your previous message:
1) no predicates defined in pac can be called without module prefix qualififcation,
2) operator declarations are local to pac,
3) renaming module names attaching prefix "pac_" to avoid possible
confusions with that of other packages.

>> Writing libraries is a different thing than writing a program in user
>> space ...  I hope this helps

Deep words. I feel I have seen something of library builder's invisible efforts
for others happy life.

By the way, I would like to ask you an urgent and maybe stupid
question about module.  I thought exported names can be used from any
oother contexts, i.e., globally, like builtin append/3.  But a simple
experiment shows that it is not the case. So my question is: in
what contexts an exported name can be used without putting module
prefix before the name ? I have read the recommended document, but I am
afraid I have missed the point again.

Kuniaki


On Oct 1, 2014, at 16:29, Jan Wielemaker <[hidden email]> wrote:

> Hi Kuniaki,
>
> I've deleted the predutils registration.
>
> ?- pack_install(pac) works fine here.
>
> I didn't really look into the details why the pack is not processed,
> but quite likely it has to do with modulariry and operator usage.  The
> pac package adds a lot of really generically named files to your library,
> a number of which are not modules and seem  to fulfil diverse roles.
>
> Things that server example purposes should go into a directory
> `examples` instead of into the prolog directory.  Files there are
> not analysed and do not end up in your (extended) Prolog library,
> so you can put there whatever you like.
>
> Helper files should also be banned from the prolog directory, especially
> if they have generic names.  Many classical programs have a file `util.pl`.
> If we allow for that habbit it packs, library(util) will be ambiguous.
> The normal solution is to create a subdirectory, so you get
>
> pac
>  pac/prolog/pac.pl
>  pac/prolog/pac/reduce.pl
>
> Any .pl file below pac/prolog should be a module file and should use
> :- use_module(...) to get its requirements.  The helper modules in
> prolog/pac should typically start with e.g., :- module(pac_reduce, ...)
> to avoid name conflicts.  Modules should export whatever needs to be
> accessible from the outside, including operators.  Code using modules
> should import the module using use_module/1 or use_module/2 and use
> non-qualified calls.
>
> A good thing to read is Michael Richter's tutorial on modules.
>
> Writing libraries is a different thing than writing a program in user
> space ...  I hope this helps
>
> --- Jan
>
> On 10/01/2014 08:49 AM, Kuniaki Mukai wrote:
>>>> This is needed because library(predutils) doesn't export the predicates
>>>> from module pac.  The documentation on modules should help:
>>>> http://swi-prolog.org/pldoc/man?section=modules
>> Thanks. I will reread it.  Once I had some difficulty to understand
>> basic notions on module something like difference between "namespace"  
>> or "predicatebase". So I skipped it as my usual way.
>> I feel I have been paying to the skipping.  
>> For instance, it is only recent (few hours ago !) for me to notice that
>> assert(a:(b:-c)) is not equivalent to  assert(a:b :- c).
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141002/db5e2ec5/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Jan Wielemaker-5
On 10/02/2014 02:31 PM, Kuniaki Mukai wrote:
>>> Writing libraries is a different thing than writing a program in user
>>> space ...  I hope this helps

> Deep words. I feel I have seen something of library builder's invisible efforts
> for others happy life.

On the other hand, writing libraries isn't too different from writing
large application where you need code structuring.   Once you get the
hang of it, the extra structuring rules help you more than they hinder
you.

> By the way, I would like to ask you an urgent and maybe stupid
> question about module.  I thought exported names can be used from any
> oother contexts, i.e., globally, like builtin append/3.  But a simple
> experiment shows that it is not the case. So my question is: in
> what contexts an exported name can be used without putting module
> prefix before the name ? I have read the recommended document, but I am
> afraid I have missed the point again.

For most Prolog systems, a use_module/1 means you can use the code from
the module you are importing from only.  SWI-Prolog modules have a notion
of `default modules`: if a predicate cannot be found in a module, it will
try its default module (recursively).  All modules default to `user`, while
`user` defaults to `system`.  So, code that you write in (or import into)
user is visible in all modules, but can be locally overruled.  B.t.w.,
system library files default directly to `system`, so you cannot modify
their behaviour by writing things in `user`.  Operator inheritance follows
the same rules.

The defaulting scheme can be modified, which allows for defining other
visibility and reuse models.

        Cheers --- Jan
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Kuniaki Mukai
Hi Jan,

On Oct 2, 2014, at 23:23, Jan Wielemaker <[hidden email]> wrote:

> On 10/02/2014 02:31 PM, Kuniaki Mukai wrote:
>>>> Writing libraries is a different thing than writing a program in user
>>>> space ...  I hope this helps
>
>> Deep words. I feel I have seen something of library builder's invisible efforts
>> for others happy life.
>
> On the other hand, writing libraries isn't too different from writing
> large application where you need code structuring.   Once you get the
> hang of it, the extra structuring rules help you more than they hinder
> you.
>
>> By the way, I would like to ask you an urgent and maybe stupid
>> question about module.  I thought exported names can be used from any
>> oother contexts, i.e., globally, like builtin append/3.  But a simple
>> experiment shows that it is not the case. So my question is: in
>> what contexts an exported name can be used without putting module
>> prefix before the name ? I have read the recommended document, but I am
>> afraid I have missed the point again.
>
> For most Prolog systems, a use_module/1 means you can use the code from
> the module you are importing from only.  SWI-Prolog modules have a notion
> of `default modules`: if a predicate cannot be found in a module, it will
> try its default module (recursively).  All modules default to `user`, while
> `user` defaults to `system`.  So, code that you write in (or import into)
> user is visible in all modules, but can be locally overruled.  B.t.w.,
> system library files default directly to `system`, so you cannot modify
> their behaviour by writing things in `user`.  Operator inheritance follows
> the same rules.
>
> The defaulting scheme can be modified, which allows for defining other
> visibility and reuse models.

Thank you for your clear answer.  However, to be honest,
what I wanted to know is something on opposite direction
of the 'default'.

Although your answer has made me clear, let me put my intended
question in more concrete way. Suppose two module files "mod_a.pl" and
a `child` module "mod_b.pl" defined as follow:

%%%% file mod_a.pl %%%
:- module(mod_a, [hello/0]).
:- use_module(mod_b).
hello :- writeln('hello from ma.').

%%%% file mod_b.pl %%%
:- module(mod_b, [world/0]).
world :- writeln('world from mb').

% ls
mod_b.pl mod_a.pl

So setting the situation, I got the log below.  Of course,
that log is what everyone expects except me.

% swipl
Welcome to SWI-Prolog (Multi-threaded, 64 bits, Version 7.1.23-28-g70f014a)
Copyright (c) 1990-2014 University of Amsterdam, VU Amsterdam
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.

For help, use ?- help(Topic). or ?- apropos(Word).

?- use_module(mod_a).
true.

?- hello.
hello from ma.
true.

?- world.
Correct to: "mod_b:world"?
Please answer 'y' or 'n'?
ERROR: '$execute_goal2'/2: Undefined procedure: world/0
ERROR:   However, there are definitions for:
ERROR:         mod_a:world/0
ERROR:         mod_b:world/0
   Exception: (6) world ? abort
% Execution Aborted


I believed wrongly that imported predicates from "child modules" may get
global under some context.  In fact, I expected no error message for that
query.

My question was really stupid, but I appreciate a lot for
your taking time. I hope I am the only such a prologer.


Kuniaki



>
> Cheers --- Jan
> _______________________________________________
> SWI-Prolog mailing list
> [hidden email]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141003/1d8d38f4/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Modules (was Re: predutils package available (Re: PAC library for develop version available))

Jan Wielemaker-5
On 10/02/2014 05:35 PM, Kuniaki Mukai wrote:

> Although your answer has made me clear, let me put my intended
> question in more concrete way. Suppose two module files "mod_a.pl" and
> a `child` module "mod_b.pl" defined as follow:

Note that there is not really a notion of `child' modules.  Modules
can use each other (even mutually, by importing each other).

> %%%% file mod_a.pl %%%
> :- module(mod_a, [hello/0]).
> :- use_module(mod_b).
> hello :- writeln('hello from ma.').
>
> %%%% file mod_b.pl %%%
> :- module(mod_b, [world/0]).
> world :- writeln('world from mb').
>
> % ls
> mod_b.pl mod_a.pl

> ?- use_module(mod_a).
> true.
>
> ?- hello.
> hello from ma.
> true.
>
> ?- world.
> Correct to: "mod_b:world"?
> Please answer 'y' or 'n'?
> ERROR: '$execute_goal2'/2: Undefined procedure: world/0
> ERROR:   However, there are definitions for:
> ERROR:         mod_a:world/0
> ERROR:         mod_b:world/0
>    Exception: (6) world ? abort
> % Execution Aborted
>  
> I believed wrongly that imported predicates from "child modules" may get
> global under some context.  In fact, I expected no error message for that
> query.

That is indeed not what happens.  If you want that though, you can do two
things: export world/0 also from mod_a.pl, as in

:- module(mod_a, [hello/0, world/0]).
:- use_module(mod_b).
hello :- writeln('hello from ma.').

Or re-export:

:- module(mod_a, [hello/0).
:- reexport(mod_b).
hello :- writeln('hello from ma.').

rexport/1 is a simple use_module/1, followed by adding all
public predicates of the imported module to the export list
of the importing module.

In most situations, I'd go for the first solution with explicit
export of the imported predicates, as this makes it much easier
for the reader to see what you get from a module.  The reexport
was mainly added to create libraries derived from similar libraries
for portability reasons.   So, if I want to write a YAP compatible
library(lists), I can of course start from scratch.  But, 95% is
the same anyway, so I can write a library like this:

:- module(yap_lists, [ extra-stuff, ...]).
:- reexport(library(lists), except([ incompatible stuff ]).

<definitions for the extra and incompatible stuff>

Now, I've saved myself a lot of typing and at the same time
make it obvious what is different between the two modules.

> My question was really stupid, but I appreciate a lot for
> your taking time. I hope I am the only such a prologer.

Quite unlikely :-)

        Cheers --- Jan
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: predutils package available (Re: PAC library for develop version available)

Richard A. O'Keefe
In reply to this post by Kuniaki Mukai
'use_module' comes from Quintus Prolog.
The way it was intended to be used was

:- use_module(Module_Name, [
      Imported_Predicate_1/Arity_1,
      ...,
      Imported_Predicate_n/Arity_n
   ]).

It was considered to be important for software maintenance
that you should explicitly list all the predicates you
needed from the module.  Having done this, the imported
predicates are then available *without* requiring any prefix.

This is like the way you do

    from fractions import Fraction

in Python, after which you use fractions.Fraction as just
plain Fraction.

This is dual to the way that a :- module directive lists
all the things *exported* from a module.

The idea was that *all* the stuff relating to modules
(:- module, :- use_module, :- meta_predicate) should be
at the very top of a file, and the rest of the file
should as much as possible look as though modules did
not exist.


_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Modules (was Re: predutils package available (Re: PAC library for develop version available))

Kuniaki Mukai
In reply to this post by Jan Wielemaker-5
Hi Jan,

You  have made me clear on the module system, which is more than I expected.
Thank you.  Let me summarize your tutorial in my favourite terms
of graph theory.

The set of current modules form a DG (directed graph; possibly cyclic,
and not necessarily connected. ) A node (= a module) m is a direct
successor of a node m' if and only if m' has `:- use_module(m)'
directive (at the head).

Given a node m, the module system looks into the direct successors of
m in the DG, but does *NOT* look into others transitively along the
`use_module` links.

( I thought wrongly that it does `transitive search' along `use_module'
links.)

Now things look much simpler than I thought.
Your tutorial has recovered the hard  time lost of mine
for reading articles on modules. Thank you again.

Kuniaki

On Oct 3, 2014, at 1:01, Jan Wielemaker <[hidden email]> wrote:

> On 10/02/2014 05:35 PM, Kuniaki Mukai wrote:
>
>> Although your answer has made me clear, let me put my intended
>> question in more concrete way. Suppose two module files "mod_a.pl" and
>> a `child` module "mod_b.pl" defined as follow:
>
> Note that there is not really a notion of `child' modules.  Modules
> can use each other (even mutually, by importing each other).
>
>> %%%% file mod_a.pl %%%
>> :- module(mod_a, [hello/0]).
>> :- use_module(mod_b).
>> hello :- writeln('hello from ma.').
>>
>> %%%% file mod_b.pl %%%
>> :- module(mod_b, [world/0]).
>> world :- writeln('world from mb').
>>
>> % ls
>> mod_b.pl mod_a.pl
>
>> ?- use_module(mod_a).
>> true.
>>
>> ?- hello.
>> hello from ma.
>> true.
>>
>> ?- world.
>> Correct to: "mod_b:world"?
>> Please answer 'y' or 'n'?
>> ERROR: '$execute_goal2'/2: Undefined procedure: world/0
>> ERROR:   However, there are definitions for:
>> ERROR:         mod_a:world/0
>> ERROR:         mod_b:world/0
>>   Exception: (6) world ? abort
>> % Execution Aborted
>>
>> I believed wrongly that imported predicates from "child modules" may get
>> global under some context.  In fact, I expected no error message for that
>> query.
>
> That is indeed not what happens.  If you want that though, you can do two
> things: export world/0 also from mod_a.pl, as in
>
> :- module(mod_a, [hello/0, world/0]).
> :- use_module(mod_b).
> hello :- writeln('hello from ma.').
>
> Or re-export:
>
> :- module(mod_a, [hello/0).
> :- reexport(mod_b).
> hello :- writeln('hello from ma.').
>
> rexport/1 is a simple use_module/1, followed by adding all
> public predicates of the imported module to the export list
> of the importing module.
>
> In most situations, I'd go for the first solution with explicit
> export of the imported predicates, as this makes it much easier
> for the reader to see what you get from a module.  The reexport
> was mainly added to create libraries derived from similar libraries
> for portability reasons.   So, if I want to write a YAP compatible
> library(lists), I can of course start from scratch.  But, 95% is
> the same anyway, so I can write a library like this:
>
> :- module(yap_lists, [ extra-stuff, ...]).
> :- reexport(library(lists), except([ incompatible stuff ]).
>
> <definitions for the extra and incompatible stuff>
>
> Now, I've saved myself a lot of typing and at the same time
> make it obvious what is different between the two modules.
>
>> My question was really stupid, but I appreciate a lot for
>> your taking time. I hope I am the only such a prologer.
>
> Quite unlikely :-)
>
> Cheers --- Jan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.iai.uni-bonn.de/pipermail/swi-prolog/attachments/20141003/605578cf/signature.asc>
_______________________________________________
SWI-Prolog mailing list
[hidden email]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
12
Loading...