Can a prologue respond vaguely, and not just yes or no?

Suppose I have a knowledge base

likes(john,mary).
person(mary).
person(john).

If we ask for a prologue, <

|?- likes(mary,john)

He will answer no , because we did not state this. Is there a way to make the prolog request unknown if we do not explicitly specify.

\+ likes(mary,john)

In other words, we can ask the prologue to treat unrelated expressions as possible, rather than false ones. I use the IDP system, which allows for existential quantification and considers unapproved relationships as if connected, rather than false, but I would like to use something more basic. http://adams.cs.kuleuven.be/idp/server.html

For example, in IDP you can make a statement

vocabulary V{
    type Person
    Likes(Person,Person)
}


theory T: V{

    //Everyone might like someone and disallow narcisiscm
    !x : ?y: Likes(x,y) & ~Likes(x,x).

}

//some instance without special meaning
structure S:V{
    Person={A..C}
}

procedure main(){
    //Print all possible solutions
    printmodels(allmodels(T,S))
}

What gives

Number of models: 27
Model 1
=======
structure  : V {
  Person = { "A"; "B"; "C" }
  Likes = { "A","B"; "A","C"; "B","A"; "B","C"; "C","A"; "C","B" }
}
//...
+4
2

, Prolog , , , , , true - a no , , , . , , , - - :

like(true, mary, john).
like(false, mary, nick).
like(unknown, X, Y).

, (, , ) , , , , - ​​ , , , .

+2

, , : Prolog World Assumption (CWA). , , .

-, Prolog , , .

, , true false.

, GNU Prolog:

| ?- X #\= 3.

X = _#2(0..2:4..127@)

- , , , .

.

:

| ?- fd_all_different([X,Y,Z]), fd_domain([X,Y,Z], 0, 1).

X = _#2(0..1)
Y = _#20(0..1)
Z = _#50(0..1)

yes

! , :

| ?- fd_all_different([X,Y,Z]), fd_domain([X,Y,Z], 0, 1),
     fd_labeling([X,Y,Z]).

no

, maybe yes.

, , .

Prolog , , .

+1

Source: https://habr.com/ru/post/1671735/


All Articles