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

strict positivity check #319

Closed
aa755msr opened this issue Aug 18, 2015 · 6 comments
Closed

strict positivity check #319

aa755msr opened this issue Aug 18, 2015 · 6 comments

Comments

@aa755msr
Copy link
Contributor

type negativeFunctor : Type -> Type
//type negativeFunctor (a:Type) = a -> Tot nat

type bad =
|Bad : (negativeFunctor bad) -> bad

Abstract functors should not be presumed to be positive. One can provide a negative implementation and violate termination guarantees.

@nikswamy
Copy link
Collaborator

nikswamy commented Aug 20, 2015

Known issue. See the discussion on polarities on other threads. (#65)

@s-zanella
Copy link
Contributor

I think implementing the strict positivity check in universes should be given a higher priority now that it's the default.

This verifies without any warning:

module Bug319

type t =
  | T: f:(t -> Tot False) -> t

let delta = T (fun x -> x.f x)

let omega: False = delta.f delta

val bug: unit -> Lemma False
let bug _ = ()

@aseemr
Copy link
Collaborator

aseemr commented Jul 1, 2016

@s-zanella , @nikswamy and I have talked about this. The implementation would be very similar to that of the hasEq check. The week after next I will work with @nikswamy to iron out the issues with hasEq, and then hopefully get to positivity.

@s-zanella
Copy link
Contributor

Thanks, nice to hear you're working on it!

@nikswamy
Copy link
Collaborator

nikswamy commented Jul 3, 2016

I could probably implement a simplified, conservative version of the check very quickly, and then we'll get a better check from Aseem later.

There used to be a warning about the missing check ... but it was really noisy since it would complain on every data type definition (rightfully so).

Anyway, I agree with the priority 1.

@aseemr
Copy link
Collaborator

aseemr commented Feb 1, 2017

Positivity check is in the master branch now. @s-zanella's example above gives an error: (Error) Inductive type Test.t does not satisfy the positivity condition, closing the issue.

@aseemr aseemr closed this as completed Feb 1, 2017
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

6 participants