Did you know ... Search Documentation:
Pack pepl -- prolog/pepl.pl
PublicShow source

Pepl is an implemention of the failure adjusted (FAM) algorithm which does parameter estimation (PE) of the probability labels of stochastic logic programs (SLPs).

See documentation fam/1 for details on how to run parameter estimation on SLPs.

Example stochastic programs are in directory slp and example run scripts are in examples.


This software is distributed under the MIT licence.

Installation and testing ...

Pepl runs on current versions of SWI (7) and Yap (6.3).

... on SWI


... on Yap

Download latest sources from http://stoics.org.uk/~nicos/sware/pepl or https://github.com/nicos-angelopoulos/pepl

gunzip pepl-*tgz
tar xf pepl-*tar
cd pepl-*
cd examples

Package information

- Nicos Angelopoulos
- 2.2, 2022/1/2
- 2.1, 2017/2/25
- 2.0.6, 2014/01/28
See also
- the user guide at pack('pepl/doc/pepl-user_guide.pdf').
- James Cussens. Parameter estimation in stochastic logic programs. Machine Learning, 44(3):245-271, 2001. ftp://ftp.cs.york.ac.uk/pub/aig/Papers/james.cussens/jcslpmlj.pdf
- Nicos Angelopoulos, Notes on the implementation of FAM, 3rd Probabilistic Logic Programming workshop (a ILP 2016 workshop), 03/09/2016, http://ceur-ws.org/Vol-1661/paper-05.pdf
- pepl website http://stoics.org.uk/~nicos/sware/pepl
- This software is distributed under the MIT licence
Run the failure adjusted maximisation (FAM) parameter estimation algorithm.

For SLP source file jc_ml_S1.slp

0.5:: s(X,p) :- p(X), p(X).
0.5:: s(X,q) :- q(X).
0.5:: p(a).
0.5:: p(b).
0.5:: q(a).
0.5:: q(b).

and data file jc_ml_S1_data.pl


the call succeeds with the learned PPs

?- fam( [goal(s(_A,_B)),slp(jc_ml_S1),datafile('jc_ml_S1_data.pl'),final_pps(PPs)] ).
PPs = [0.6602,0.3398,0.5858,0.4142,0.5,0.5]


CountMeth in {exact, store, sample};
only relevant with CountMeth=sample
currently TermList knows about the following terms
ask user if another iteration should be run
I is the number of iterations
parameter difference between iteration, that renders termination due to convergence of all parameters, between two iterations
likelihood convergence limit;
the top goal, defaults to an all vars version of data;
a goal that called only once, before experiments are run. The intuition is that PreGoal will partially instantiate Goal.
the data to use, overrides datafile/1. Data should be a list of Yield-Times pairs. (All Yields of Goal should be included in Data, even if that means some get Times = 0.)
the distribution to replace the probability labels with. By default prior is used, so input parameters are used as given in Slp source file. System also knows about uniform and random. Any other distribution should come in Prolog source file named Prior.pl and define Prior/3 predicate. First argument is a list of ranges (Beg-End) for each stochastic predicate in source file. Second argument, is the list of actual probability labels in source file. Finally, third argument should be instantiated to the list of labels according to Prior.
the data file to use, default is data.pl. DataFile should have either a number of atomic formulae or a single formula of the form : frequencies(Data).
one of : none (with PrbSc = PrbTrue, the default), success (with PrbSc = 1 − PrbF ail), or quotient (with PrbSc = PrbT rue/(PrbT rue + PrbF ail)).
sets random seeds. SetRand = true sets the seeds to some random triplet while the default value false, does not set them. Any other value for SetRand is taken to be of the form rand(S1,S2,S3) as expected by system predicate random of the supported prolog systems.
the depth Epsilon. Sets the probability limit under which Pepl considers a path as a failed one.
indicates which set of parameters to output. Values for Wrt are: all, last and none.
takes a boolean argument, idicating where loglikelihoods should be printed or not.
should be set to on or off. If on, various information about intermediate calculations will be printed.
a list of return options. The terms RetOpts contain variables. These will be instantiated to the appropriate values signified by the name of each corresponding term. Recognised are, initial pps/1 for the initial parameters, final pps for the final/learned parameters, termin/1 for the terminating reason, ll/1 for the last loglikelyhood calculated, iter/1 for the number of iterations performed, and seeds/1 for the seeds used.
if true, the temporary Prolog file that contains the translated SLP, is not deleted.
identifies the action to be taken if an exception is raised while running Fam. rerun means that the same Fam call is executed repeatedly. Any other value for Handle will cause execution to abort after printing the exception raised.
 pepl_citation(-Atom, -Bibterm)
This predicate succeeds once for each publication related to this library. Atom is the atom representation suitable for printing while Bibterm is a bibtex(Type,Key,Pairs) term of the same publication. Produces all related publications on backtracking.
 pepl_version(-Version, -Date)
Pepl's current Version (Maj:Min:Fix) and publication date (date(Year,Month,Day)).
?- pepl_version(V,D).
V = 2:2:0,
D = date(2021, 1, 1).
Save the stochastic program currently in memory to a file.
Listing of the stochastic program currently in memory.
 sload_pe(Files, Options)
Load an SLP to memory. If the source file has an slp extension the extension may be omitted. Pepl looks in the following directories and order for the source file(s). ., and ./slp/ while on SWI it also looks in, pack(’pepl/slp/’).
Sample (=call) Goal
?- sload_pe(coin).
?- set_random(seed(101)).
?- scall(coin(Flip)).
Flip = head.

?- scall(coin(Flip)).
Flip = tail.

If you have packs: mlu, b_real and Real.

?- lib(mlu).
?- sload_pe(coin).
?- mlu_sample( scall(coin(Side)), 100, Side, Freqs ), mlu_frequency_plot( Freqs, [interface(barplot),outputs([svg]),las=2] ).

Produces file: real_plot.svg


To demonstrate the inability of SLPs to operate over arbitrary length objects, check:

?- sload_pe(member3).
?- lib(mlu).
?- set_random(seed(101)).
?- mlu_sample( scall(member3(X,[a,b,c])), 100, X, Freqs ), mlu_frequency_plot( Freqs, [interface(barplot),outputs(png),stem('meb3from3'),las=2] ).

Produces file: meb3from3.png



?- sload_pe(member3).
?- lib(mlu).
?- set_random(seed(101)).
?- mlu_sample( scall(member3(X,[a,b,c,d,e,f,g,h])), 100, X, Freqs ), mlu_frequency_plot( Freqs, [interface(barplot),outputs(png),stem('meb3from8'),las=2] ).

Produces file: meb3from8.png


See also
- scall/6
 scall(Goal, Eps, Meth, Path, Succ, Prb)
This predicate is for people interested in the iternals of pepl. Use at your own peril.

The predicate arguments are as follows.

  • The vanilla prolog Goal to call.
  • The value of Eps(ilon) at which branches are to be considered as failures.
  • The search Method to be used, (all for all solutions or sample for a single solution).
  • The Path(s) of the derivation(s).
  • A flag idicating a Succ(essful) derivation or otherwise-Succ is bound to the atom fail if this was a failed derivation and remains unbound otherwise. BrPrb the branch probability of the derivation. if this was a failed derivation and remains unbound otherwise.
  • BrPrb the branch probability of the derivation.

See predicate main_gen/1, in examples/main_scfg.pl for example usage.

You can use scall/6 to sample from an SLP.

?- sload_pe(coin).
?- set_random(seed(101)).
?- scall(coin(Flip), 0, sample, Path, Succ, Prb ).
Flip = head,
Path = [1],
Prb = 0.5.

... or to backtrack overall paths

?- scall(coin(Flip), 0, all, Path, Succ, Prb ).
Flip = head,
Path = [1],
Prb = 0.5 ;
Flip = tail,
Path = [2],
Prb = 0.5.
Switch debugging of fam/1 to either on or off.
Call Goal iff in (pepl) debugging.

Undocumented predicates

The following predicates are exported, but not or incorrectly documented.

 sload_pe(Arg1, Arg2)