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

Clever scheduling needed in absence of ACC? #9

Open
nomeata opened this issue Oct 5, 2022 · 0 comments
Open

Clever scheduling needed in absence of ACC? #9

nomeata opened this issue Oct 5, 2022 · 0 comments

Comments

@nomeata
Copy link
Owner

nomeata commented Oct 5, 2022

I’m worrying if rec-def may be unpure in the presence of infinite chains, i.e. when the Ascending Chain Condition does not hold.

Consider the type Maybe Natural, ordered by Just 0 ⊑ Just 1 ⊑ … ⊑ Nothing. The following operations are monotone and continuous:

max :: Maybe Natural -> Maybe Natural -> Maybe Natural
max Nothing _ = Nothing
max _ Nothing = Nothing
max (Just n1) (Just n2) = Just (max n1 n2)

succ :: Maybe Natural -> Maybe Natural
succ Nothing = Nothing
succ (Just n) = Just (succ n)

Now consider these these recursive equations:

n, m :: Maybe Natural
n = max (succ n) m
m = Nothing

a naive fix-pointing algorithm might initialize n and m to the bottom element Just 0, then keep updating n with max (succ n) m forever, without ever setting m to Nothing.

Or it might set m to Nothing eventually, which turns n to Nothing, and finds the fixed point.

So if the “Ascending Chain Condition” does not hold for all involved types, it seems that purity is non-trivial.

Would some form of “fair scheduling” fix this, and is that easily implementable?

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

1 participant