Code Monkey home page Code Monkey logo

ciao-lang / ciao Goto Github PK

View Code? Open in Web Editor NEW
244.0 21.0 18.0 13.9 MB

Ciao is a modern Prolog implementation that builds up from a logic-based simple kernel designed to be portable, extensible, and modular.

Home Page: https://ciao-lang.org

License: GNU Lesser General Public License v3.0

Prolog 71.41% Shell 3.56% Makefile 0.10% Python 0.85% Batchfile 0.01% C 22.58% C++ 1.12% PLSQL 0.01% CLIPS 0.23% HTML 0.02% Emacs Lisp 0.03% JavaScript 0.10% Dockerfile 0.01%
prolog compiler programming-language logic interpreter bytecode virtual-machine clp constraints prolog-implementation

ciao's Introduction

The Ciao Programming Language

Ciao is a general-purpose programming language in the Prolog family that builds up from a logic-based simple kernel, and is designed to be extensible and modular. Please check the documentation for a complete feature list.

This repository contains the Ciao compiler, standard libraries, and build system. Other advanced features (static analysis, documentation generation, Emacs-based development environment, etc.) are provided in separate bundles.

Installation

Build Try

curl https://ciao-lang.org/boot -sSfL | sh

Please consult the installation instructions for details.

ciao's People

Contributors

albertogp avatar danielaferreiro avatar igcontreras avatar ignaciocasso avatar jfmc avatar louisrustenholz avatar manuel-carro avatar mciccale avatar nataliacarpizo avatar pedro-lopez-garcia avatar thierrymarianne avatar victor-eds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ciao's Issues

Support ppc64le CPU architecture

Hi, I’m trying to compile on an unsupported CPU architecture and for that the first step is to do some trivial changes in eng_predef.h.

However, ./ciao-boot.sh configure fails precisely because it would need those changes to run.

It says compiling ciaoengine (engine for ciaoc.sta) so I imagine that ciaoc.sta is a pre-compiled file. I’ve tried removing the file core/bootstrap/ciaoc.car/ciaoc.sta hoping it would be rebuilt from the C source, but it surprisingly still says compiling ciaoengine (engine for ciaoc.sta), so I guess it got built into yet another file which is the one actually loaded.

My question is: can I somehow bootstrap from C?

Standard div/2 integer function and operator are missing

The standard div/2 integer function and operator are missing

?- X is 7 div 2.
{SYNTAX ERROR: (lns 74-74) operator expected after expression
X is 7
** here **
div 2 .
}
?- X is div(7,2).
{ERROR: arithmetic:is/2, arg 2 - expected an arithmetically evaluable expression, found div(7,2)}

aborted

uncaught memory overflow in ciaowasm (was Cannot distinguish error from failure")

There is a strange behaviour on my machine
with the new Ciao WASM Playground:

?- time2(fac(s(s(s(s(s(s(s(s(s(s(n)))))))))), _)).
% walltime 520.0 ms
yes
?- time2(fac(s(s(s(s(s(s(s(s(s(s(s(n))))))))))), _)).
no
?- fail.
no

I guess JavaScript WASM run out of memory. But
somehow the error is not noticed or ignored.
Would it be possible to show the out of memory?

P.S.: Was using this code:

add(n, X, X).
add(s(X), Y, Z) :- add(X, s(Y), Z).

mul(n, _, n).
mul(s(X), Y, Z) :- mul(X, Y, H), add(Y, H, Z).

fac(n, s(n)).
fac(s(X), Y) :- fac(X, H), mul(s(X), H, Y).

Type error "evaluable": non-compliant exception

Several standard compliance tests fail due to non-compliant exception for "evaluable" type errors. For example:

!     lgt_acos_1_05: failure 
!       test goal throws the wrong error:
!         expected error(type_error(evaluable,foo/0),A)
!         but got  error(type_error(evaluable,acos(foo)),'arithmetic:is'/2-2)
!       in file /Users/pmoura/logtalk/tests/prolog/functions/acos_1/tests.lgt between lines 54-58

This may be an easy fix. In the place where the exception is thrown, replace the second argument in the type_error/2 term by the non-evaluable term indicator.

Standard double_quotes flag inconsistent value

Consider the following queries:

Ciao 1.19.0 (2020-03-26 10:41:43 +0100) [DARWINx86_64]
?- set_prolog_flag(double_quotes, codes).

no
?- current_prolog_flag(double_quotes, codes).

no
?- current_prolog_flag(double_quotes, V).

V = chars ? ;

no
?- write("abc").
[97,98,99]
yes
?- set_prolog_flag(double_quotes, chars).

yes
?- write("abc").
[97,98,99]
yes
?- set_prolog_flag(double_quotes, atom).

no

It seems that the value of the double_quotes flag is wrongly reported as chars instead of codes. The flag is also not documented in the documentation on pre-defined flags.

ciao-site-file.el does not exist

After executing the installation:

./ciao-boot.sh get devenv

The file init.el was modified, adding the following:

; @begin(10762777)@ - Do not edit these lines - added automatically! (if (file-exists-p "path-to-ciao/ciao/ciao_emacs/elisp/ciao-site-file.el") (load-file "path-to-ciao/ciao/ciao_emacs/elisp/ciao-site-file.el")) ; @end(10762777)@ - End of automatically added lines.

(Instead of path-to-ciao, my home directory)

The problem is that there is no a ciao-site-file.el file there, so no file is loaded.

Tests fail at `append(X2,_,_1)` and `atom_concat(_1,_)`

Tests fail in the same way on both Linux x64 and Linux ppc64le:

cd /tmp
git clone https://github.com/ciao-lang/ciao.git
cd ciao
./ciao-boot.sh get devenv
./ciao-boot.sh local-install
eval "$(./build/bin/ciao-env --sh)"
./ciao-boot.sh test

Result: (omitted part are all PASSED)

=> core: testing
   running tests at lib/
[...]
PASSED: (lns 67-69) append/3 "Simple call to append".
FAILED: (lns 70-73) append/3 "Simple append test".
append(X2,_,_1) run-time check failure.
Requires in *success*: 
    _1==_2.
But instead:
    _1=[1,2,4,5,6]
    _2=X2
PASSED: (lns 74-77) append/3 "Test of reverse call".
[...]
PASSED: (lns 74-83) atom_concat/2.
FAILED: (lns 84-99) atom_concat/2 "atom_concat that generates several solutions.".
terms:atom_concat(_1,_) run-time check failure.
Requires in *compat*: 
    list(atm,_1).
But instead:
    _1=[a,_|_]
FAILED: (lns 100-123) atom_concat/2 "atom_concat that generates several solutions.".
terms:atom_concat(_1,_) run-time check failure.
Requires in *compat*: 
    list(atm,_1).
But instead:
    _1=[a,_|_]
FAILED: (lns 124-133) atom_concat/2.
terms:atom_concat(_1,_) run-time check failure.
Requires in *compat*: 
    list(atm,_1).
But instead:
    _1=[_,b,_]
FAILED: (lns 134-142) atom_concat/2.
terms:atom_concat(_1,_) run-time check failure.
Requires in *compat*: 
    list(atm,_1).
But instead:
    _1=[_,b,'']
}

{In core/lib/varnames/apply_dict.pl
PASSED: (lns 52-53) apply_dict/4.
}

Note: {Total:
Passed: 37 (88.10%) Failed: 5 (11.90%) Precond Failed: 0 (0.00%) Aborted: 0 (0.00%) Timeouts: 0 (0.00%) Total: 42 Run-Time Errors: 5
}
[...]
[OK] Files are the same
=> ciaodbg: testing
=> ciao_emacs: testing
{ERROR: system:working_directory/2, arg 2 - existence error: source_sink:/tmp/ciao/ciao_emacs/tests does not exist}

After mkdir ciao_emacs/tests/, the tests complete with the same result excep this output after [OK] Files are the same:

[OK] Files are the same
=> ciaodbg: testing
=> ciao_emacs: testing
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50cmake-data.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading debian-ispell...
Loading /var/cache/dictionaries-common/emacsen-ispell-default.el (source)...
Loading /var/cache/dictionaries-common/emacsen-ispell-dicts.el (source)...
Loading info...
Cannot open load file: No such file or directory, run-indent-test.el
=> ciaopp: testing
=> lpdoc: testing
   running tests at src/

Reflection support to find if features like tabling are available

Depending on the Ciao build, features like tabling may or may not be available. Ideally, there will be a programatic way to test for the presence of those features at runtime. A simple solution is a flag per feature. E.g.

?- current_prolog_flag(tabling, Boolean).

Another alternative, found e.g. on YAP, is to have a non-deterministic/multi-value flag:

?- current_prolog_flag(system_options, Option).
Option = tabling ;
Option = ...

sub_atom/5 bug

Ciao 1.20.0 (2021-03-31 22:29:19 +0200) [DARWINx86_64]
?- sub_atom('.', 0, 1, _, '.').

no

feature request time/1 in WASM

Was just playing around with the new playground. Very
cool, can even bignums. But somehow time/1 is not
implemented, I get for a factorial example:

?- time(fac(1000,_)).
no
?- fac(1000,_).
yes

Which is also a little misleading to return no for a time/1
call. Would it be possible to add a time/1 predicate to WASM?
Its pretty standard in other Prolog systems,

since the evaluable predicate cputime/0 or the predicate
statistics/2 was not available in WASM, I couldn't bootstrap
it by myself. Or is there a way to import time/1

by some use_module/1?

sub_atom/5 compliance and performance issues

Running the Logtalk sub_atom/5 standard compliance tests with dc5c435 gives:

$ cd logtalk3/tests/prolog/predicates/sub_atom_5
$ ciaolgt
...
?- {tester}.
Note: module system already in executable, just made visible
Note: module runtime_control already in executable, just made visible
% 
% tests started at 2021-10-24, 11:22:55
% 
% running tests from object tests
% file: /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt
% 
% iso_sub_atom_5_01: success (in 0.0012809999999996435 seconds)
% iso_sub_atom_5_02: success (in 0.000848000000000404 seconds)
% iso_sub_atom_5_03: success (in 0.0008459999999992363 seconds)
% iso_sub_atom_5_04: success (in 0.0008559999999997459 seconds)
% iso_sub_atom_5_05: success (in 0.0008429999999997051 seconds)
% iso_sub_atom_5_06: success (in 0.0008530000000002147 seconds)
% iso_sub_atom_5_07: success (in 0.0008529999999993265 seconds)
% eddbali_sub_atom_5_08: success (in 0.0001139999999990593 seconds)
% eddbali_sub_atom_5_09: success (in 0.00011300000000069588 seconds)
!     eddbali_sub_atom_5_10: failure (in 0.00010799999999910881 seconds)
!       test goal failed but should have thrown an error:
!         expected error(type_error(atom,2),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 62-64
!     eddbali_sub_atom_5_11: failure (in 0.00010899999999924859 seconds)
!       test goal failed but should have thrown an error:
!         expected error(type_error(integer,a),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 65-67
!     eddbali_sub_atom_5_12: failure (in 0.00010899999999924859 seconds)
!       test goal failed but should have thrown an error:
!         expected error(type_error(integer,n),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 68-70
!     eddbali_sub_atom_5_13: failure (in 0.00010899999999924859 seconds)
!       test goal failed but should have thrown an error:
!         expected error(type_error(integer,m),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 71-73
!     sics_sub_atom_5_14: failure (in 0.00010899999999924859 seconds)
!       test goal failed but should have thrown an error:
!         expected error(domain_error(not_less_than_zero,-2),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 74-76
!     sics_sub_atom_5_15: failure (in 0.00010899999999924859 seconds)
!       test goal failed but should have thrown an error:
!         expected error(domain_error(not_less_than_zero,-3),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 77-79
!     sics_sub_atom_5_16: failure (in 0.00010899999999924859 seconds)
!       test goal failed but should have thrown an error:
!         expected error(domain_error(not_less_than_zero,-4),A)
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 80-82
% sics_sub_atom_5_17: success (in 0.0008470000000002642 seconds)
% sics_sub_atom_5_18: success (in 0.0008459999999992363 seconds)
% sics_sub_atom_5_19: success (in 0.0008429999999997051 seconds)
% sics_sub_atom_5_20: success (in 0.0008419999999995653 seconds)
% sics_sub_atom_5_21: success (in 0.0008409999999994255 seconds)
% sics_sub_atom_5_22: success (in 0.00010899999999924859 seconds)
% sics_sub_atom_5_23: success (in 0.00012799999999923983 seconds)
% sics_sub_atom_5_24: success (in 0.00011400000000083566 seconds)
% sics_sub_atom_5_25: success (in 0.00011199999999877974 seconds)
% sics_sub_atom_5_26: success (in 0.0001110000000013045 seconds)
% sics_sub_atom_5_27: success (in 0.0001120000000005561 seconds)
% sics_sub_atom_5_28: success (in 0.00011099999999952814 seconds)
% sics_sub_atom_5_29: skipped
% sics_sub_atom_5_30: skipped
% sics_sub_atom_5_31: skipped
% sics_sub_atom_5_32: skipped
% sics_sub_atom_5_33: success (in 0.0008850000000002467 seconds)
% lgt_sub_atom_5_34: success (in 0.00011500000000097543 seconds)
% lgt_sub_atom_5_35: success (in 0.00011600000000022703 seconds)
% lgt_sub_atom_5_36: success (in 0.00011600000000022703 seconds)
% lgt_sub_atom_5_37: success (in 0.00011199999999966792 seconds)
% lgt_sub_atom_5_38: success (in 0.0001120000000005561 seconds)
% lgt_sub_atom_5_39: success (in 0.0008660000000002555 seconds)
% lgt_sub_atom_5_40: success (in 0.00011100000000041632 seconds)
% lgt_sub_atom_5_41: success (in 0.00010999999999938836 seconds)
% lgt_sub_atom_5_42: success (in 0.0008639999999990877 seconds)
% lgt_sub_atom_5_43: success (in 0.0008609999999995566 seconds)
% lgt_sub_atom_5_44: success (in 0.0008650000000010039 seconds)
!     lgt_sub_atom_5_45: failure (in 0.0006510000000004013 seconds)
!       test goal succeeded non-deterministically
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 173-175
% lgt_sub_atom_5_46: success (in 0.00042899999999868044 seconds)
% lgt_sub_atom_5_47: success (in 0.00042699999999928906 seconds)
!     lgt_sub_atom_5_48: failure (in 0.00042799999999942884 seconds)
!       test goal succeeded non-deterministically
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 182-184
!     lgt_sub_atom_5_49: failure (in 0.0004290000000004568 seconds)
!       test goal succeeded non-deterministically
!       in file /Users/pmoura/logtalk/tests/prolog/predicates/sub_atom_5/tests.lgt between lines 185-187
% 
% 49 tests: 4 skipped, 35 passed, 10 failed (0 flaky)
% completed tests from object tests
% 
% no code coverage information collected
% tests ended at 2021-10-24, 11:22:55
% 

yes
?- 

Thus, some type-checking of the predicate arguments is currently missing and calls may leave spurious choice-points, which can hurt performance.

De facto standard version_data flag missing

The de facto standard version_data flag is missing. Its expected (read-only) value would be ciao(Major,Minor,Path,ImplementationDependentTerm) with the first three arguments being integers. The fourth argument can be used e.g. for a commit id.

configuration gives error

I attempted to install ciao according to "Quick installation from source".
When I ran "./ciao-boot.sh configure", its output had following error.

$./ciao-boot.sh configure
=> builder: building [boot]
compiling ciaoengine (engine for ciaoc.sta)
/home/junya/Downloads/ciao-1.21.0-alpha.4/builder/sh_src/config-sysdep/config-sysdep.sh: 501: [: ': unexpected operator
/home/junya/Downloads/ciao-1.21.0-alpha.4/builder/sh_src/config-sysdep/config-sysdep.sh: 501: [: ': unexpected operator
/home/junya/Downloads/ciao-1.21.0-alpha.4/builder/sh_src/config-sysdep/config-sysdep.sh: 501: [: unexpected operator
/home/junya/Downloads/ciao-1.21.0-alpha.4/builder/sh_src/config-sysdep/config-sysdep.sh: 501: [: unexpected operator
(truncated followings)

500--510 lines of config-sysdep.sh:

qflag() { # q str
    if [ "$1" == "" ]; then # (Make)
        # escape $ as $$
        printf "%s" "$2" | sed -e "s/\\\$/\$\$/g"
    else # (sh)
        # escape ' as '"'"', $ as \$
        printf "$1"
        printf "%s" "$2" | sed -e "s/'/'\"'\"'/g;s/\\\$/\\\\\$/g"
        printf "$1"
    fi
}

I guess the error is due to my environment used 'dash shell' to run scripts and its test command lacks == operator.

~$ readlink /bin/sh
dash

error after global install on Debian GNU/Linux 9.7 (stretch)

With system administrator (root) on /root/.ciaoroot/master, i execute:

./ciao-boot.sh unistall
./ciao-boot.sh distclean
./ciao-boot.sh global-install

After this steps, i log in with local user, executed source ~/.bashrc and ciao on terminal, i get:

{ERROR: No handle found for thrown error error(existence_error(source_sink,engine(term_basic)),absolute_file_name/7-1)}

The local installation works.

moabson@###:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.7 (stretch)
Release: 9.7
Codename: stretch

moabson@###:~$ uname -a
Linux #### 4.9.0-8-amd64 #1 SMP Debian 4.9.130-2 (2018-10-27) x86_64 GNU/Linux

Errors while compiling in Termux

While trying to compile in Termux version 0.133 I get the following error:

Termux: ~/ciao >> ./ciao-boot.sh
=> builder: building [boot]
compiling ciaoengine (engine for ciaoc.sta)
/data/data/com.termux/files/home/ciao/build-boot/eng/ciaoengine/src/concurrency.c:400:7: error: too few arguments to function call, expected 2, have 1
Thread_Cancel(goal_ref->thread_handle);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Looking at the Android definition of the macro in core/engine/os_threads.h, line 499, it reads:

#define Thread_Cancel(id) pthread_kill(Id)

According to the project maintainers, they could compile it without any problem in an older version of termux, but after upgrading they have been able to reproduce the issue. I have done some research and I still can't figure out why in an older version of termux it was possible to call pthread_kill with one parameter. According to POSIX documentation, there should be two parameters: id and signal. It's well known that Bionic libc, which Android and Termux use, doesn't have pthread_cancel and some other functions, but the parameter count issue doesn't seem to be documented anywhere.

I have been able to compile it by just changing the line to:

#define Thread_Cancel(id) pthread_kill(Id, SIGKILL)

But we should still figure out what happened in old versions of termux. Problem is, it's probably not due to the app itself, but due to the unupgraded packages. And there's no way to downgrade termux packages (only the app), which makes it harder to debug the problem.

Version information:

Termux 0.133

clang version 13.0.0
Target: aarch64-unknown-linux-android24
Thread model: posix
InstalledDir: /data/data/com.termux/files/usr/bin

Package ndk-sysroot version 23b-4 provides /usr/include/signal.h, which defines in line 167:

int pthread_kill(pthread_t __pthread, int __signal); // 2 parameter version

Notes about CIAO installation (my first impression on CIAO system)

Hi everyone:

I will be reporting here the first impressions about the CIAO, looking for an improvement with CIAO community:

  1. About the installation (Linux and derivatives):
    Normally, the major applications, these installations are done with root account. All the time, su, and sudo su, are used to install a new packages etc.
    Well, in the ciao, install as a normal user, no as sudo su or su
    (my first mistake).
    The installation will be in /home/USER/.ciaoroot/master/ ....
    so confirm it after all.

  2. In /home/USER/.ciaoroot/master/ there a file called ciao-boot.sh
    read this file and check its options. Very useful.
    For instance:
    ./ciao-boot.sh list

  3. Although VSCODE has been a universal editor, the extension for ciao works under EMACS. So, learn emacs to obtain the advantes from ciao.

  4. However, if you wish extend the ciao with other languages ... for instance tcl/tk, now, as su or sudo su,
    install the some packages like wish and tcl. In Debian systems,
    apt install wish
    apt install tcl

  5. The ciao command in the manual does many task, but it does not exist .... and my case
    ciao-shell is the command for "ciao"

  6. The iterative mode to try the ciao
    $ ciaosh
    Ciao 1.20.0 [LINUXx86_64]
    ?-
    should be presenting some initials informations for new user.
    Command listing., help(predicate), consult(....), for beginners these informations are essential.

  7. The shortcuts for console in ciaosh, such Crtl-A, Ctrl-E ... standard in Linux system does not work yet.
    Including arrorw up and dow... repeat last commantds.

Positive regards:

  • The compiler is fast as well its executable. Probably a VM embeded.
  • The system in GitHub, seems clean (lean)
  • The answer by email were cool and very kindly

Final suggestion:

  • To rewrite some parts of the manual ...
  • A section (tutorial) of the first-steps for beginners

Well Manuel, it was my first glimpse of ciao system ...some minimal details let it a little confuse for a first use.

My best regards and call me if can help you

Claudio

get devenv failed with "'devenv' does not look like a valid builder target"

While tryng to run ciao-boot.sh get devenv for latest code, it failed with following error:

   compiling ciao_builder (command) [using ciaoc.sta]
   reusing ciaoengine.LINUXx86_64 (engine for ciao_builder)
{ERROR (ciao_builder): 'devenv' does not look like a valid builder target.

It does not correspond to a known bundle name, a path to a bundle, or a path
to a workspace containing bundles.

Some possible reasons: the target is not reachable from CIAOROOT or CIAOPATH,
or it does not contain the ACTIVATE mark (for catalogues), or the bundle
sources are incomplete (no valid Manifest.pl?).}

Wrong path for activating Ciao env after non-default installation

Hi

I have installed Ciao and choose a non-default installation. In the end, I got this command to enable the Ciao env.

Installation is completed!

Now you can enable this installation manually with (bash, zsh):
  eval $(~/.ciaoroot/1.18.0/build/bin/ciao-env --sh)
or (csh):
  eval `~/.ciaoroot/1.18.0/build/bin/ciao-env --csh`

However, the correct path the Ciao installed itself in is: ~/.ciaoroot/master/build/bin/ciao-env

Ubuntu 18.04

De facto standard arithmetic constants missing

It would be also quite useful to have the following de facto standard arithmetic constants available:

?- X is pi.
{ERROR: arithmetic:is/2, arg 2 - expected an arithmetically evaluable expression, found pi}

aborted
?- X is e.
{ERROR: arithmetic:is/2, arg 2 - expected an arithmetically evaluable expression, found e}

aborted
?- X is epsilon.
{ERROR: arithmetic:is/2, arg 2 - expected an arithmetically evaluable expression, found epsilon}

aborted

Problem installing Ciao on MacBook M1 with Apple Silicon (ARM)

Is it possible to install Ciao on a MacBook M1 or is this not a supported platform? There does not appear be a binary release available and when I try to build from source code using ciao-boot.sh local-install I get the error message:

{ERROR (ciao_builder): '.' does not look like a valid builder target.

It does not correspond to a known bundle name, a path to a bundle, or a path
to a workspace containing bundles.

Some possible reasons: the target is not reachable from CIAOROOT or CIAOPATH,
or it does not contain the ACTIVATE mark (for catalogues), or the bundle
sources are incomplete (no valid Manifest.pl?).}

I did some investigation and discovered that the bootstrap had built a BOOT configuration in build-boot/eng/ciaoengine/cfg/BOOT that looked reasonable - however, line 806 of builder/sh_src/build_car.sh sets eng_cfg=DEFAULT rather than BOOT if $ENG_CFG is not set. This appears to be deliberate according to aTODO comment at line 619 that states # TODO: ENG_CFG=DEFAULT hardwired.

How can I bootstrap a new configuration for my platform?

read_term/3 option variable_names/1 doesn't returns pairs in left-to-right traversal order

The read_term/3 option variable_names/1 doesn't returns pairs in left-to-right traversal order as required by the ISO standard. For details, see e.g.

http://www.complang.tuwien.ac.at/ulrich/iso-prolog/WDCor3

Example to reproduce the compliance bug:

?- current_input(S), read_term(S, T, [variables(L), variable_names(Variables)]).
|: circle(_Id_, _Radius_, _Color_).

L = [_B,_A,_C],
S = user_input,
T = circle(_B,_A,_C),
Variables = ['_Color_'=_C,'_Id_'=_B,'_Radius_'=_A] ? 

yes

It should be:

Variables = [_Id_'=_B,'_Radius_'=_A,'_Color_'=_C,] ? 

This notably breaks Logtalk's parametric object examples.

get devenv failed while trying to fetch `builder` bundle

ciao-boot.sh get devenv failed with following error, it seems that there is no builder bundle exists:

   compiling ciao_builder (command) [using ciaoc.sta]
   reusing ciaoengine.LINUXx86_64 (engine for ciao_builder)
   fetching devenv skipped (already fetched, remove to force upgrade)
   fetching builder source (master) from https://github.com/ciao-lang/builder/archive/master.tar.gz
/usr/bin/tar: This does not look like a tar archive
/usr/bin/tar: Exiting with failure status due to previous errors
{ERROR (ciao_builder): Bundle fetch failed for `github(github.com/ciao-lang/builder,master)'.}

ciao-shell failed to execute scripts reside in readonly directory

When trying to use ciao-shell to execute scripts reside in readonly directory, it failed with following error:

% ./hello.pl
WARNING: cannot create /home/dram/prolog/ciao/readonly/hello.itf
{ERROR: No handle found for thrown error error(existence_error(source_sink,/home/dram/prolog/ciao/readonly/hello.po),streams_basic:$open/3-1)}

BTW, it would be nice if ciao-shell can run scripts without creating foo.itf and foo.po files.

error after installation on linux (mint 18.1)

Hi, I git cloned and installed ciao on Linux Mint 18.1 and afterwards get the following error when after I start ciao:

{ERROR: No handle found for thrown error error(existence_error(source_sink,engine(term_basic)),absolute_file_name/7-1)}

I can exit ciao using halt., but other prolog predicates, like write('hello'). don't seem to work (procedure does not exist error).

ciao seems to be experiencing some sort of path problem perhaps?

The installation instructions I followed were:

./ciao-boot.sh configure --instype=global
./ciao-boot.sh build
sudo ./ciao-boot.sh install

There were no reported errors or warnings during this install. All files seem to have been created properly in /usr/local/bin
Also, /usr/local/ciao has subdirectory ciao/1.16.0-alpha.3/

Any suggestions on how to fix this?

ISO core standard compatibility of Ciao WASM

Now I bumped my head:

  • (div)/2 is missing
  • current_prolog_flag/2 is missing
  • What else?

For the later I get:

?- current_prolog_flag(version, X).
WARNING: Predicate current_prolog_flag/2 undefined in module ciaowasm
{ERROR: No handle found for thrown exception 
error(existence_error(procedure,'ciaowasm:current_prolog_flag'/2),
'ciaowasm:current_prolog_flag'/2)}

Although "version" is not some standard flag, but current_prolog_flag/2 is
ISO core standard, isn't it? How do I obtain the version of the Ciao WASM
I am using. "version", "dialect" and "version_data" Prolog flags are

meanwhile widespread. Is there some equivalent to obtain similar data
in Ciao Prolog. Maybe this can be mapped to ISO core standard
current_prolog_flag/2 built-in predicate?

Unicode source support

Ciao 1.19.0 (2020-03-26 10:41:43 +0100) [LINUXx86_64]
?- Λ = 2.

�= 2 ?

yes
?- Λam = 2.
{SYNTAX ERROR: (lns 7-7) operator expected after expression
�
 ** here **
am = 2 .
}

It would be nice to have a better Unicode support.

open/4 predicate doesn't accept the type/1 option

The open/4 standard predicate doesn't accept the type/1 option. If no distinction is made internally between text and binary stream, I suggest that the type/1 option be parsed, checked (possible option values are text and binary), saved in the internal stream properties table entry, and otherwise ignored. This would avoid a large number of failed compliance tests. It would also allow several tests that happen to call open/4 in their setup to run.

Logic programming with α-equivalence

Name binding is an essential part of most programming languages. But it's also a pain spot when implementing programming languages.

One approach to make implementing programming languages easier is HOAS, like in λProlog. Another approach is based on fresh name generation, like in αProlog.

While λProlog approach seems to be suitable for typed logic programming languages, it might be possible to port αProlog approach to Ciao.

UPDATE: I should have provided a paper: αProlog: A Logic Programming Language with
Names, Binding and α-Equivalence

Problem when calling Ciao from C

Hi,

I ran into a problem when trying to use Ciao from C++ on Mac. As far as I see, I'm correctly following the instructions from the documentation.
I have followed the installation from source instructions when installing Ciao; none of the default paths were changed.

The program is very simple: asserting a fact and querying for the same fact.

#include <iostream>
#include "ciao_prolog.h"
using namespace std;

void ciao_test() {
    cout << "Initialising Ciao Prolog\n";
    ciao_opts("program_name", 0, NULL, 0, NULL, NULL);
    ciao_init(NULL);

    cout << "Creating context\n";
    ciao_implicit_ctx = ciao_ctx_new();

    cout << "Begin frame\n";
    ciao_frame_begin();

    ciao_term a = ciao_atom("a");
    ciao_term b = ciao_atom("b");
    ciao_term ff = ciao_structure("p", 2, a, b);

    ciao_term call = ciao_structure("assertz", 1, ff);

    cout << "Asserting fact\n";
    ciao_commit_call_term(call);
    cout << "Fact asserted!\n";

    ciao_term v1 = ciao_var();
    ciao_term v2 = ciao_var();

    ciao_term q = ciao_structure("p", 2, v1, v2);

    bool res = ciao_commit_call_term(q);

    if (res) {
        cout << "query succeeded!\n";
    }
    else {
        cout << "query did not succeeded: " << res << "\n";
    }

    cout << "End frame\n";
    ciao_frame_end();
}

int main () {
    ciao_test();
    return 0;
}

However, when I execute the program, I get the following error

{ERROR: segmentation violation}
Wam not initialized, exiting!!!

The error happens on the first ciao_commit_call_term(*) call.
It seems that initialization of the engine works fine, as well as frame creation.

What am I missing?

Documentation problem

Hi, after a few installations, I think that Ciao Install Documentation should contain the option to install the development environment without generating the LaTex documentation, because the necessary dependencies occupy 1098 MB.

When you execute ./ciao-boot.sh get devenv if you do not have installed texlive, texinfo and imagemagick, that are needed to generate the documentation, the installer will abort his execution.

It is necessary to include that option, as an alternative, in the installation documentation, so that you can install the development environment with the --with-docs=no option to skip the generation of documentation.

Some top-level goodies maybe?

In another ticket it was stated:

Note that atoms are still not quoted properly in the output. We'll fix that soon too.
#53

I got more ideas, like suppressing variables that did not get instantiated.
Currently I get in the Ciao WASM Playground:

?- forall(member(X,[1,4,3]), X > 0).
X=_8862 ? 
yes
?- forall(member(X,[1,4,3]), X > 1).
no

Many Prolog systems only show, like SWI-Prolog, which also
uses true/false instead yes/no, but the later doesn't matter:

?- forall(member(X,[1,4,3]), X > 0).
true.

?- forall(member(X,[1,4,3]), X > 1).
false.

Installation adjustments

Hi, it is necessary to include the following code in ~/.emacs.d/init.el so that emacs correctly loads the development environment.

(if (file-exists-p "path_to_ciao_folder/ciao_emacs/elisp/ciao-site-file.el")
  (load-file "path_to_ciao_folder/ciao_emacs/elisp/ciao-site-file.el"))

It is also necessary to update $PATH with that: export PATH=$PATH:path_to_ciao_folder/build/bin and paste it in ~/.profile

(path_to_ciao_folder is the content of the environment variable ciaoroot)

Cannot use predicate_property/2 to query module predicate properties

With a loaded module, e.g.

?- current_module(between).

yes

is not possible to query the properties of predicates exported by the module:

?- between:predicate_property(between(_,_,_), P).
ERROR: Bad module qualification of predicate_property/2, module user(/Users/pmoura/ciao/core/library/toplevel/toplevel_scope) does not import the predicate from module between
{ERROR: $bad_qualification$:predicate_property/2 - existence error: procedure:$bad_qualification$:predicate_property/2 does not exist}

aborted
?- predicate_property(between:between(_,_,_), P).
ERROR: Bad module qualification of between/3, module user(/Users/pmoura/ciao/core/library/toplevel/toplevel_scope) does not import the predicate from module between

no

Error when trying to run the executable: ERROR: arithmetic:>/2, arg 1 .

This is probably not an 'issue'. Simply, I'm new to Ciao and I can't seem to find the answer. My code works fine in interactive mode. When trying to run the executable I get the error:

    {ERROR: arithmetic:>/2, arg 1 - expected an arithmetically evaluable expression, found 3}
    ERROR: {Program ended with failure}

The code:

    #!/usr/bin/env ciao-shell
    % -*- mode: ciao; -*-
    
    main(N) :- facto(N,R),write(R),nl.
    
    facto(0,1).
    
    facto(N,R) :- N > 0, N1 is N-1, facto(N1,R1), R is R1*N.

my command for executing:

    ./facto.pl 3

Please help. This should be simple. If you could direct me to examples on how to run executables that would be helpful too.

Optimization

This isn't specific to Ciao, but perhaps someone can tell me why this is so commonly the case.

Consider

X=5, between(1,100000000,X).

vs

between(1,100000000,X), X=5.

After giving X = 5 as the first answer, the former quickly reports that there are no more answers, while the latter takes a long time to do so. This is the case in many implementations of Prolog - I've tried like 5, and they all do this. (Except that Mercury is slow both ways around.) Given that Prolog is by-and-large order-invariant, it seems like the compiler/interpreter ought to be able to optimize that away, yet it seems that nobody does. I come away with an (uneducated) impression that everybody's compilers are bad at optimization. Is that true? Is there some secret reason why this cannot be optimized? It seems like one of the simplest test cases you could construct.

Error 404 on URL

The installation command generated the error.

curl https://ciao-lang.org/boot -sSfL | sh
▄▄▄
▄▀ ▀ ▀ ▄▄▄ ▄▄▄ Default stable version: 1.20.0
█ █ █ █ █ █ Detected OS: DARWIN
▀▄▄▄▀ ▀▄▄▀▄▄▀█▄▀▄▄▄▀ Detected architecture: x86_64

Welcome to the interactive network installation for Ciao!
(Press C-c to cancel)

Install the development environment? (yes/no) y
Install local documentation? (no/yes) n
Enable this installation by default? (yes/no) y

Code will be installed under ~/.ciaoroot directory.
The selected installation is reproducible with:

curl https://ciao-lang.org/boot -sSfL | sh -s -- --no-prebuilt get devenv --builder:with_docs=no

(Press enter to continue or C-c to cancel)

fetching ciao () from https://github.com/ciao-lang/ciao/archive/.tar.gz
curl: (22) The requested URL returned error: 404

sh: line 267: /Users/marclajoie/.ciaoroot//builder/sh_boot/builder_boot.sh: No such file or directory
sh: line 267: exec: /Users/marclajoie/.ciaoroot//builder/sh_boot/builder_boot.sh: cannot execute: No such file or directory

Errors compiling from sources

With the current git version (6714f26), on macOS, I get:

$ ./ciao-boot.sh local-install
...
=> core: building [bin]
{Using package /Users/pmoura/Documents/Prolog/ciao/core/lib/condcomp/condcomp.pl
ERROR: (lns 2-3) unknown declaration if($with_compiler_name(c_optim_comp))
ERROR: (lns 4-4) unknown declaration compilation_fact(optim_comp)
ERROR: (lns 5-5) unknown declaration endif
}
{Using package /Users/pmoura/Documents/Prolog/ciao/core/lib/initial.pl
ERROR: (lns 4-6) unknown declaration if(defined(SHELL))
ERROR: (lns 7-10) unknown declaration else
ERROR: (lns 10-12) unknown declaration if(defined(optim_comp))
ERROR: (lns 13-13) unknown declaration else
ERROR: (lns 14-15) unknown declaration endif
ERROR: (lns 16-18) unknown declaration if(defined(optim_comp))
ERROR: (lns 19-19) unknown declaration $props($initialization/1,[impnat=bytecode])
ERROR: (lns 21-21) unknown declaration $props($on_abort/1,[impnat=bytecode])
ERROR: (lns 23-23) unknown declaration else
ERROR: (lns 26-26) unknown declaration endif
ERROR: (lns 27-29) unknown declaration if(defined(optim_comp))
ERROR: (lns 30-30) unknown declaration else
ERROR: (lns 44-44) unknown declaration endif
ERROR: (lns 45-47) unknown declaration if(defined(optim_comp))
ERROR: (lns 48-49) unknown declaration $native_weak_inline(include(ciao/basiccontrol.native.h))
{ERROR: absolute_file_name/7, arg 1 - existence error: source_sink:engine(ptoc__prelude_types) does not exist}
{ERROR: user:compile_mods/5 - existence error: procedure:user:compile_mods/5 does not exist}
   compiled engine/ (23 modules)
...

callable/1 bug

The implementation of the standard callable/1 predicate succeeds on variables:

$ ./ciaosh --iso
Ciao 1.19.0 (2020-03-26 10:41:43 +0100) [DARWINx86_64]
?- callable(_).

yes

This, btw, explains some of the odd warnings we are getting in Logtalk.

ensure_datadir/2 fails for non-local installation of Ciao

Looks like persdb/datadir tries to use system path for data dir (probably relative to core/builder bundles or CIAOROOT folders).

Can be reproduced with Nix packaged version (example for Flakes flavor):

nix run nixpkgs\#ciao
use_module(library(persdb/datadir)). ensure_datadir('learn-ciao', Dir).
zsh%  nix run nixpkgs\#ciao
Ciao 1.20.0 [LINUXx86_64]
?- use_module(library(persdb/datadir)). ensure_datadir('learn-ciao', Dir).

yes
?- {ERROR: system:make_directory/2, arg 1 - system error: Read-only file system}

In NixOS packages installed at location that is perceived as read-only for normal users.

P.S. This at least affects ciaopp. See ciao-lang/ciaopp#2

Installation issue on big sur

I apologize if this should have an obvious solution, but I am attempting to install CIAO on a Mac M1 running big sur, and I am getting the following response when running ./ciao-boo.sh get devenv:

=> builder: building [boot]
   compiling ciaoengine.DARWINarm64 (engine for ciaoc.sta)
   compiling ciao_builder (command) [using ciaoc.sta]
/Users/jason/ciao/builder/sh_boot/autoboot.sh: line 153: 57565 Killed: 9               CIAOPATH="$default_ciaopath" CIAOALIASPATH="$default_ciaoaliaspath" CIAOROOT=`crossp "$ciaoroot"` CIAOHDIR=`crossp "$bld_hdir"` CIAOENGINE=`crossp "$engexec"` $engdbg "$engexec" "$@" -C -b "$cpxexec" $engopts
   reusing ciaoengine.DARWINarm64 (engine for ciao_builder)
/Users/jason/ciao/builder/sh_boot/autoboot.sh: line 153: 57571 Killed: 9               CIAOPATH="$default_ciaopath" CIAOALIASPATH="$default_ciaoaliaspath" CIAOROOT=`crossp "$ciaoroot"` CIAOHDIR=`crossp "$bld_hdir"` CIAOENGINE=`crossp "$engexec"` $engdbg "$engexec" "$@" -C -b "$cpxexec" $engopts

The same thing happens whether it is being run as the local user or as root. Any help would be appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.