GithubHelp home page GithubHelp logo

ciao-lang / ciaopp Goto Github PK

View Code? Open in Web Editor NEW
10.0 5.0 3.0 13.2 MB

The Ciao Preprocessor

License: GNU Lesser General Public License v3.0

Prolog 99.96% Shell 0.04%
prolog static-analysis abstract-interpretation ciao-prolog

ciaopp's Introduction

The CiaoPP Program Processor

CiaoPP is a program processor framework for Ciao. CiaoPP performs a number of program debugging, analysis, and source-to-source transformation tasks:

  • Inference of properties of the predicates and literals of the program (types, modes and other variable instantiation properties, non-failure, determinacy, bounds on computational cost, bounds on sizes of terms in the program, etc.).

  • Certain kinds of static debugging and verification, finding errors before running the program. This includes checking how programs call system library predicates and also checking the assertions present in the program or in other modules used by the program. Such assertions represent essentially partial specifications of the program.

  • Several kinds of source to source program transformations such as program specialization, slicing, partial evaluation, program parallelization (taking granularity control into account), inclusion of run-time tests for assertions which cannot be checked completely at compile-time, etc.

The information generated by analysis and the assertions in the specifications are all written in the same assertion language, which is in turn also used by the Ciao system documentation generator, lpdoc.

This repository contains the generic preprocessor framework together with some basic analyses, transformations, and language support. Other features (including support for a variety of programming languages) are distributed as separate bundles.

CiaoPP is distributed under the GNU general public license.

Installation

By default, Ciao will detect and build CiaoPP during system compilation. In order to customize the default configuration options, please refer to the Ciao installation instructions.

It is possible to do a separate build and install of CiaoPP with the following command:

$ ciao get ciaopp

ciaopp's People

Contributors

danielaferreiro avatar djurjo avatar igcontreras avatar ignaciocasso avatar jfmc avatar louisrustenholz avatar nataliacarpizo avatar pedro-lopez-garcia avatar victor-eds avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ciaopp's Issues

Partial evaluation

I'm experimenting with the partial evaluation capabilities of ciaopp, but I'm not sure how to get the best possible results. I tried to transform the following program:

:- module(test3, [test3/1], []).

generate(empty,T,T).
generate(char(X),[X|T],T).
generate(or(X,Y),H,T) :- generate(X,H,T).
generate(or(X,Y),H,T) :- generate(Y,H,T).
generate(cat(X,Y),H,T) :- generate(X,H,T1), generate(Y,T1,T).
generate(star(X),T,T).
generate(star(X),H,T) :- generate(X,H,T1), generate(star(X),T1,T).

prog(cat(char(a),star(char(b)))).
prog(or(star(char(c)), empty)).

test3(S) :-
  prog(P),
  generate(P,S,[]).

With this "driver" code:

:- use_module(ciaopp(ciaopp)).

main(_) :-
  module('test3.pl'),
  set_pp_flag(comp_rule, no_sideff_jb),
  set_pp_flag(local_control, df_hom_emb),
  set_pp_flag(global_control, hom_emb),
  set_pp_flag(fixpoint, di),
  set_pp_flag(unf_depth, 1000),
  set_pp_flag(abs_spec_defs, all),
  set_pp_flag(rem_use_cls, both),
  set_pp_flag(part_concrete, multi),
  analyze(pdb),
  transform(codegen),
  transform(spec),
  output('test3_pe.pl').

Here is the result:

:- module(_1,[test3/1],[assertions]).

:- true pred test3(_A).

test3([a]).
test3([a,b|A]) :-
    generate_1(star(char(b)),A,[]).
test3([]).
test3([c|A]) :-
    generate_2(star(char(c)),A,[]).
test3([]).

:- true pred generate_1(_A,_B,_C).

generate_1(star(char(b)),[],[]).
generate_1(star(char(b)),[b|A],[]) :-
    generate_1(star(char(b)),A,[]).

:- true pred generate_2(_A,_B,_C).

generate_2(star(char(c)),[],[]).
generate_2(star(char(c)),[c|A],[]) :-
    generate_2(star(char(c)),A,[]).

This looks good to me, and I want to express my thanks for ciaopp as a really capable open source tool. But I don't really know what I'm doing so I have some basic questions:

  • Is there some way to get rid of the duplicate test3([]). clauses? (In some bigger tests I get many of them).
  • Is there some flag to turn off generation of these kinds of statements: :- true pred...?
  • Am I going about this the right way? I'd like to be able to apply partial evaluation across a variety of programs, and so I'm looking for a configuration that works well overall.

Build fails at ciaopp_client when using system-wide installation

It looks like ciaopp.ciaopp_client build attempts to install ciaopp-client at CIAOROOT location

Output of ciao get ciaopp:

   fetching ciaopp source (master) from https://github.com/ciao-lang/ciaopp/archive/master.tar.gz
=> ciaopp: preparing build [bin]
=> ciaopp: building [bin]
   compiled src/ (105 modules)
   compiled domains/ (65 modules)
   compiled lib/ (7 modules)
   compiled spec/ (43 modules)
   compiled batch/ (7 modules)
   compiling ciaopp-dump (command)
   compiling ciaopp-batch (command)
   compiling ciaopp_master (command)
   compiling ciaopp_batch_report (command)
=> ciaopp.cmds: building [bin]
   compiling ciaopp (command)
=> ciaopp.ciaopp_client: building [bin]
{ERROR: system:$throw_errno/1, arg 2 - could not open: /nix/store/0dglpvf6vzyddjzk1g6mgs1zrd794qnd-ciao-1.21.0-m1/ciao/1.21.0/build/bin/ciaopp-client}

I guess caused by

% TODO: strange target, only for installation, define in another way?
'$builder_hook'(item_nested(ciaopp_client)).
'$builder_hook'(ciaopp_client:cmd('ciao-client', [main='NONE_AUTOGEN', shscript])).
'$builder_hook'(ciaopp_client:build_bin) :- % (override build)
% (we just copy the script from the builder)
cmd_build_copy(core, shscript, ~ciaopp_client_sh, 'ciaopp-client').

And setting INSTALL_CIAOROOT doesn't seem to affect it.

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.