All predicatesShow sourcecoinduction.pl -- Co-Logic Programming

This simple module implements the directive coinductive/1 as described in "Co-Logic Programming: Extending Logic Programming with Coinduction" by Luke Simon et al. The idea behind coinduction is that a goal succeeds if it unifies to a parent goal. This enables some interesting programs, notably on infinite trees (cyclic terms).

:- use_module(library(coinduction)).

:- coinductive p/1.

p([1|T]) :- p(T).

This predicate is true for any cyclic list containing only 1-s, regardless of the cycle-length.

See also
- "Co-Logic Programming: Extending Logic Programming with Coinduction" by Luke Simon et al.
bug
- Programs mixing normal predicates and coinductive predicates must be stratified. The theory does not apply to normal Prolog calling coinductive predicates, calling normal Prolog predicates, etc.

Stratification is not checked or enforced in any other way and thus left as a responsibility to the user.

Source head(+Term, -QHead) is semidet[private]
Must be first to allow reloading!
Source coinductive(:Spec)
The declaration :- coinductive name/arity, ... defines predicates as coinductive. The predicate definition is wrapped such that goals unify with their ancestors. This directive must precede all clauses of the predicate.
Source wrap_coinductive(+Head, +Term, -Clauses) is det[private]
Create a wrapper. The first clause deal with the case where we already created the wrapper. The second creates the wrapper and the first clause.
Source rename_clause(+Clause, +Prefix, -Renamed) is det[private]
Rename a clause by prefixing its old name wit h Prefix.