How to deal with my results being stolen? I have experienced a couple of times the following problem: I have asked another researcher to cooperate and provided mathematical results (as a basis for an algorithm). The cooperation has not proceeded as fast as expected and the other party has taken my results and integrated them into a work that he has published with other people. There are two questions: 


How to initiate cooperation with new people and still avoid this problem? The mathematical properties are central in our research. New algorithms cannot be created, unless we first invent some clever properties that prune the search space (so, the properties are the heart of the algorithm, the rest is usually straight-forward). So, they have to be invented first and this inventing happens to be my speciality. Unfortunately, it is easy to proceed without me, when I have done this difficult part. So, I don't know whom and when I could give the results. They should be shared pretty soon, since we should all be able to ponder together how to integrate the new properties in the algorithm. Sometimes we may also find that they are not useful or strong enough and new results are needed, so ideally this invention-brainstorming process would be iterative.
How should I refer to my own results, if others have published them first? Should I still give a reference to their publication, when I use them for something new? This is now an important question since I have invented a new use for one of my previous results. (Naturally, I don't like the idea I should refer to somebody else for my own invention.)


I would also like to understand the behaviour of those other researchers. I have a few hypotheses:


It's possible they underestimate the invention work, because I
usually present only the final results as nice compact proofs +
explanation what the result means in practice. In reality, deriving
the results may easily take 100 hours or more - proving by trial and
error, guided by intuition and earlier results. 
I have been only a post-doc, when this happened, so I had no authority. They may think it is easier to get a paper published if it is written with some better
known researchers. 
These people have been from other countries and had a different mother tongue than me, while they have published the results with
people who were either geographically close (even the same research
group) or spoke the same language they did. So maybe the question is
about easy communication and cooperation?
The original research had suffered from delays, like rejected project application. It would have continued but not in the original schedule (from my part). So maybe they wanted to get things published faster or even assumed I won't get any funding for future research.


What do you think is the explanation? Understanding the reasons would help to avoid the problem in future.
How to initiate cooperation with new people and still avoid this
  problem?


You need some basic trust in the people you want to cooperate with before starting to share ideas. In some cases, you might know coauthors of them. Talk to them and hopefully they will drop hints on whether the collaboration was fair or if you need to be careful. I have indeed gotten warnings from other researchers (inside my own institute) regarding who I can trust and who tries to steal ideas. And I also pass on such information (after validating it) to new researchers.

But most important: Before starting any serious exchange of information, define basic rules for all of you. For example, anything which is developed throughout this collaboration must only be published with everyone agreeing to it. Create proof of this via a digitally signed email.

Of course, you might not be able to fully trust ANY person. So take care and create proof of your initial ideas. I tend to create repositories with revision-tracking (via GIT or SVN) of the joint work during collaboration. Everything should be stored therein, for example, any paper that you are writing or simulation data. Even if you get into trouble later on, you can proof, WHEN and WHAT you contributed.