CAP_project icon indicating copy to clipboard operation
CAP_project copied to clipboard

Make use of the opposite category to automatically generate code for opposite derivations

Open mohamed-barakat opened this issue 3 years ago • 4 comments

As discussed with Fabian it would be desirable to write half of the derivations and automatically generate the opposite versions using CompilerForCAP and the current infrastructure.

Background: I have written code to derive finite limits from products and binary equalizers and I would like to generate the code for colimits automatically. The current code for finite colimits calls the category constructor Opposite inside the derivations which is a hack.

mohamed-barakat avatar Sep 30 '22 09:09 mohamed-barakat

As far as I can tell, nothing significant is blocking this, see https://github.com/zickgraf/CAP_project/tree/opposite_derivations for a demo. One has to:

  1. Make Opposite applicable twice (see the commented line on the above branch, something similar has to be done for objects and morphisms and put behind a switch).
  2. Write a wrapper CategoryAsOppositeOfOppositeOfCategory.
  3. For each derivation: Create a dummy category with the opposite requirements, apply CategoryAsOppositeOfOppositeOfCategory, compile the opposite operation.
  4. Write the result as a derivation for the opposite operation to a file.

zickgraf avatar Sep 30 '22 13:09 zickgraf

This would also fix #917.

zickgraf avatar Sep 30 '22 13:09 zickgraf

For CAP this is done in https://github.com/homalg-project/CAP_project/pull/1468. The system could easily be extended to more cases (e.g. include derivations including multiple categories), final derivations, and other packages.

zickgraf avatar Sep 25 '23 14:09 zickgraf

Excellent.

mohamed-barakat avatar Sep 25 '23 15:09 mohamed-barakat