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

Monotonic/Crease-handling #126

Open
pjonsson opened this issue Jun 23, 2014 · 2 comments
Open

Monotonic/Crease-handling #126

pjonsson opened this issue Jun 23, 2014 · 2 comments

Comments

@pjonsson
Copy link
Member

cc @emwap @emilaxelsson

The history of this ticket is that #38 exposed some expressions that should be optimized, for example min var3 (var3 >> 1). That optimization was checked in with the class Monotonic. Commit a23d9a1 renamed Monotonic to Crease, but that is not a great name. The optimization rule before that commit reads:

 constructFeatOpt _ (C' Min) (a :* b :* Nil)
        | as <- viewMonotonicDec a
        , any (alphaEq b) as = return a

I am convinced about the correctness of the optimization suggested in #38. Revisiting this generalization makes me a bit worried that the API is suggestive for making incorrect rewrite rules that will show upp in transitive uses, but I don't have a counter example at hand. I will try to construct a counter example this week.

The second issue is the name of the class. Aren't we really trying to Ord functions and their output?

f x < x
pjonsson referenced this issue Jun 25, 2014
"Monotonic" is not the right term, but I don't know what the proper term is.
"Increasing"/"decreasing" seems to mean the same as "monotonic", so I chose
"increases"/"decreases" to mean that the function *-creases an argument.
@pjonsson
Copy link
Member Author

The last comment by @josefs identifies the property as inflationary, and the opposite is deflationary.

To call the class by a word that exists and means the right thing would be nice. Is it a trend we are trying to describe? We are not trying to calculate fix points, so Flationary that might be overkill for our situation. I'm still curious if ordering functions + their parameters compared to their output is enough for what we are after, in which case a partial Ord might suffice.

@emilaxelsson
Copy link
Member

So you suggest a function

comp :: ASTF ... -> ASTF ... -> CompResult

?

That sounds nice, but one problem with using it in constructFeatOpt above is that we don't have direct access to the whole AST, only the symbol and its children.

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