Skip to content

Conversation

andreasabel
Copy link
Member

Closes #7669.

@andreasabel andreasabel added positivity Positivity checking for data-type definitions missing reduce An error caused by a term not being in weak head normal form (typically, forgotten call to reduce). labels Jan 3, 2025
@andreasabel andreasabel added this to the 2.8.0 milestone Jan 3, 2025
@andreasabel
Copy link
Member Author

The change here improves polarity inference, which seems to make solutions of unification problems less unique.
https://github.com/agda/agda-stdlib/blob/d85cd7e5cc9d990c103be625e52331b6e7f125b9/src/Algebra/Construct/Initial.agda#L78
https://github.com/agda/agda/actions/runs/12603074122/job/35127852387?pr=7674#step:8:158

Unsolved metas at the following locations:
/home/runner/work/agda/agda/std-lib/src/Algebra/Construct/Initial.agda:78.17-32
/home/runner/work/agda/agda/std-lib/src/Algebra/Construct/Initial.agda:81.61-67

@szumixie
Copy link
Member

szumixie commented Jan 3, 2025

Here's a minimized example for the difference in unification behavior:

data Unit : Set where
  tt : Unit

postulate
  A B : Set

FUN : Set₁
FUN = Set  Set

ConstA : Unit  FUN
ConstA tt _ = A

postulate
  x : Unit
  f : (Z : Set)  ConstA x Z

a : ConstA x B
a = f _

With the old behavior, the code above typechecks even though the hole in a can be solved with any type, inlining FUN in the type of ConstA results in an unsolved meta. With the new behavior, it always results in an unsolved meta.

@andreasabel andreasabel marked this pull request as draft January 7, 2025 17:25
@nad
Copy link
Contributor

nad commented Jan 10, 2025

With the old behavior, the code above typechecks even though the hole in a can be solved with any type

That sounds like a bug to me.

@szumixie
Copy link
Member

Yes it is a bug, the new behavior is the correct one. With the old behavior, the positivity checker fails to infer that the second argument of ConstA is nonvariant, which causes the unifier to treat it as definitionally injective in that argument.

andreasabel added a commit to agda/agda-stdlib that referenced this pull request Jan 13, 2025
Agda PR #7674 requires some implicit arguments explicitly in some record
expression given since variance info got refined (invariant to
non-variant) and hence solutions are no longer unique.
@andreasabel
Copy link
Member Author

@andreasabel andreasabel added the type: bug Issues and pull requests about actual bugs label Jan 13, 2025
@andreasabel andreasabel self-assigned this Jan 13, 2025
@andreasabel andreasabel marked this pull request as ready for review January 13, 2025 08:39
@andreasabel andreasabel added the pr: squash-me This PR needs squashing label Jan 13, 2025
@andreasabel andreasabel merged commit 7e3f81a into master Jan 13, 2025
27 checks passed
@andreasabel andreasabel deleted the get-arity-def branch January 13, 2025 10:03
andreasabel added a commit to agda/agda-stdlib that referenced this pull request Mar 15, 2025
Agda PR #7674 requires some implicit arguments explicitly in some record
expression given since variance info got refined (invariant to
non-variant) and hence solutions are no longer unique.
andreasabel added a commit to agda/agda-stdlib that referenced this pull request May 9, 2025
Agda PR #7674 requires some implicit arguments explicitly in some record
expression given since variance info got refined (invariant to
non-variant) and hence solutions are no longer unique.
andreasabel added a commit to agda/agda-stdlib that referenced this pull request Jun 28, 2025
Agda PR #7674 requires some implicit arguments explicitly in some record
expression given since variance info got refined (invariant to
non-variant) and hence solutions are no longer unique.
github-merge-queue bot pushed a commit to agda/agda-stdlib that referenced this pull request Jun 30, 2025
* agda/agda#7674 eta-expand fields in record expression

Agda PR #7674 requires some implicit arguments explicitly in some record
expression given since variance info got refined (invariant to
non-variant) and hence solutions are no longer unique.

* Workaround for Agda 2.7.0 (and lower, I suppose)

* Correct option --warn to --warning for agda/agda#7966

The official name of the option is `--warning` and the prefix `--warn` is only
accepted because we have no options like `--warner` or
`--warner-brothers-owns-us`, but we might have so in the future.

* Update README and CI for v2.8.0-rc3

---------

Co-authored-by: Andreas Abel <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing reduce An error caused by a term not being in weak head normal form (typically, forgotten call to reduce). positivity Positivity checking for data-type definitions pr: squash-me This PR needs squashing type: bug Issues and pull requests about actual bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Positivity checker doesn't respect definitional equality
3 participants