:- module(coSLD,
          [ cosld/1
          ]).

:- use_module(library(lists)).

inductive(Atom) :- predicate_property(Atom,built_in),!.
inductive(Atom) :- predicate_property(Atom,imported_from(library(_))).

cosld(Goal) :- solve([],Goal).

solve(Hypothesis, (Goal1,Goal2)) :- !,solve(Hypothesis, Goal1), solve(Hypothesis,Goal2).
solve(_,Atom) :- inductive(Atom), !, Atom.
solve(Hypothesis,Atom):- member(Atom, Hypothesis).
solve(Hypothesis,Atom):- clause(Atom,Atoms),solve([Atom|Hypothesis],Atoms).


