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

Constraint solving in heterogenous situations #470

Closed
GoogleCodeExporter opened this issue Aug 8, 2015 · 8 comments
Closed

Constraint solving in heterogenous situations #470

GoogleCodeExporter opened this issue Aug 8, 2015 · 8 comments
Assignees
Labels
constraints Constraints (postponed type checking problems, postponed unification problems, instance constraints) meta Metavariables, insertion of implicit arguments, etc status: info-needed More information is needed from the bug reporter to confirm the issue. type: enhancement Issues and pull requests about possible improvements
Milestone

Comments

@GoogleCodeExporter
Copy link

GoogleCodeExporter commented Aug 8, 2015

module Solve where

data Bool : Set where
  true false : Bool

_and_ : Bool  Bool  Bool
true  and x = x
false and x = false

infixr 5 _∷_

data Foo : Bool  Set where
  []  : Foo true
  _∷_ :  {b} (x : Bool)  Foo b  Foo (x and b)

Baz : Bool  Set
Baz true = Bool
Baz false = Foo false

data Bar :  {b}  Foo b  Set where
  []  : Bar []
  _∷_ :  {b} {foo : Foo b} {x} (g : Baz x)  (bar : Bar foo)  Bar (x ∷ foo)

foo : Foo false
foo = false ∷ true ∷ []

bar : Bar foo
bar = (false ∷ []) ∷ false ∷ [] -- ← is yellow

{-
_59 := _55 ∷ false ∷ [] [blocked by problem 75]
[75] ["apply" (_53 ∷ true ∷ [])] == ["apply" (false ∷ true ∷ [])] : Foo 
(_53 and (true and true)) → Set [blocked by problem 76]
[76] (_53 and (true and true)) = false : Bool
_54 := false ∷ [] :? Baz _53
-}

Here, the solver's equation 75 is blocked by 76, but 76 can't be solved in isolation, so things turn yellow. However, if the solver ignored 76 and unified _53 with false, then it could solve 76. Ulf and I spoke about it on
IRC and he said it might be possible to have the solver first check that the "shape" of things being unified in 75 could be checked to make sure the unification makes sense, then they could be unified, then 76 could be attempted.

Original issue reported on code.google.com by pumpkingod@gmail.com on 22 Sep 2011 at 3:33

@GoogleCodeExporter GoogleCodeExporter added auto-migrated type: enhancement Issues and pull requests about possible improvements meta Metavariables, insertion of implicit arguments, etc labels Aug 8, 2015
@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 8, 2015

What's needed here is the heterogenous shape machinery we just implemented for unification.

Original comment by ulf.nor...@gmail.com on 22 Sep 2011 at 6:02

  • Changed title: Constraint solving in heterogenous situations
  • Changed state: Accepted
  • Added labels: Priority-Medium, Type-Enhancement

@GoogleCodeExporter
Copy link
Author

Original comment by andreas....@gmail.com on 22 Sep 2011 at 9:42

  • Added labels: Meta

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 8, 2015

Has this been implemented? The code typechecks with no unsolved metas on the dev. version of Agda.

Original comment by sanzhi...@gmail.com on 26 Jan 2015 at 4:12

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 8, 2015

No, this has not been implemented. However, the occurs check was strengthened. Also, this might be working due to bug #1258.

Original comment by andreas....@gmail.com on 26 Jan 2015 at 4:49

@GoogleCodeExporter
Copy link
Author

GoogleCodeExporter commented Aug 8, 2015

This is a better test case then:

module Solve where

data _≡_ {a} {A : Set a} (x : A) : A  Set a where
  refl : x ≡ x

data Bool : Set where
  true false : Bool

_and_ : Bool  Bool  Bool
true  and x = x
false and x = false

infixr 5 _∷_

data Foo : Bool  Set where
  []  : Foo true
  _∷_ :  {b} (x : Bool)  Foo b  Foo (x and b)

foo : let C = _ in (C ∷ []) ≡ (false ∷ [])
foo = refl

Original comment by sanzhi...@gmail.com on 27 Jan 2015 at 9:43

@andreasabel
Copy link
Member

For the new example I get:

_25 : Bool 
_30 : Foo (_25 and true) 

Failed to solve the following constraints:
  _30 := false ∷ [] [blocked on problem 32]
  [32, 33] false = _25 and true : Bool

Could the proposal be fleshed out to see what it takes to implement this?

@andreasabel andreasabel added constraints Constraints (postponed type checking problems, postponed unification problems, instance constraints) status: info-needed More information is needed from the bug reporter to confirm the issue. and removed auto-migrated labels Jul 28, 2017
@UlfNorell UlfNorell added this to the icebox milestone May 24, 2018
@Saizan Saizan removed their assignment Nov 27, 2018
@vlopezj
Copy link
Contributor

vlopezj commented Sep 16, 2019

The test case given in #470 (comment) seems to type-check at least since commit ba4354f.

@vlopezj vlopezj closed this as completed Sep 16, 2019
@gallais
Copy link
Member

gallais commented Sep 16, 2019

Can you please add it to the test suite?

@gallais gallais reopened this Sep 16, 2019
vlopezj added a commit that referenced this issue Sep 17, 2019
@vlopezj vlopezj closed this as completed Sep 17, 2019
@asr asr modified the milestones: icebox, 2.6.1 Sep 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
constraints Constraints (postponed type checking problems, postponed unification problems, instance constraints) meta Metavariables, insertion of implicit arguments, etc status: info-needed More information is needed from the bug reporter to confirm the issue. type: enhancement Issues and pull requests about possible improvements
Projects
None yet
Development

No branches or pull requests

7 participants