Do patches need to be open source?

Discussion of anything and everything relating to chess playing software and machines.

Moderators: hgm, Rebel, chrisw

User avatar
hgm
Posts: 27787
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: Do patches need to be open source?

Post by hgm »

syzygy wrote:
Ovyron wrote:Suppose I implement some Learning Algorithm in Stockfish, but I don't want to open the source, because I want to keep my Algorithm secret.

Apparently, releasing the engine would be against the Licence Agreement.

So what if I release some other exe that when it's run, it patches Stockfish and makes it have learning?

Note this isn't very different from releasing a closed source Stockfish, because I'd be giving people the option of turning their Stockfishes into learning Stockfishes at home, so that they end up with a closed source Stockfish, just as if I gave them to them on the first place.

But doing it this way would be fine?
As long as your exe contains no Stockfish code, it cannot infringe the copyright on Stockfish and so the GPL does not apply.

But it seems to me the idea will not work very well. If your exe patches the Stockfish source code, any user of your exe will be free to distribute that source code including your changes.

So you would have to make an exe that patches a particular Stockfish compile. But that is practically impossible to do. (It may be possible if your learning code has almost no interaction with the SF search code, but then you could as well implement learning in the GUI instead.)
Well, I am not so sure. You might be happy with one particular Stockfish compile (e.g. a Windows .exe), which you provide yourself.

I am also not so certain about your statement that people who would patch the source code with the aid of a program they bought would be free to distribute it. The code that this patching program inserts would not be theirs. They are just licensed to use it , as buyers of the patching program. That the program inserts it into Stockfish doesn't make it GPL, it only makes it illegal for them to distribute the patched version. But that is fine as long as they don't start distributing the binaries.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Do patches need to be open source?

Post by syzygy »

I guess what would work (and what others here already basically proposed) is to release your algorithm as a closed-source dynamically linked library together with a source-level patch to Stockfish to let the engine make the appropriate library calls.

The patch could be closed source as long as you don't include any Stockfish code. That would mean the patch has to be based on line numbers, which isn't very flexible but still quite doable. Since you're not distributing any GPL'd code, your are 100% safe.

I think you would still be legal if you distributed the modified Stockfish binary together with its modified source and your closed-source library. This is slightly more tricky, but in my view the modified Stockfish and the closed-source library are separate copyrighted works. You are free to distribute one GPL'd work under the GPL and another non-GPL'd work under a restrictive license. The FSF might not like that, but copyright was not designed to suit the needs of the FSF.
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

Re: Do patches need to be open source?

Post by velmarin »

syzygy wrote:
I think you would still be legal if you distributed the modified Stockfish binary together with its modified source and your closed-source library. This is slightly more tricky, but in my view the modified Stockfish and the closed-source library are separate copyrighted works. You are free to distribute one GPL'd work under the GPL and another non-GPL'd work under a restrictive license. The FSF might not like that, but copyright was not designed to suit the needs of the FSF.
Oh, YES. :D

Whether you like it or not.
There are several programs that are open source and have a Nalimov library closed.
I guess if the modification is in a closed library, but it is included with the Stokfish code, and can be compiled by the user must be legal.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Do patches need to be open source?

Post by syzygy »

hgm wrote:I am also not so certain about your statement that people who would patch the source code with the aid of a program they bought would be free to distribute it. The code that this patching program inserts would not be theirs. They are just licensed to use it , as buyers of the patching program.
Yes, you are right.
That the program inserts it into Stockfish doesn't make it GPL, it only makes it illegal for them to distribute the patched version. But that is fine as long as they don't start distributing the binaries.
Agreed.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Do patches need to be open source?

Post by syzygy »

velmarin wrote:
syzygy wrote:
I think you would still be legal if you distributed the modified Stockfish binary together with its modified source and your closed-source library. This is slightly more tricky, but in my view the modified Stockfish and the closed-source library are separate copyrighted works. You are free to distribute one GPL'd work under the GPL and another non-GPL'd work under a restrictive license. The FSF might not like that, but copyright was not designed to suit the needs of the FSF.
Oh, YES. :D

Whether you like it or not.
There are several programs that are open source and have a Nalimov library closed.
I guess if the modification is in a closed library, but it is included with the Stokfish code, and can be compiled by the user must be legal.
Nalimov is an interesting example.

I think I have argued myself in the past that Fruit Reloaded cannot legally access Nalimov TBs (assuming it uses Nalimov's code with no permission from Nalimov to release it under GPL). Maybe I was wrong.

Of course it is legal to start from a GPL'd version of Fruit and hack it to use Nalimov. The question is when is it legal to distribute the result.

Distributiing a modified Fruit binary that includes Nalimov's code is of course against the GPL.

I don't see a problem with distributing modified Fruit source that calls Nalimov's access code. Without egtb.cpp it might not even compile, but can the GPL force me to release only modifications that compile without errors?

What if I distribute the modified source code together with egtb.cpp and argue that each source file is a separate work. The Fruit files are GPL'd, egtb.cpp is not. The FSF certainly would not like this, but it's not clear to me that I am violating the GPL.

What if I let Fruit link dynamically so that it can be compiled and run without any Nalimov code but can be configured to load the dll? I would say that's OK.

What if the compiled Fruit loads the dll at startup so it can't be run without the dll? That's more tricky, but of course a windows executable can be GPL even though it needs closed-source Windows to function...

The GPL relies a lot on "please understand our intentions and interpret copyright law in accordance with those intentions".
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

Re: Do patches need to be open source?

Post by velmarin »

syzygy wrote:
Yeah, that's a good point,
but if we include the Nalimov access in .lib file, which is compiled inside the executable, of course accessible with the original code, without traps.

If there is a secret in the .lib file, it is not displayed.
User avatar
velmarin
Posts: 1600
Joined: Mon Feb 21, 2011 9:48 am

Re: Do patches need to be open source?

Post by velmarin »

syzygy wrote:
Taking advantage of this thread I would like to know your opinion of this hypothetical scene:
Houdini or Komodo (examples), have access to Syzygy, are closed source and do not show that part of the code either.
Let's say they decide to use the derived and named Fathom code that has been given a GPL.
How to do this, a closed code and what they would do, a link to the github and fixed.
Ras
Posts: 2487
Joined: Tue Aug 30, 2016 8:19 pm
Full name: Rasmus Althoff

Re: Do patches need to be open source?

Post by Ras »

syzygy wrote:I guess what would work (and what others here already basically proposed) is to release your algorithm as a closed-source dynamically linked library together with a source-level patch to Stockfish to let the engine make the appropriate library calls.
That would not work because it would still be a combined program. Dynamic linking makes no difference for GPL, unlike LGPL:
https://www.gnu.org/licenses/gpl-faq.en ... cVsDynamic

Then there is the question when a program actually is a combined program, and the idea of just using dynamic library function calls would not wash:
https://www.gnu.org/licenses/gpl-faq.en.html#GPLPlugins

The level of separation that is required is also explained in that article. For example a closed source GUI like Arena can be combined with a GPL'ed engine like Stockfish.

And then we have item 5.c from the GPL:
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
...
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy.
So the whole idea of the binary patch is a non-starter.
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Do patches need to be open source?

Post by syzygy »

velmarin wrote:
syzygy wrote:
Taking advantage of this thread I would like to know your opinion of this hypothetical scene:
Houdini or Komodo (examples), have access to Syzygy, are closed source and do not show that part of the code either.
Let's say they decide to use the derived and named Fathom code that has been given a GPL.
How to do this, a closed code and what they would do, a link to the github and fixed.
In my view linking to a GPL'd Fathom library dynamically does not require the linking program to be GPL.

The FSF seems to have a different view: https://www.gnu.org/licenses/gpl-faq.ht ... braryIsGPL:
Yes, because the program actually links to the library. As such, the terms of the GPL apply to the entire combination. The software modules that link with the library may be under various GPL compatible licenses, but the work as a whole must be licensed under the GPL.
I think they're right if they are talking about a statically linked executable. But I doubt that the GPL forbids you from distributing a program that, when executed, happens to link to and call functions in a non-GPL library.

In principle a license could probably say "you can modify this code or include the code in another program and distribute the result, but not if that resulting program does X, Y or Z". Whether such conditions are valid might differ from country to country. But it seems the GPLv3 only forbids distributing ("conveying") the modified program if you do not license "the entire work, as a whole" under the GPLv3.

How should I understand that? What if my modified program does not yet compile? Does it then not qualify as "the entire work"? Would it be a GPL violation to publish the modified code on github?

If I implement some calls to an API, does the "entire work" then become the modified program plus any library that implements the API? What if there are GPL implementations of the API and non-GPL implementations? This is confusing!
syzygy
Posts: 5557
Joined: Tue Feb 28, 2012 11:56 pm

Re: Do patches need to be open source?

Post by syzygy »

Ras wrote:
syzygy wrote:I guess what would work (and what others here already basically proposed) is to release your algorithm as a closed-source dynamically linked library together with a source-level patch to Stockfish to let the engine make the appropriate library calls.
That would not work because it would still be a combined program. Dynamic linking makes no difference for GPL, unlike LGPL:
https://www.gnu.org/licenses/gpl-faq.en ... cVsDynamic
That's what they say. Does not make it true.

And in fact it is 100% certain that if some code does not include any GPL code, the GPL is simply irrelevant to it.