## 4.15 Examining the program

current_atom(-Atom)
  Successively unifies Atom with all atoms known to the system. Note that current_atom/1 always succeeds if Atom is instantiated to an atom.
current_blob(?Blob, ?Type)
  Examine the type or enumerate blobs of the given Type. Typed blobs are supported through the foreign language interface for storing arbitrary BLOBS (Binary Large Object) or handles to external entities. See section 9.6.6 for details.
current_functor(?Name, ?Arity)
  Successively unifies Name with the name and Arity with the arity of functors known to the system.
current_flag(-FlagKey)
  Successively unifies FlagKey with all keys used for flags (see flag/3).
current_key(-Key)
  Successively unifies Key with all keys used for records (see recorda/3, etc.).
current_predicate(?Name, ?Head)
  Successively unifies Name with the name of predicates currently defined and Head with the most general term built from Name and the arity of the predicate. This predicate succeeds for all predicates defined in the specified module, imported to it, or in one of the modules from which the predicate will be imported if it is called.
[ISO]current_predicate(:PredicateIndicator)
  ISO compliant implementation of current_predicate/2. Unlike current_predicate/2, the current implementation of current_predicate/1 does not consider predicates that can be autoloaded `current'.
predicate_property(:Head, ?Property)
  True if Head refers to a predicate that has property Property. Can be used to test whether a predicate has a certain property, obtain all properties known for Head, find all predicates having property or even obtaining all information available about the current program. Property is one of:
  built_in
    Is true if the predicate is locked as a built-in predicate. This implies it cannot be redefined in its definition module and it can normally not be seen in the tracer.
  dynamic
    Is true if assert/1 and retract/1 may be used to modify the predicate. This property is set using dynamic/1.
  exported
    Is true if the predicate is in the public list of the context module.
  imported_from(Module)
    Is true if the predicate is imported into the context module from module Module.
  file(FileName)
    Unify FileName with the name of the source file in which the predicate is defined. See also source_file/2.
  foreign
    Is true if the predicate is defined in the C language.
  indexed(Head)
    Predicate is indexed (see index/1) according to Head. Head is a term whose name and arity are identical to the predicate. The arguments are unified with `1' for indexed arguments, `0' otherwise.
  interpreted
    Is true if the predicate is defined in Prolog. We return true on this because, although the code is actually compiled, it is completely transparent, just like interpreted code.
  line_count(LineNumber)
    Unify LineNumber with the line number of the first clause of the predicate. Fails if the predicate is not associated with a file. See also source_file/2.
  multifile
    Is true there may be multiple (or no) file providing clauses for the predicate. This property is set using multifile/1.
  nodebug
    Details of the predicate are not shown by the debugger. This is the default for built-in predicates. User predicates can be compiled this way using the Prolog flag generate_debug_info.
  notrace
    Do not show ports of this predicate in the debugger.
  number_of_clauses(ClauseCount)
    Unify ClauseCount to the number of clauses associated with the predicate. Fails for foreign predicates.
  thread_local
    If true (only possible on the multi-threaded version) each thread has its own clauses for the predicate. This property is set using thread_local/1.
  transparent
    Is true if the predicate is declared transparent using the module_transparent/1 declaration.
  undefined
    Is true if a procedure definition block for the predicate exists, but there are no clauses for it and it is not declared dynamic or multifile. This is true if the predicate occurs in the body of a loaded predicate, an attempt to call it has been made via one of the meta-call predicates or the predicate had a definition in the past. See the library package `library(check)` for example usage.
  volatile
    If true, the clauses are not saved into a saved-state by qsave_program/[1,2]. This property is set using volatile/1.
dwim_predicate(+Term, -Dwim)
  `Do What I Mean' (`dwim') support predicate. Term is a term, which name and arity are used as a predicate specification. Dwim is instantiated with the most general term built from Name and the arity of a defined predicate that matches the predicate specified by Term in the `Do What I Mean' sense. See dwim_match/2 for `Do What I Mean' string matching. Internal system predicates are not generated, unless `style_check(+dollar)` is active. Backtracking provides all alternative matches.
[ISO]clause(:Head, ?Body)
  True if Head can be unified with a clause head and Body with the corresponding clause body. Gives alternative clauses on backtracking. For facts Body is unified with the atom true.
clause(:Head, ?Body, ?Reference)
  Equivalent to clause/2, but unifies Reference with a unique reference to the clause (see also assert/2, erase/1). If Reference is instantiated to a reference the clause's head and body will be unified with Head and Body.
nth_clause(?Pred, ?Index, ?Reference)
  Provides access to the clauses of a predicate using their index number. Counting starts at 1. If Reference is specified it unifies Pred with the most general term with the same name/arity as the predicate and Index with the index-number of the clause. Otherwise the name and arity of Pred are used to determine the predicate. If Index is provided Reference will be unified with the clause reference. If Index is unbound, backtracking will yield both the indices and the references of all clauses of the predicate. The following example finds the 2nd clause of member/2:

      ?- nth_clause(member(_,_), 2, Ref), clause(Head, Body, Ref).

      Ref = 160088
      Head = system : member(G575, [G578|G579])
      Body = member(G575, G579)

clause_property(+ClauseRef, -Property)
  Queries properties of a clause. ClauseRef is a reference to a clause as produced by clause/3, nth_clause/3 or prolog_frame_attribute/3. Property is one of the following:
  file(FileName)
    Unify FileName with the name of the source file in which the clause is defined. Fails if the clause is not associated to a file.
  line_count(LineNumber)
    Unify LineNumber with the line number of the clause. Fails if the clause is not associated to a file.
  fact
    True if the clause has no body.
  erased
    True if the clause has been erased, but not yet reclaimed because it is referenced.