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

Translated data types violate Coq's strict positivity restriction #155

Open
MajaRet opened this issue Jul 27, 2020 · 0 comments
Open

Translated data types violate Coq's strict positivity restriction #155

MajaRet opened this issue Jul 27, 2020 · 0 comments
Labels
bug Something isn't working Coq Related to Coq back end or base library

Comments

@MajaRet
Copy link
Contributor

MajaRet commented Jul 27, 2020

Description

Some data types are translated into Coq data types that violate the strict positivity restriction. As a result, the generated Coq code cannot be compiled.

Steps to Reproduce

Translate the following Haskell program with the Free compiler.

data NSP a = Val a | Stack (NSP (NSP a))

Expected Behavior

The compiler should throw an error when it encounters a Haskell data type whose translation would violate the strict positivity restriction.

Actual Behavior

No error is thrown. Translating this program leads to the following data type definition in Coq.

Inductive NSP (Shape : Type) (Pos : Shape -> Type) (a : Type) : Type
  := val : Free Shape Pos a -> NSP Shape Pos a
  |  stack : Free Shape Pos (NSP Shape Pos (NSP Shape Pos a)) -> NSP Shape Pos a.

This definition causes the following error.

Non strictly positive occurrence of 
"NSP" in
 "Free Shape Pos (NSP Shape Pos (NSP Shape Pos a)) ->
  NSP Shape Pos a".

Versions

  • Git commit: 8779013877645b9547bb36c93fa1df9856b2b1aa
  • ghc --version: 8.6.5
  • cabal --version: 3.2.0.0
  • coqc --version: 8.11.0
  • OS: Ubuntu 19.10

ToDo

Implement an analysis that checks whether a data type's translation would violate the strict positivity restriction and throw an error if this is the case.

@MajaRet MajaRet added bug Something isn't working Coq Related to Coq back end or base library labels Jul 27, 2020
@MajaRet MajaRet changed the title Translation of certain data types violates Coq's strict positivity restriction Translated data types violate Coq's strict positivity restriction Jul 27, 2020
@maclement maclement assigned maclement and unassigned maclement Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Coq Related to Coq back end or base library
Projects
None yet
Development

No branches or pull requests

2 participants