What meta argument is predicate_property / 2's first argument?

In other words, should it be 0or :or something else? Prolog SICStus, YAP, and SWI systems point this out :. Is this appropriate? Doesn't 0that mean what a term can be called up call/1?

To check your system type:

| ?- predicate_property(predicate_property(_,_),P).
P = (meta_predicate predicate_property(:,?)) ? ;
P = built_in ? ;
P = jitted ? ;
no

I should add that the meta arguments are at least as in the form used here; cannot guarantee the same algebraic properties that we expect from pure relations:

?- S=user:false, predicate_property(S,built_in).
S = user:false.

?- predicate_property(S,built_in), S=user:false.
false.

Here is the relevant part from ISO / IEC 13211-2:

7.2.2 predicate_property / 2

7.2.2.1 Description

predicate_property(Prototype, Property)is true in the context of invoking a module call Mif the procedure associated with the argument Prototypehas a predicate property Property.

...

7.2.2.2

predicate_property(+prototype, ?predicate_property)

7.2.2.3

a) Prototype - β€” instantiation_error.

...

c) Prototype ,
β€” type_error(callable, Prototype).

...

7.2.2.4

Goals attempted in the context of the module
bar.

predicate_property(q(X), exported).
    succeeds, X is not instantiated.

...

+4
1

. , predicate_property/2. , , write/1, nl/0 .., ..:

solve((A,B)) :- !, solve(A), solve(B).
solve(A) :- predicate_property(A, built_in), !, A.
solve(A) :- clause(A,B), solve(B).

, , 0 . predicate_property/ 2 . - ISO.

F/N, F - N - . , - (:)/2 (/)/2. , :

solve((A,B)) :- !, solve(A), solve(B).
solve(A) :- functor(A,F,N), predicate_property(F/N, built_in), !, A.
solve(A) :- clause(A,B), solve(B).

- 0, solve/1, . functor/3 -. functor/3 predicate_property/2 , functor/3 , , , .

:
1) / functor/3.
2) functor/3, .

:
1) . ,   .   functor/3 :

  :- meta_predicate functor(?,?,?).
  :- meta_predicate functor(0,?,?).

  , (=)/2. :

  :- meta_predicate =(?,?).
  :- meta_predicate =(0,0).

, , ,  (=)/2 , ,   .

, ,   cast,   . -,   -  .   .

 , . , (=)/2   A, :

 :- meta_predicate =(A,A).

2) Jekejeke Prolog   /3. sys_modfunc_site/2.   , functor/3,   .   :

 ?- sys_modfunc_site(a:b(x,y), X).
 X = a:b/2
 ?- sys_modfunc_site(X, a:b/2).
 X = a:b(_A,_B)

  . , SWI-Prolog  , listing/1. , -   listing/1 . : SWI-Prolog.   , , predicate_property/2 : :

 :- meta_predicate sys_modfunc_site(?,?).
 :- meta_predicate sys_modfunc_site(0,:).

, ,   . , ,   sys_indicator_colon/2,   ,  predicate_property/2   :

solve((A,B)) :- !, solve(A), solve(B).
solve(A) :- 
      sys_modfunc_site(A,I), 
      sys_indicator_colon(J,I), 
      predicate_property(J, built_in), !, A.
solve(A) :- clause(A,B), solve(B).

(:)/2,    (:)/2, ISO.    .   .

Jekejeke   , .   sys_modfunc_site/2 sys_indicator_colon/2   , predicate_property/2   ,   , ..

:
  Jekejeke Prolog -   ,   .   . ,   :

 ?- [user].
 foo:bar.
 ^D

, sys_modfunc_site/2  , sys_indicator_colon/2:

  ?- S = foo:bar/0, sys_indicator_colon(R,S), predicate_property(R,static).
  S = foo:bar/0,
  R = 'foo%bar'/0
  ?- predicate_property(R,static), sys_indicator_colon(R,S), S = foo:bar/0.
  R = 'foo%bar'/0,
  S = foo:bar/0

, , predicate_property/2  . , SWI-Prolog phaenomenom   , .   false user, system false.   , .   SWI-Prolog:

 ?- predicate_property(X, built_in), write(X), nl, fail; true.
 portray(_G2778)
 ignore(_G2778)
 ...
 ?- predicate_property(user:X, built_in), write(X), nl, fail; true.
 prolog_load_file(_G71,_G72)
 portray(_G71)
 ...
 ?- predicate_property(system:X, built_in), write(X), nl, fail; true.
 ...
 false
 ...

SWI-Prolog predicate_property/ 2   , .. ,   ,  . M:G G  M, M,   .

- , user:false  system:false. , , M:G  M:G , .   user:false system:false.

Bye

+2

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


All Articles