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

Rewrite rules with non-linear patterns do not work in presence of Prop #3525

Closed
jespercockx opened this issue Jan 28, 2019 · 4 comments
Closed
Assignees
Labels
prop Prop, definitional proof irrelevance rewriting Rewrite rules, rewrite rule matching type: bug Issues and pull requests about actual bugs
Milestone

Comments

@jespercockx
Copy link
Member

Reported by Simon Boulier:

{-# OPTIONS --prop --rewriting #-}

open import Agda.Builtin.Nat
open import Agda.Builtin.Equality

{-# BUILTIN REWRITE _≡_ #-}

data _≐_ {ℓ} {A : Set ℓ} (x : A) : A  Propwhere
  refl : x ≐ x

postulate
  subst :  {ℓ ℓ′} {A : Set ℓ} (P : A  Set ℓ′)
         (x y : A)  x ≐ y  P x  P y
  subst-rew :  {ℓ ℓ′} {A : Set ℓ} (P : A  Set ℓ′)
             {x : A} (e : x ≐ x) (p : P x)  subst P x x e p ≡ p
{-# REWRITE subst-rew #-}

data Box (A : Prop) : Set where
  box : A -> Box A

foo : (A : Prop)(x y : A)(P : Box A  Set)(p : P (box x))  subst P (box x) (box y) refl p ≐ p
foo A x y P p = refl -- refl does not type check

The problem is that the rewriting implementation uses untyped equality for checking the non-linear parts of patterns, which doesn't do the right thing in the presence of Prop's.

@jespercockx jespercockx added type: bug Issues and pull requests about actual bugs rewriting Rewrite rules, rewrite rule matching prop Prop, definitional proof irrelevance labels Jan 28, 2019
@jespercockx jespercockx self-assigned this Jan 28, 2019
@jespercockx jespercockx added this to the 2.6.1 milestone Feb 11, 2019
@jespercockx
Copy link
Member Author

I'm working on a fix, but it won't be ready for 2.6.0 since it required a lot of refactoring of the conversion checker.

jespercockx added a commit to jespercockx/agda that referenced this issue Mar 16, 2019
@jespercockx
Copy link
Member Author

I finished my fix and pushed it to my fork of Agda (https://github.com/jespercockx/agda/tree/MonadConversion). However, the fix depends on #3589 which still needs some work, so the fix will have to wait a bit before it gets into master.

@SimonBoulier
Copy link
Contributor

Wow, great!
I will test it when I have a bit of time.

jespercockx added a commit to jespercockx/agda that referenced this issue Apr 18, 2019
jespercockx added a commit to jespercockx/agda that referenced this issue Apr 18, 2019
jespercockx added a commit to jespercockx/agda that referenced this issue Apr 18, 2019
@rwe rwe closed this as completed in 70236aa May 7, 2019
@SimonBoulier
Copy link
Contributor

It works well, thank you :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prop Prop, definitional proof irrelevance rewriting Rewrite rules, rewrite rule matching type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

No branches or pull requests

2 participants