How are Prolog and CHR supposed to interact?

@meditans in your solution here:

I’m trying to understand how you get things into the constraint store in the first place. It seems to be related to the local_chr predicate which is defined as follows:

find_constraint(Goal, Cs) :-
    findall(Goal, find_chr_constraint(Goal), Cs).

local_chr(Facts, Result, Res) :-
    thread_create((maplist(call, Facts),
                   find_constraint(Result, Ns),
                   thread_exit(Ns)), Id),
    thread_join(Id, exited(Res)).

It is invoked here:

parse(File, Mat-Ns) :-
    once(phrase_from_file(input(Mat), File)),
    findall(n(I-J, 1, N), position(Mat, I-J, dgt(N)), Constraints),
    local_chr(Constraints, n(_, _, _), Ns).

… and that seems to be what activates the constraints and adds to them, but I don’t understand what’s going on here. It looks like local_chr calls all the facts in a new thread, is that what activates the constraints? It then uses find_constraint to extract the result back into Ns. Is that right?