AI-Logic-AnswerSet
view release on metacpan or search on metacpan
Revision history for Perl extension AI::Logic::AnswerSet.
0.01 Sat Jan 28 18:10:08 2012
- original version; created by h2xs 1.23 with options
-AXc -n AI::Logic::AnswerSet
# Extra linker info
EXPORT_LIST =
PERL_ARCHIVE =
PERL_ARCHIVE_AFTER =
TO_INST_PM = lib/AI/Logic/AnswerSet.pm
PM_TO_BLIB = lib/AI/Logic/AnswerSet.pm \
blib/lib/AI/Logic/AnswerSet.pm
# --- MakeMaker platform_constants section:
MM_Unix_VERSION = 6.55_02
PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
# --- MakeMaker tool_autosplit section:
# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$ARGV[0], $$ARGV[1], 0, 1, 1)' --
UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
MACROSTART =
MACROEND =
USEMAKEFILE = -f
FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
# --- MakeMaker makemakerdflt section:
makemakerdflt : all
$(NOECHO) $(NOOP)
# --- MakeMaker dist section:
TAR = tar
TARFLAGS = cvf
ZIP = zip
ZIPFLAGS = -r
COMPRESS = gzip --best
SUFFIX = .gz
SHAR = shar
# --- MakeMaker const_cccmd section:
# --- MakeMaker post_constants section:
# --- MakeMaker pasthru section:
PASTHRU = LIBPERL_A="$(LIBPERL_A)"\
LINKTYPE="$(LINKTYPE)"\
PREFIX="$(PREFIX)"
# --- MakeMaker special_targets section:
.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
# --- MakeMaker c_o section:
# --- MakeMaker xs_c section:
# --- MakeMaker xs_o section:
# --- MakeMaker top_targets section:
all :: pure_all manifypods
$(NOECHO) $(NOOP)
pure_all :: config pm_to_blib subdirs linkext
$(NOECHO) $(NOOP)
subdirs :: $(MYEXTLIB)
$(NOECHO) $(NOOP)
config :: $(FIRST_MAKEFILE) blibdirs
$(NOECHO) $(NOOP)
help :
perldoc ExtUtils::MakeMaker
# --- MakeMaker blibdirs section:
blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP)....
$(NOECHO) $(NOOP)
# Backwards compat with 6.18 through 6.25
blibdirs.ts : blibdirs
$(NOECHO) $(NOOP)
$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_LIBDIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR)
$(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists
$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_ARCHLIB)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB)
$(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists
$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_AUTODIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR)
$(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists
$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR)
$(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists
$(INST_BIN)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_BIN)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN)
$(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists
$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_SCRIPT)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT)
$(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists
$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_MAN1DIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR)
$(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists
$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_MAN3DIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR)
$(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists
# --- MakeMaker linkext section:
linkext :: $(LINKTYPE)
$(NOECHO) $(NOOP)
# --- MakeMaker dlsyms section:
# --- MakeMaker dynamic section:
dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
$(NOECHO) $(NOOP)
# --- MakeMaker dynamic_bs section:
BOOTSTRAP =
# --- MakeMaker dynamic_lib section:
# --- MakeMaker static section:
## $(INST_PM) has been moved to the all: target.
## It remains here for awhile to allow for old usage: "make static"
static :: $(FIRST_MAKEFILE) $(INST_STATIC)
$(NOECHO) $(NOOP)
# --- MakeMaker static_lib section:
# --- MakeMaker manifypods section:
POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
POD2MAN = $(POD2MAN_EXE)
manifypods : pure_all \
lib/AI/Logic/AnswerSet.pm
$(NOECHO) $(POD2MAN) --section=$(MAN3EXT) --perm_rw=$(PERM_RW) \
lib/AI/Logic/AnswerSet.pm $(INST_MAN3DIR)/AI::Logic::AnswerSet.$(MAN3EXT)
# --- MakeMaker processPL section:
# --- MakeMaker installbin section:
# --- MakeMaker subdirs section:
# none
# --- MakeMaker clean_subdirs section:
clean_subdirs :
$(NOECHO) $(NOOP)
# --- MakeMaker clean section:
# Delete temporary files but do not touch installed files. We don't delete
# the Makefile here so a later make realclean still has a makefile to use.
clean :: clean_subdirs
- $(RM_F) \
*$(LIB_EXT) core \
core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \
core.[0-9][0-9] $(BASEEXT).bso \
pm_to_blib.ts core.[0-9][0-9][0-9][0-9] \
$(BASEEXT).x $(BOOTSTRAP) \
perl$(EXE_EXT) tmon.out \
*$(OBJ_EXT) pm_to_blib \
$(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \
core.[0-9][0-9][0-9][0-9][0-9] *perl.core \
core.*perl.*.? $(MAKE_APERL_FILE) \
perl $(BASEEXT).def \
core.[0-9][0-9][0-9] mon.out \
lib$(BASEEXT).def perlmain.c \
perl.exe so_locations \
$(BASEEXT).exp
- $(RM_RF) \
blib
- $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
# --- MakeMaker realclean_subdirs section:
realclean_subdirs :
$(NOECHO) $(NOOP)
# --- MakeMaker realclean section:
# Delete temporary files (via clean) and also delete dist files
realclean purge :: clean realclean_subdirs
- $(RM_F) \
$(MAKEFILE_OLD) $(FIRST_MAKEFILE)
- $(RM_RF) \
$(DISTVNAME)
# --- MakeMaker metafile section:
metafile : create_distdir
$(NOECHO) $(ECHO) Generating META.yml
$(NOECHO) $(ECHO) '--- #YAML:1.0' > META_new.yml
$(NOECHO) $(ECHO) 'name: AI-Logic-AnswerSet' >> META_new.yml
$(NOECHO) $(ECHO) 'version: 0.01' >> META_new.yml
$(NOECHO) $(ECHO) 'abstract: Perl extension for embedding ASP (Answer Set Programming) programs in Perl.' >> META_new.yml
$(NOECHO) $(ECHO) 'author:' >> META_new.yml
$(NOECHO) $(ECHO) ' - leviathan <leviathan@>' >> META_new.yml
$(NOECHO) $(ECHO) 'license: unknown' >> META_new.yml
$(NOECHO) $(ECHO) 'distribution_type: module' >> META_new.yml
$(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml
$(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
$(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml
$(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
$(NOECHO) $(ECHO) 'requires: {}' >> META_new.yml
$(NOECHO) $(ECHO) 'no_index:' >> META_new.yml
$(NOECHO) $(ECHO) ' directory:' >> META_new.yml
$(NOECHO) $(ECHO) ' - t' >> META_new.yml
$(NOECHO) $(ECHO) ' - inc' >> META_new.yml
$(NOECHO) $(ECHO) 'generated_by: ExtUtils::MakeMaker version 6.55_02' >> META_new.yml
$(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml
$(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml
$(NOECHO) $(ECHO) ' version: 1.4' >> META_new.yml
-$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
# --- MakeMaker signature section:
signature :
cpansign -s
# --- MakeMaker dist_basics section:
distclean :: realclean distcheck
$(NOECHO) $(NOOP)
distcheck :
$(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
skipcheck :
$(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
manifest :
$(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
veryclean : realclean
$(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
# --- MakeMaker dist_core section:
dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
$(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \
-e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' --
tardist : $(DISTVNAME).tar$(SUFFIX)
$(NOECHO) $(NOOP)
uutardist : $(DISTVNAME).tar$(SUFFIX)
uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
$(DISTVNAME).tar$(SUFFIX) : distdir
$(PREOP)
$(TO_UNIX)
$(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
$(RM_RF) $(DISTVNAME)
$(COMPRESS) $(DISTVNAME).tar
$(POSTOP)
zipdist : $(DISTVNAME).zip
$(NOECHO) $(NOOP)
$(DISTVNAME).zip : distdir
$(PREOP)
$(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
$(RM_RF) $(DISTVNAME)
$(POSTOP)
shdist : distdir
$(PREOP)
$(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
$(RM_RF) $(DISTVNAME)
$(POSTOP)
# --- MakeMaker distdir section:
create_distdir :
$(RM_RF) $(DISTVNAME)
$(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
distdir : create_distdir distmeta
$(NOECHO) $(NOOP)
# --- MakeMaker dist_test section:
disttest : distdir
cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
# --- MakeMaker dist_ci section:
ci :
$(PERLRUN) "-MExtUtils::Manifest=maniread" \
-e "@all = keys %{ maniread() };" \
-e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \
-e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
# --- MakeMaker distmeta section:
distmeta : create_distdir metafile
$(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{META.yml} => q{Module meta-data (added by MakeMaker)}}) } ' \
-e ' or print "Could not add META.yml to MANIFEST: $${'\''@'\''}\n"' --
# --- MakeMaker distsignature section:
distsignature : create_distdir
$(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) } ' \
-e ' or print "Could not add SIGNATURE to MANIFEST: $${'\''@'\''}\n"' --
$(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE
cd $(DISTVNAME) && cpansign -s
# --- MakeMaker install section:
install :: pure_install doc_install
$(NOECHO) $(NOOP)
install_perl :: pure_perl_install doc_perl_install
$(NOECHO) $(NOOP)
install_site :: pure_site_install doc_site_install
$(NOECHO) $(NOOP)
install_vendor :: pure_vendor_install doc_vendor_install
$(NOECHO) $(NOOP)
pure_install :: pure_$(INSTALLDIRS)_install
$(NOECHO) $(NOOP)
doc_install :: doc_$(INSTALLDIRS)_install
$(NOECHO) $(NOOP)
pure__install : pure_site_install
$(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
doc__install : doc_site_install
$(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
pure_perl_install :: all
$(NOECHO) umask 022; $(MOD_INSTALL) \
$(INST_LIB) $(DESTINSTALLPRIVLIB) \
$(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
$(INST_BIN) $(DESTINSTALLBIN) \
$(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
$(NOECHO) $(WARN_IF_OLD_PACKLIST) \
$(SITEARCHEXP)/auto/$(FULLEXT)
pure_site_install :: all
$(NOECHO) umask 02; $(MOD_INSTALL) \
read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \
write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \
$(INST_LIB) $(DESTINSTALLSITELIB) \
$(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
$(INST_BIN) $(DESTINSTALLSITEBIN) \
$(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
$(NOECHO) $(WARN_IF_OLD_PACKLIST) \
$(PERL_ARCHLIB)/auto/$(FULLEXT)
pure_vendor_install :: all
$(NOECHO) umask 022; $(MOD_INSTALL) \
$(INST_LIB) $(DESTINSTALLVENDORLIB) \
$(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
$(INST_BIN) $(DESTINSTALLVENDORBIN) \
$(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
doc_perl_install :: all
doc_site_install :: all
$(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLSITEARCH)/perllocal.pod
-$(NOECHO) umask 02; $(MKPATH) $(DESTINSTALLSITEARCH)
-$(NOECHO) umask 02; $(DOC_INSTALL) \
"Module" "$(NAME)" \
"installed into" "$(INSTALLSITELIB)" \
LINKTYPE "$(LINKTYPE)" \
VERSION "$(VERSION)" \
EXE_FILES "$(EXE_FILES)" \
>> $(DESTINSTALLSITEARCH)/perllocal.pod
doc_vendor_install :: all
uninstall :: uninstall_from_$(INSTALLDIRS)dirs
$(NOECHO) $(NOOP)
uninstall_from_perldirs ::
uninstall_from_sitedirs ::
$(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist
uninstall_from_vendordirs ::
# --- MakeMaker force section:
# Phony target to force checking subdirectories.
FORCE :
$(NOECHO) $(NOOP)
# --- MakeMaker perldepend section:
# --- MakeMaker makefile section:
# We take a very conservative approach here, but it's worth it.
# We move Makefile to Makefile.old here to avoid gnu make looping.
$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
$(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
$(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
-$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
-$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
- $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
$(PERLRUN) Makefile.PL
$(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
$(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
$(FALSE)
# --- MakeMaker staticmake section:
# --- MakeMaker makeaperl section ---
MAP_TARGET = perl
FULLPERL = /usr/bin/perl
$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
$(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
$(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
$(NOECHO) $(PERLRUNINST) \
Makefile.PL DIR= \
MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=
# --- MakeMaker test section:
TEST_VERBOSE=0
TEST_TYPE=test_$(LINKTYPE)
TEST_FILE = test.pl
TEST_FILES = t/*.t
TESTDB_SW = -d
testdb :: testdb_$(LINKTYPE)
test :: $(TEST_TYPE) subdirs-test
subdirs-test ::
$(NOECHO) $(NOOP)
test_dynamic :: pure_all
PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES)
testdb_dynamic :: pure_all
PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
test_ : test_dynamic
test_static :: test_dynamic
testdb_static :: testdb_dynamic
# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd :
$(NOECHO) $(ECHO) '<SOFTPKG NAME="$(DISTNAME)" VERSION="0.01">' > $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <ABSTRACT>Perl extension for embedding ASP (Answer Set Programming) programs in Perl.</ABSTRACT>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <AUTHOR>leviathan <leviathan@></AUTHOR>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <IMPLEMENTATION>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <ARCHITECTURE NAME="i686-linux-gnu-thread-multi-5.10" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' <CODEBASE HREF="" />' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) ' </IMPLEMENTATION>' >> $(DISTNAME).ppd
$(NOECHO) $(ECHO) '</SOFTPKG>' >> $(DISTNAME).ppd
# --- MakeMaker pm_to_blib section:
pm_to_blib : $(FIRST_MAKEFILE) $(TO_INST_PM)
$(NOECHO) $(ABSPERLRUN) -MExtUtils::Install -e 'pm_to_blib({@ARGV}, '\''$(INST_LIB)/auto'\'', q[$(PM_FILTER)], '\''$(PERM_DIR)'\'')' -- \
lib/AI/Logic/AnswerSet.pm blib/lib/AI/Logic/AnswerSet.pm
$(NOECHO) $(TOUCH) pm_to_blib
# --- MakeMaker selfdocument section:
# --- MakeMaker postamble section:
# End.
Makefile.PL view on Meta::CPAN
use 5.010001;
use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
NAME => 'AI::Logic::AnswerSet',
VERSION_FROM => 'lib/AI/Logic/AnswerSet.pm', # finds $VERSION
PREREQ_PM => {}, # e.g., Module::Name => 1.1
($] >= 5.005 ? ## Add these new keywords supported since 5.005
(ABSTRACT_FROM => 'lib/AI/Logic/AnswerSet.pm', # retrieve abstract from module
AUTHOR => 'leviathan <leviathan@>') : ()),
);
where they can be easily managed by the user.
NOTE: the use of this framework requires at least some basics of declarative programming, ASP in particular;
in addition, the DLV system is needed.
The user might refer to www.dlvsystem.com for downloading DLV and getting some info on its language.
INSTALLATION
To install this module type the following:
perl Makefile.PL
make
make test
make install
DEPENDENCIES
This module requires no other modules and libraries
COPYRIGHT AND LICENCE
Copyright (C) 2012 by Ferdinando Primerano, Francesco Calimeri.
This work started within the bachelor degree thesis program of the
lib/AI/Logic/AnswerSet.pm view on Meta::CPAN
use 5.010001;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter);
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
);
our $VERSION = '0.02';
sub executeFromFileAndSave { #Executes DLV with a file as input and saves the output in another file
open DLVW, ">>", "$_[1]";
print DLVW $_[2];
close DLVW;
open(SAVESTDOUT, ">&STDOUT") or die "Can't save STDOUT: $!\n";
open(STDOUT, ">$_[0]") or die "Can't open STDOUT to $_[0]", "$!\n";
my @args = ("./dlv", "$_[1]");
system(@args) == 0
or die "system @args failed: $?";
open(STDOUT,">&SAVESTDOUT"); #close file and restore STDOUT
close OUTPUT;
}
sub executeAndSave { #Executes DLV and saves the output of the program written by the user in a file
open(SAVESTDOUT, ">&STDOUT") or die "Can't save STDOUT: $!\n";
open(STDOUT, ">$_[0]") or die "Can't open STDOUT to $_[0]", "$!\n";
my @args = ("./dlv --");
system(@args) == 0 or die "system @args failed: $?";
open(STDOUT,">&SAVESTDOUT"); #close file and restore STDOUT
close OUTPUT;
}
sub iterativeExec { # Executes an input program with several instances and stores them in a bidimensional array
my @input = @_;
my @returned_value;
if(@input) {
my $option = $input[$#input];
if($option =~ /^-/) {
pop(@input);
}
else {
$option = "";
}
my $dir = pop(@input);
my @files = qx(ls $dir);
my $size = @files;
for(my $i = 0; $i < $size; $i++) {
my $elem = $files[$i];
chomp $elem;
my @args = ("./dlv", "@input", "$dir$elem", "$option");
my (@out) = `@args`;
push @{$returned_value[$i]}, @out;
}
}
else {
print "INPUT ERROR\n";
}
return @returned_value;
}
sub singleExec { # Executes a single input program or opens the DLV terminal and stores it in an array
my @input = @_;
my @returned_value;
if(@input) {
my @args = ("./dlv", "@input");
(@returned_value) = `@args`;
}
else {
my $command = "./dlv --";
(@returned_value) = `$command`;
}
return @returned_value;
}
sub selectOutput { # Select one of the outputs returned by the iterative execution of more input programs
my @stdoutput = @{$_[0]};
my $n = $_[1];
return @{$stdoutput[$n]};
}
sub getFacts { # Return the facts of the input program
my $input = shift;
my @isAFile = stat($input);
my @facts;
if(@isAFile) {
open INPUT, "<", "$input";
my @rows = <INPUT>;
foreach my $row (@rows) {
if($row =~ /^(\w+)(\(((\w|\d|\.)+,?)*\))?\./) {
push @facts, $row;
}
}
close INPUT;
}
else {
my @str = split /\. /,$input;
foreach my $elem (@str) {
if($elem =~ /^(\w+)(\(((\w|\d|\.)+,?)*\))?\.?$/) {
push @facts, $elem;
}
}
}
return @facts;
}
sub addCode { #Adds code to input
my $program = $_[0];
my $code = $_[1];
my @isAFile = stat($program);
if(@isAFile) {
open PROGRAM, ">>", $program;
print PROGRAM "$code\n";
close PROGRAM;
}
else {
$program = \($_[0]);
$$program = "$$program $code";
}
}
sub getASFromFile { #Gets the Answer Set from the file where the output was saved
open RESULT, "<", "$_[0]" or die $!;
my @result = <RESULT>;
my @arr;
foreach my $line (@result) {
if($line =~ /\{\w*/) {
$line =~ s/(\{|\})//g;
#$line =~ s/\n//g; # delete \n from $line
my @tmp = split(', ', $line);
push @arr, @tmp;
}
}
close RESULT;
return @arr;
}
sub getAS { #Returns the Answer Sets from the array where the output was saved
my @result = @_;
my @arr;
foreach my $line (@result) {
if($line =~ /\{\w*/) {
$line =~ s/(\{|\})//g;
$line =~ s/(Best model:)//g;
my @tmp = split(', ', $line);
push @arr, @tmp;
}
}
return @arr;
}
sub statistics { # Return an array of hashes in which the statistics of every predicate of every answerSets are stored
# If a condition of comparison is specified(number of predicates) it returns the answer sets that satisfy
# that condition
my @as = @{$_[0]};
my @pred = @{$_[1]};
my @num = @{$_[2]};
my @operators = @{$_[3]};
my @sets;
my @ans;
my $countAS = 0;
my @stat;
my $countPred;
foreach my $elem (@as) {
if($elem =~ /(\w+).*\n/) {
push @{$sets[$countAS]}, $elem;
if(_existsPred($1,\@pred)) {
$stat[$countAS]{$1} += 1;
$countAS += 1;
}
}
elsif($elem =~ /(\w+).*/) {
push @{$sets[$countAS]}, $elem;
if(_existsPred($1,\@pred)) {
$stat[$countAS]{$1} += 1;
}
}
}
my $comparison = 0;
if(@num and @operators) {
$comparison = 1;
}
elsif(@num and !@operators) {
print "Error: comparison element missing";
return @ans;
}
if($comparison) {
my $size = @pred;
my $statSize = @stat;
for(my $j = 0; $j < $statSize; $j++) {
for(my $i = 0; $i < $size; $i++) {
my $t = $stat[$j]{$pred[$i]};
if(_evaluate($t,$num[$i],$operators[$i])) {
$countPred++;
}
else {
$countPred = 0;
break;
}
}
if($countPred == $size) {
push @ans , $sets[$j];
}
$countPred = 0;
}
return @ans;
}
return @stat;
}
sub _evaluate { #private use only
my $value = shift;
my $num = shift;
my $operator = shift;
if($operator eq "==") {
if($value == $num) {
return 1;
}
return 0;
}
elsif($operator eq "!=") {
if($value != $num) {
return 1;
}
return 0;
}
elsif($operator eq ">") {
if($value > $num) {
return 1;
}
return 0;
}
elsif($operator eq ">=") {
if($value >= $num) {
return 1;
}
return 0;
}
elsif($operator eq "<") {
if($value < $num) {
return 1;
}
return 0;
}
elsif($operator eq "<=") {
if($value <= $num) {
return 1;
}
return 0;
}
return 0;
}
sub mapAS { #Mapping of the Answer Sets in an array of hashes
my $countAS = 0;
my @answerSets = @{$_[0]};
my @second;
if($_[1]) {
@second = @{$_[1]};
}
my @third;
if($_[2]) {
@third = @{$_[2]};
}
my @selectedAS;
my @predList;
my @pred;
if(@second) {
if($second[0] =~ /\d+/) {
@selectedAS = @second;
if(@third) {
@predList = @third;
}
}
else {
@predList = @second;
if(@third) {
@selectedAS = @third;
}
}
}
foreach my $elem (@answerSets) {
if($elem =~ /(\w+).*\n/){
if(@predList) {
if(_existsPred($1,\@predList)) {
push @{$pred[$countAS]{$1}}, $elem;
}
}
else {
push @{$pred[$countAS]{$1}}, $elem;
}
$countAS = $countAS + 1;
}
elsif($elem =~ /(\w+).*/) {
if(@predList) {
if(_existsPred($1,\@predList)) {
push @{$pred[$countAS]{$1}}, $elem;
}
}
else {
push @{$pred[$countAS]{$1}}, $elem;
}
}
}
if(@selectedAS) {
my $size = @selectedAS;
my @selectedPred;
for(my $i = 0; $i < $size; $i++) {
my $as = $selectedAS[$i];
push @selectedPred, $pred[$as];
}
return @selectedPred;
}
return @pred;
}
sub _existsPred { #Verifies the existence of a predicate (private use only)
my $pred = $_[0];
my @predList = @{$_[1]};
my $size = @predList;
for(my $i = 0; $i < $size; $i++) {
if($pred eq $predList[$i]) {
return 1;
}
}
return 0;
}
sub getPred { #Returns the predicates from the array of hashes
my @pr = @{$_[0]};
return @{$pr[$_[1]]{$_[2]}};
}
sub getProjection { #Returns the values selected by the user
my @pr = @{$_[0]};
my @projection;
my @res = @{$pr[$_[1]]{$_[2]}};
my $size = @res;
my $fieldsStr;
for(my $i = 0; $i < $size; $i++) {
my $pred = @{$pr[$_[1]]{$_[2]}}[$i];
if($pred =~ /(\w+)\((.+)\)/) {
$fieldsStr = $2;
}
my @fields = split(',',$fieldsStr);
push @projection , $fields[$_[3]-1];
}
return @projection;
}
sub createNewFile {
my $file = $_[0];
my $code = $_[1];
open FILE, ">", $file;
print FILE "$code\n";
close FILE;
}
sub addFacts {
my $name = $_[0];
my @facts = @{$_[1]};
my $append = $_[2];
my $filename = $_[3];
open FILE, $append, $filename;
foreach my $f (@facts) {
print FILE "$name($f).\n";
}
close FILE;
}
1;
__END__
#
=head1 NAME
AI::Logic::AnswerSet - Perl extension for embedding ASP (Answer Set Programming) programs in Perl.
=head1 SYNOPSIS
use AI::Logic::AnswerSet;
# invoke DLV( AnwerSetProgramming-based system) and save the stdoutput
my @stdoutput = AI::Logic::AnswerSet::singleExec("3-colorability.txt");
# parse the output
my @res = AI::Logic::AnswerSet::getAS(@stdoutput);
# map the results
my @mappedAS = AI::Logic::AnswerSet::mapAS(\@res);
# get a predicate from the results
my @col = AI::Logic::AnswerSet::getPred(\@mappedAS,1,"col");
# get a term of a predicate
my @term = AI::Logic::AnswerSet::getProjection(\@mappedAS,1,"col",2);
=head1 DESCRIPTION
This extension allows to interact with DLV, an Artificial Intelligence system
for Answer Set Programming (ASP).
Please note that the DLV system must appear in the same folder of the perl program
and it must be renamed as "dlv";
DLV can be freely obtained at www.dlvsystem.com.
For further info about DLV and Answer Set Programming please start from www.dlvsystem.com.
lib/AI/Logic/AnswerSet.pm view on Meta::CPAN
If you are using this module, please let us know: we are always
interested in end-users desires, and we wish to improve our library:
comments are truly welcome!
=head2 Methods
=head3 executeFromFileAndSave
This method allows to execute DLV with and input file and save the output in another file.
AI::Logic::AnswerSet::executeFromFileAndSave("outprog.txt","dlvprog.txt","");
In this case the file "outprog.txt" consists of the result of the DLV invocation
with the file "dlvprog.txt".
No code is specified in the third value of the method. It can be used to add code
to an existing file or to a new one.
AI::Logic::AnswerSet::executeFromFileAndSave("outprog.txt","dlvprog.txt",
"b(X):-a(X). a(1).");
=head3 executeAndSave
To call DLV without an input file, directly writing the ASP code from the terminal,
use this method, passing only the name of the output file.
AI::Logic::AnswerSet::executeAndSave("outprog.txt");
Press Ctrl+D to stop using the DLV terminal and execute the program.
=head3 singleExec
Use this method to execute DLV whit several input files, including also
DLV options like "-nofacts".
The output will be stored inside an array.
my @out = AI::Logic::AnswerSet::singleExec("3col.txt","nodes.txt","edges.txt","-nofacts");
Another way to use this method:
my @out = AI::Logic::AnswerSet::singleExec();
In this way it will work like C<executeAndSave()> without saving the output to a file.
=head3 iterativeExec
This method allows to call multiples DLV executions for several instances of the same problem.
Suppose you have a program that calculates the 3-colorability of a graph; in this case
one might have more than a graph, and each graph instance can be stored in a different file.
A Perl programmer might want to work with the results of all the graphs she has in her files,
so this function will be useful for this purpose.
Use it like in the following:
my @outputs = AI::Logic::AnswerSet::iterativeExec("3col.txt","nodes.txt","./instances");
In this case the nodes of each graph are the same, but not the edges.
Notice that in order to correctly use this method, the user must specify the path
to the instances (the edges, in this case).
The output of this function is a two-dimensional array; each element corresponds to the result
of a single DLV execution, exactly as in the case of the function C<singleExec()>.
=head3 selectOutput
This method allows to get one of the results of C<iterativeExec>.
my @outputs = AI::Logic::AnswerSet::iterativeExec("3col.txt","nodes.txt","./instances");
my @out = AI::Logic::AnswerSet::selectOutput(\@outputs,0);
In this case the first output is selected.
=head3 getASFromFile
Parses the output of a DLV execution saved in a file and gather the answer sets.
AI::Logic::AnswerSet::executeFromFileAndSave("outprog.txt","dlvprog.txt","");
my @result = AI::Logic::AnswerSet::getASFromFile("outprog.txt");
=head3 getAS
Parses the output of a DLV execution and gather the answer sets.
my @out = AI::Logic::AnswerSet::singleExec("3col.txt","nodes.txt","edges.txt","-nofacts");
my @result = AI::Logic::AnswerSet::getAS(@out);
=head3 mapAS
Parses the new output in order to save and organize the results into a hashmap.
my @out = AI::Logic::AnswerSet::singleExec("3col.txt","nodes.txt","edges.txt","-nofacts");
my @result = AI::Logic::AnswerSet::getAS(@out);
my @mappedAS = AI::Logic::AnswerSet::mapAS(@result);
The user can set some constraints on the data to be saved in the hashmap, such as predicates, or answer sets, or both.
my @mappedAS = AI::Logic::AnswerSet::mapAS(@result,@predicates,@answerSets);
For instance, think about the 3-colorability problem: imagine to
have the edges in the hashmap, and to print the edges contained in the third answer set
returned by DLV; this is an example of the print instruction, useful to understand how
the hashmap works:
print "Edges: @{$mappedAS[2]{edge}}\n";
In this case, we are printing the array containing the predicate "edge".
=head3 getPred
Easily manage the hashmap and get the desired predicate(see the print example
described in the method above):
my @edges = AI::Logic::AnswerSet::getPred(\@mappedAS,3,"edge");
=head3 getProjection
Returns the projection of the n-th term of a specified predicate.
Suppose that we have the predicate "person" C<person(Name,Surename);> and
that we just want the surenames of all the instances of "person":
my @surenames = AI::Logic::AnswerSet::getProjection(\@mappedAS,3,"person",2);
The parameters are, respectively: hashmap, number of the answer set, name of the predicate,
position of the term.
=head3 statistics
This method returns an array of hashes with some stats of every predicate of every answer set,
namely the number of occurrences of the specified predicates of each answer set.
If a condition is specified(number of predicates), only the answer sets that satisfy
the condition are returned.
my @res = AI::Logic::AnswerSet::getAS(@output);
my @predicates = ("node","edge");
my @stats = AI::Logic::AnswerSet::statistics(\@res,\@predicates);
In this case the data structure returned is the same as the one returned by C<mapAS()>.
Hence, for each answer set (each element of the array of hashes), the hashmap will appear
like this:
{
node => 6
edge => 9
}
This means that for a particular answer set we have 6 nodes and 9 edges.
In addition, this method can be used with some constraints:
my @res = AI::Logic::AnswerSet::getAS(@output);
my @predicates = ("node,"edge");
my @numbers = (4,15);
my @operators = (">","<");
my @stats = AI::Logic::AnswerSet::statistics(\@res,\@predicates,\@numbers,\@operators);
Now the functions returns the answer sets that satisfy the condition, i.e., an answer set
is returned only if the number of occurrences of the predicate "node" is higher than 4, and the number of occurrences of the predicate "edge" less than 15.
=head3 getFacts
Get the logic program facts from a file or a string.
my @facts = AI::Logic::AnswerSet::getFacts($inputFile);
or
my $code = "a(X):-b(X). b(1). b(2).";
my @facts = AI::Logic::AnswerSet::getFacts($code);
DLV code can be freely exploited, with the only constraint of putting a space between rules
or facts.
This is an example of wrong input code:
my $code = "a(X):-b(X).b(1).b(2).";
=head3 addCode
Use this method to quiclky add new code to a string or a file.
my $code = "a(X):-b(X). b(1). b(2).";
AI::Logic::AnswerSet::addCode($code,"b(3). b(4).");
or
my $file = "myfile.txt";
AI::Logic::AnswerSet::addCode($file,"b(3). b(4).");
=head3 createNewFile
Creates a new file with some code.
AI::Logic::AnswerSet::createNewFile($file,"b(3). b(4).");
=head3 addFacts
Quiclky adds facts to a file. Imagine to have some data(representing facts)
stored inside an array; just use this method to put them in a file and give it a name.
AI::Logic::AnswerSet::addFacts("villagers",\@villagers,">","villagersFile.txt");
In the example above, "villagers" will be the name of the facts; C<@villagers> is the array
containing the data; ">" is the file operator(will create a new file, in this case);
"villagersFile.txt" is the filename. The file will contain facts of the form "villagers(X)",
for each "X", appearing in the array C<@villagers>.
=head1 SEE ALSO
www.dlvsystem.com
( run in 0.260 second using v1.01-cache-2.11-cpan-4d50c553e7e )