Well founded semantics for DyLPs

(last update: 04.04.2005)

 

 

  • Example1   (A simple l example, it illustrate how to use the special predicate 'prolog'  )
  • Example2   (An example  showing how undefined literals are treated)
  • Example3   (It shows the behaviour of the semantics when inconsistecyes arise)      

This software implements the Well Founded Semantics for DyLPs.
This semantics is a three valued and paraconsistent, which means
that a predicate P can be either true, false or undefined and that it can be
both true and false at the same time. In the last case the predicate P is said to
be inconsistent.


Syntax:

Rules are of the form:
Head :- Body.
where Head is a literal and Body a conjunction of t-literal separated by ,

To write facts, simply omit the body and the :-

A literal is either an atom 'A', or a default negated atom 'not A'.
One can use predicates with variable, subject to the floundering problem.

A file may contain several update programs separated by 'update.'.

Example:

a(X):- not b(d), c(1).
b(d).
not b(3).
d(X).
c(1).

update

not a(X):- c(1).
c(2).


For now, no explicit negation is considered.

Usage:

WRITING DyLPs.

:- , . not ->           This expressions have the same value that in standard prolog:
                            :-    separates the body and the head of a query,
                            ,     separates two literals in the body of a query,
                            .     marks the end of a query,
                            not before a predicate represents the negation of that predicate.
                            It can be used either in the body or in the head of a rule.
                            

Capitalized names represent variables, while non capitalized names
represent contants.
Examples: p(jhon):- borned(jhon,X), not female(jhon).
not d(G):- not a(J), b(Link,5).

update ->             It marks the beginning of a new update in the sequence.


prolog(exp) ->     Whenever you want to use either a standard prolog predicate (or expression) or a                                predicate coming from a library in the body of a rule put such predicate within the                                special predicate Prolog. In this way the predicate is not subject of any kind of                                transformation that would change its meaning.

Example: p(X,Y,List):- prolog(Z is X + Y), prolog(member(Z,List)), ... .

MANIPULATING DyLPs.

clean ->         resets the knowledge base (i.e retracts all updates made until the present
                    time, including the initial program).

updateF(FileName) ->         It updates the current knowledge base (that may itself be the
                                            result of several updates) with the update program(s) in the
                                            file FileName.


updateL(List) ->                  It updates the current knowledge base with the list of rules List.
                                           Here, each rule must be inside parenthesis.


saveF(FileName) ->             It saves the current knowledge base in the file FileName.

The saved knowledge base can then be consulted using the command
[FileName] as normal source code, but, in this case, just
consult the knowledge base without updating it. If you want to
update the knowledge base store in the file FileName use the command
load(FileName).

loadF(FileName) ->             It loads the current knowledge base in the file FileName.

                                            The knowledge base can than  be either queried or further
                                            updated and the result can be written in FileName or in another file
                                            using the command saveF/1.



current(N) ->                       It returns in N the level of the latest update + 1.


QUERYING DyLPs.


IMPORTANT ->                         Given a predicate P/Ar, the program generate
                                                    another predicate with the same name and ariety Ar+1. The                                                        additional  predicate is the last one and it represents the time when                                                        the query id done. If the answer is yes it means the literal belongs to                                                        the well founded semantics ad that updates.
                                                    If the last argument is now the predicate is queried at the time of the                                                        last update.

To ask if the predicate is false query the predicate with the prefix not_


Examples: p(X,Y) becomes p(X,Y,N).
The query ?- p(X,Y,3) returns yes if p(X,Y) is true at the time of the update 3.
The query ?- not_p(X,Y,now) returns yes if p(X,Y) is FALSE at the time of the LAST update.

REMEMBER: DO NOT CALL THE PREDICATE WITHOUT INSTANTIATING THE
ADDITIONAL ARGUMENT! This would cause the query to flounder. It is
possible to make queries leaving the number of the update as a
free variable the special predicates last/2 and first/2.


last(L,N) ->                     The first argument of last/2 is the literal
                                        L(either positive or negative) that is queried.
                                        The second argument is the time of the query. If the second argument is a                                            variable it is instantiated to the number of the last (i.e. the most recent)                                            update at which L belongs to the well-founded semantics of the considered                                            program.

Examples:  ?last(p(X,Y), N)
                 ?last(not p(X,Y), now).


first(L,N)->                     It works like last(L,N) with the unique difference that N is instantiated to the                                           FIRST UPDATE (i.e. the less recent) at which L belongs to the                                           well-founded semantics of the considered program.

Examples: ?first(p(X,Y), N)
                ?first(not p(X,Y), now).


undef(L,N)->                  It asks to the KB weather L is undefined at the update N.
                                       N must be instantiated to either the number of an update
                                       or now.


Examples: ?undef(p(X,Y), N)
                ?undef(not p(X,Y), now).


inc(L,N)->                        It means L is inconsistent at the update N.
                                        N must be instantiated to either the number of an update or now.

Examples:     ?inc(p(X,Y), N)
                     ?inc(not p(X,Y), now).


consistent(L,N)-> It means L is true and consistent at the update N.
                            N must be instantiated to either the number of an update or now.

Examples:  ?consistent(p(X,Y), N)
                  ?consistent(not p(X,Y), now).


ENJOY :-)


Send your suggestions and comments to bantiAgmail.com (substitute the A with  @ )