logicpicat

"=>" symbol definition in Picat


What is the definition of the symbol "=>" in Picat and how do you read it ? Is it an implication ? I have trouble to understand it since there seems to be no informations about it in the manual nor in the book.

%example using "=>"
main => 
 A = true, 
 B = true,
 C = function(A,B),
 predicate(A,B).
 
function(true,true) = R => R =  true.
predicate(true,true) => true.

How would you describe the meaning of "=>" in the previous example ? Is it just something syntactically required, such as "{" after the declaration of a method in Java, or has a deeper meaning ?


Solution

  • Briefly, if you use => instead of :-, you are essentially writing a deterministic predicate. As we know that Prolog is a practical programming language and it is not necessary to keep all predicates pure. A lot of time, we actually write impure programs by cut and hope single sided unification. The => just provides a convenient mechanism to write such programs.

    You can understand => by program transformation.

    p(A1,A2,...An), C1, C2, ... => Body
    

    is semantically equivalent to

    p(V1,V2,...Vn) :-
        Pattern = p(A1,A2,...An),
        Args = p(V1,V2,...Vn),
        subsumes_term(Pattern, Args),
        Pattern = Args,
        C1, C2, ...,
        !,
        Body.
    

    More detail see https://swi-prolog.discourse.group/t/picat-style-matching