Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifications #4

Open
zickgraf opened this issue Aug 15, 2020 · 6 comments
Open

Specifications #4

zickgraf opened this issue Aug 15, 2020 · 6 comments

Comments

@zickgraf
Copy link
Member

I wonder which of the following specifications should hold true for a category C and L := LazyCategory( C ):

  1. IsEqualForObjects( DirectProduct( a / L, b / L ), DirectProduct( a, b ) / L ) for all objects a and b in C (of course, DirectProduct is just an example)
  2. IsEqualForObjects( Source( morphism ), Source( EvaluatedCell( morphism ) ) / L ) for all morphisms morphism in L.
  3. IsEqualForObjects( EvaluatedCell( Source( morphism ) ), Source( EvaluatedCell( morphism ) ) for all morphisms morphism in L.

From looking at the code I assume that 1. and 2. should not hold true, but I expect that 3. should be true.

@zickgraf
Copy link
Member Author

I extend my question further:
4. IsEqualForObjects( EvaluatedCell( DirectProduct( a / L, b / L ) ), DirectProduct( a, b ) ) for all objects a and b in C

This is probably the most important one: if it should hold true it restricts the possible optimizations which we are allowed to make in L (e.g. the current optimization for FiberProduct would be invalid). If it need not hold true, it means that we cannot mix computations made with LazyCategories and computations made without LazyCategories.

@mohamed-barakat
Copy link
Member

The answers are (generically): 1. false, 2. false, 3. true, 4. true

@mohamed-barakat
Copy link
Member

I do not see the significance of 4. as IsEqualForObjects is called in the category underlying the lazy category.

@zickgraf
Copy link
Member Author

Thanks for the quick response! Consider the following example (where I have replace DirectProduct by FiberProduct):

LoadPackage( "LazyCategories" );
LoadPackage( "FinSetsForCAP" );
M := FinSet( [ 1, 2 ] );
id := IdentityMorphism( M );
phi := MapOfFinSets( M, [ [ 1, 1 ], [ 2, 1 ] ], M );
L := LazyCategory( FinSets : show_evaluation := true );

IsEqualForObjects( EvaluatedCell( FiberProduct( phi / L, id / L ) ), FiberProduct( phi, id ) );

where the last line yields false, since the object in the lazy category has changed due to the optimization.

@mohamed-barakat
Copy link
Member

Why is this bad?

@zickgraf
Copy link
Member Author

It's not necessarily bad. It's unexpected if one thinks of LazyCategories as a completely transparent wrapper (in the sense that once I evaluate I get exactly the same result as if I had never lazified anything), that's why I asked for the specification.

If LazyCategories is not a completely transparent wrapper, you cannot mix computations from the lazy and the non-lazy world. And if such optimizations would be part of CompilerForCAP, there would be some additional implications:

  1. Compiled and non-compiled code might produce different results.
  2. If the compiler is enabled, every piece of code has to go through the compiler, even the code the user types in the command line.
  3. If the compiler misses an optimization (for example because it is hidden in some user-provided function which is not resolved, or because there is some complicated for-loop the compiler cannot handle) it produces wrong results.
  4. The compiler implicitly changes the notion of equality (e.g. it would distinguish between a morphism given by IdentityMorphism and a morphism which happens to be the identity by chance, exactly like LazyCategories does). And this changed notion of equality might not be apparent in the compiled code anymore.

Again, this is not necessarily bad, I'm just trying and to understand and write down my thoughts about the implications :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants