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

Compile time Nats need to be optimised #1171

Open
UlfNorell opened this issue May 2, 2014 · 2 comments
Open

Compile time Nats need to be optimised #1171

UlfNorell opened this issue May 2, 2014 · 2 comments

Comments

@UlfNorell
Copy link

UlfNorell commented May 2, 2014

Here's half the proof that (==) on nats does the right thing.

eqComplete : (x : Nat) -> (y : Nat) -> so (not (x == y)) -> x = y -> Bool -> _|_
eqComplete Z Z         oh eq   _ impossible
eqComplete Z (S _)     p  refl _ impossible
eqComplete (S _) Z     p  refl _ impossible
eqComplete (S x) (S y) p  eq   True  = eqComplete x y p (sucInj eq) True
eqComplete (S x) (S y) p  eq   False = eqComplete x y p (sucInj eq) False

This takes about 3s:

*slow> eqComplete 1000 1001
eqComplete 1000 1001 : (so True) -> (1000 = 1001) -> Bool -> _|_

This is very strange since eqComplete cannot actually evaluate, as made sured by the spurious Bool argument.

@david-christiansen
Copy link
Contributor

Following discussion on Friday, I'm pretty sure this is due to fromInteger : Integer -> Nat taking time linear to the size of the Nat. Idris also takes quite some time to evaluate the Nat 10000.

Probably the way to fix this is to replace Nats with Integers in the evaluator, but there are some trade-offs regarding complexity of implementation there.

@edwinb edwinb changed the title Mysterious slowness Compile time Nats need to be optimised Oct 19, 2015
@edwinb
Copy link
Contributor

edwinb commented Oct 19, 2015

I've changed the title to reflect the fact that the slowness is no longer mysterious, but we do need to get around to implementing better compile time Nats. I don't like implementing special cases, but as special cases go, this one is particularly special...

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

No branches or pull requests

4 participants