Repository navigation
Closed
Labels
type: enhancementIssues and pull requests about possible improvements
Description
What's the problem? Cut-and-pasted program examples are preferred over
attachments (if reasonably short).
I prove an existential Theorem, and then define
program₁ : ₂ℕ → ℕ → ₂
program₁ α m = ∃-witness(Theorem α m)
program₂ : ₂ℕ → (m : ℕ) → (smaller(m + 1) → ℕ)
program₂ α m = ∃-witness(∃-elim (Theorem α m))
This makes Agda compilation run for some time until the heap is exhausted.
Now I instead define the two programs by pattern matching rather than
the destructors ∃-witness and ∃-elim (first and second projection):
program₁ : ₂ℕ → ℕ → ₂
program₁ α m = f(Theorem α m)
where
f : Finite-Pigeonhole α m → ₂
f(∃-intro b proof) = b -- f is ∃-witness!!!
program₂ : ₂ℕ → (m : ℕ) → (smaller(m + 1) → ℕ)
program₂ α m = f(Theorem α m)
where
f : Finite-Pigeonhole α m → (smaller(m + 1) → ℕ)
f(∃-intro b (∃-intro s proof)) = s -- f is ∃-witness o ∃-elim!!!
Compilation is instanteneous and succeeds using neglegible memory.
What is going on?
This is how I defined ∃-witness and ∃-elim:
data ∃ {X : Set} (A : X → Ω) : Ω where
∃-intro : (x₀ : X) → A x₀ → ∃ \(x : X) → A x
∃-witness : {X : Set} {A : X → Ω} → (∃ \(x : X) → A x) → X
∃-witness (∃-intro x a) = x
∃-elim : {X : Set} {A : X → Ω} →
(proof : ∃ \(x : X) → A x) → A (∃-witness proof)
∃-elim (∃-intro x a) = a
That is, using the same kind of pattern matching!!!
I can't make the example small - sorry.
The attached program ProgramsWithoutSpecificationBis.agda doesn't compile, but
the one called ProgramsWithoutSpecificationBis.agda.
You will notice that some modules disable the termination checker: this is not
the problem; if we replace the offending recursive definitions by postulates,
and enables termination checking, all modules compile except again
ProgramsWithoutSpecificationBis.agda.
This issue is not urgent for me, because now I am instead using pigon-program
that compiles and is better (and this is how I ended up discovering by accident
the "correction" ProgramsWithoutSpecificationBis.agda.
But still I think there is a problem with the system.
What version of Agda are you using? On what operating system (if relevant)?
Agda version 2.2.6
Best wishes,
Martin
Original issue reported on code.google.com by [email protected] on 19 May 2011 at 8:45
Attachments:
Metadata
Metadata
Assignees
Labels
type: enhancementIssues and pull requests about possible improvements
Activity