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

Internal-to-Core translation is limited to type-declaring axioms #2763

Closed
jonaprieto opened this issue May 2, 2024 · 3 comments · Fixed by #2768
Closed

Internal-to-Core translation is limited to type-declaring axioms #2763

jonaprieto opened this issue May 2, 2024 · 3 comments · Fixed by #2768

Comments

@jonaprieto
Copy link
Collaborator

It seems that axioms with a type signature of the form

Type -> ... -> Type

are being ignored or missed during the translation from internal to the core.

Consider the program test.juvix

module test;
axiom X : Type;
axiom B : Type -> Type;

type A := mkA {
  a : B X;
};

This program typechecks on previous versions:

juvix-v0.5.5 typecheck test.juvix
Well done! It type checks

However, the compiler spits out the following error with the latest (also with the one from main):

juvix-v0.6.1 typecheck test.juvix
juvix-v0.6.1: internal to core: undeclared identifier: B@architecture-2.engines.test:2
at /Users/jonaprieto/anoma/nspec/docs/architecture-2/engines/test.juvix:20:7-8
Module:
-------

-- Inductives:
type A {
  
};
-- Identifiers:
def X!3@architecture-2.engines.test[0] : Type;

-- Axioms:

-- Context:
def X!3@architecture-2.engines.test[0] : Type := (⊥ : Type);
-- Main:

Imports:
--------

-- Inductives:

-- Identifiers:

-- Axioms:

-- Context:

-- Main:

CallStack (from HasCallStack):
  error, called at src/Juvix/Prelude/Base/Foundation.hs:378:9 in juvix-0.6.1-KU1jCXinzNdHsK6szbkNUt:Juvix.Prelude.Base.Foundation
  error, called at src/Juvix/Compiler/Core/Translation/FromInternal.hs:912:9 in juvix-0.6.1-KU1jCXinzNdHsK6szbkNUt:Juvix.Compiler.Core.Translation.FromInternal

 *  The terminal 
juvix-v0.6.1 dev internal typecheck test.juvix
Well done! It type checks
@jonaprieto jonaprieto added this to the 0.6.2 milestone May 2, 2024
@jonaprieto jonaprieto changed the title Internal-to-Core translation is limited to type-ceclaring axioms Internal-to-Core translation is limited to type-declaring axioms May 2, 2024
@paulcadman
Copy link
Collaborator

git bisect shows that the regression was introduced in #2468

@lukaszcz
Copy link
Collaborator

lukaszcz commented May 6, 2024

The problem is with dependency computation for implicit record projections. This works:

module TypeParamAxiom;

axiom X : Type;
axiom B : Type -> Type;

type A := mkA : B X -> A;

main : Type := B X;

@lukaszcz
Copy link
Collaborator

lukaszcz commented May 7, 2024

lukaszcz added a commit that referenced this issue May 14, 2024
…ter their inductive types (#2768)

* Closes #2763. 
* Fixes a bug in the scoper, likely introduced in
#2468 by making later declarations
depend on earlier ones. The problem was that the inductive modules were
always added at the beginning of a section, which resulted in an
incorrect definition dependency graph (an inductive type depended on its
associated projections).
* Now inductive modules are added just after a group of inductive
definitions, before the next function definition. This implies that
inductive type definitions which depend on each other cannot be
separated by function definitions. Existing Juvix code needs to be
adjusted.
* The behaviour is now equivalent to "manually" inserting module
declarations with projections after each group of inductive definitions.
jonaprieto added a commit that referenced this issue Jun 5, 2024
* Closes #2689 
* Adds the command `juvix isabelle program.juvix` which translates a
given file to an Isabelle/HOL theory.
* Currently, only a single module is translated.
* By default translates types and function signatures. Translating
function signatures can be disabled with the `--only-types` option.

Blocked by:
- #2763

---------

Co-authored-by: Jonathan Cubides <jonathan.cubides@uib.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants