darcs

Patch 2165 stop testing the internals of Prim.commute

Title stop testing the internals of Prim.commute
Superseder Nosy List ganesh
Related Issues
Status accepted Assigned To
Milestone

Created on 2021-05-02.07:52:04 by ganesh, last changed 2021-06-03.10:14:45 by bfrk.

Files
File name Status Uploaded Type Edit Remove
patch-preview.txt ganesh, 2021-05-02.07:52:02 text/x-darcs-patch
stop-testing-the-internals-of-prim_commute.dpatch ganesh, 2021-05-02.07:52:02 application/x-darcs-patch
unnamed ganesh, 2021-05-02.07:52:02 text/plain
See mailing list archives for discussion on individual patches.
Messages
msg22737 (view) Author: ganesh Date: 2021-05-02.07:52:02
I'll leave this a day or two before screening. Actually
refactoring the prim Commute implementation is for
another discussion, but I don't think these tests
add any value regardless of whether the current code
is kept.

1 patch for repository darcs-unstable@darcs.net:screened:

patch 0e7ade582c107af13fbfbe076197da91088fe2e9
Author: Ganesh Sittampalam <ganesh@earth.li>
Date:   Sun May  2 08:36:03 BST 2021
  * stop testing the internals of Prim.commute
  
  The current structure of commute isn't very clear and
  should be refactored, but these tests inhibit that.
Attachments
msg22745 (view) Author: bfrk Date: 2021-05-04.19:58:51
>   * stop testing the internals of Prim.commute
>   
>   The current structure of commute isn't very clear and
>   should be refactored, but these tests inhibit that.

I am absolutely d'accord with the idea. But why do add instead
properties that are already defined in Darcs.Test.Patch.Properties.Generic?
msg22747 (view) Author: ganesh Date: 2021-05-04.20:01:16
I did look around for any properties that seemed to be exact duplicates, but
it wasn't a very thorough search. I'm not adding anything new, just
specialising what was already being run for the "commutex" case of
subcommutes to be a normal property. Very happy to drop them entirely if they
are duplicates.
msg22750 (view) Author: bfrk Date: 2021-05-05.06:49:30
> I did look around for any properties that seemed to be exact duplicates, but
> it wasn't a very thorough search. I'm not adding anything new, just
> specialising what was already being run for the "commutex" case of
> subcommutes to be a normal property.

Okay, I failed to see that immediately.

> Very happy to drop them entirely if they are duplicates.

propCommuteFailurePrim is contained in Generic.commuteInverses
propReadShow is Generic.showRead
propCommuteTwice is Generic.recommute
propCommuteEitherWay is contained in Generic.commuteInverses
propCommuteEitherOrder is Generic.permutivity
...

and so on.

D.T.Patch.Arbitrary.Generic mostly covers all known generic patch
properties. Indeed, some of the properties in there are even redundant
(e.g. mergeEitherWay, see the haddocks).

The squareCommuteLaw got me thinking, though. This is in the two
properties propCommuteInversePrim and propPatchAndInverseIsIdentity
(both are badly named). However, the way it is formulated here checks
that we don't have a conflict. That is, it uses David's original
formulation of the law: if AB<-->B'A' *and* A^B' commutes, then it
commutes to BA'^. This makes it applicable to mergable patches (i.e.
non-prims) if they are invertible. I think a modern version that doesn't
rely on invertibility could be stated as a kind of partial inverse of
the mergeCommute law: if  AB'<-->BA', and
cleanMerge(A\/B)=Just(B''/\A'') then B''=B' and A''=A'. This is
currently missing from the Generic properties and it should be added and
tested. My fault, actually: when we dropped invertibility frommergable
patches I failed to define testable properties for cleanMerge instead.
msg22752 (view) Author: ganesh Date: 2021-05-05.19:11:55
On 05/05/2021 07:49, Ben Franksen wrote:
> 
> Ben Franksen <ben.franksen@online.de> added the comment:
> 
>> I did look around for any properties that seemed to be exact duplicates, but
>> it wasn't a very thorough search. I'm not adding anything new, just
>> specialising what was already being run for the "commutex" case of
>> subcommutes to be a normal property.
> 
> Okay, I failed to see that immediately.
> 
>> Very happy to drop them entirely if they are duplicates.
> 
> propCommuteFailurePrim is contained in Generic.commuteInverses
> propReadShow is Generic.showRead
> propCommuteTwice is Generic.recommute
> propCommuteEitherWay is contained in Generic.commuteInverses
> propCommuteEitherOrder is Generic.permutivity
> ...
> 
> and so on.

FWIW the only ones coming from this specific refactor are:

> propCommuteFailurePrim

As you say this is completely subsumed by Generic.commuteInverses.

> V1Set2.propCommuteInversePrim
> V1Set2.propCommuteNontrivialInversePrim

These two do 4 separate commutes and compares them all. I think it's
probably subsumed by the combination of Generic.commuteInverses and
Generic.squareCommuteLaw, although the preconditions (on
V1Set2.propCommuteInverse*) mean we may get better coverage.

Shall I just drop all three?

We can review/remove the rest in a separate bundle.
msg22754 (view) Author: bfrk Date: 2021-05-06.06:42:01
First, I think you should screen things as they are. You can always
follow up with replacing redundant properties with the corresponding
ones from the Generic module, either in this or in a separate bundle.

>> V1Set2.propCommuteInversePrim
>> V1Set2.propCommuteNontrivialInversePrim
> 
> These two do 4 separate commutes and compares them all. I think it's
> probably subsumed by the combination of Generic.commuteInverses and
> Generic.squareCommuteLaw,

We cannot test Generic.squareCommuteLaw for RepoPatchV1, since it misses
a precondition. The general squareCommuteLaw only holds for prim patches
i.e. it holds only if there are no conflicts.

At least this is what I always thought to be true. See below.

> the preconditions (on
> V1Set2.propCommuteInverse*) mean we may get better coverage.

Looking closer ar propCommuteInverse I am surprised to see that it seems
to hold. It says (precisely) that A;B'<-->B;A' implies A';B'^<-->_;A.
This is (one formulation of) the squareCommute law. It *cannot* hold if
A and B are in conflict, because the conclusion (the RHS of the
implication) means they are *not* in conflict! So the fact that the
tests succeed suggest to me that either (1) we fail to generated
conflicting pairs or (2) I am completely confused about what it means
for two patches to be in conflict with each other.
msg22755 (view) Author: bfrk Date: 2021-05-06.07:50:27
It looks indeed as if we do not generate conflicted (sequential) pairs
for RepoPatchV1. So it's not surprising that the square commute law
tests succeed. I thought the generators for RepoPatchV1 were using
D.T.P.A.PatchTree.Tree but apparently they do not. This means that all
the property tests for RepoPatchV1 that take sequential pairs as input
actually only test prim patches. My conclusion is that they are useless
and can be eliminated.
msg22827 (view) Author: bfrk Date: 2021-06-03.10:14:44
I agree with the rationale and the changes are indeed pretty much 
straight forward and look good.
History
Date User Action Args
2021-05-02 07:52:04ganeshcreate
2021-05-04 19:58:51bfrksetmessages: + msg22745
2021-05-04 20:01:16ganeshsetmessages: + msg22747
2021-05-05 06:49:32bfrksetmessages: + msg22750
2021-05-05 19:11:57ganeshsetmessages: + msg22752
2021-05-06 06:42:03bfrksetmessages: + msg22754
2021-05-06 07:50:28bfrksetmessages: + msg22755
2021-05-06 19:51:51ganeshsetstatus: needs-screening -> needs-review
2021-06-03 10:14:45bfrksetstatus: needs-review -> accepted
messages: + msg22827