aboutsummaryrefslogtreecommitdiff
path: root/test-suite
diff options
context:
space:
mode:
authorMatthieu Sozeau2018-06-19 12:09:58 +0100
committerMatthieu Sozeau2018-10-08 15:44:15 +0200
commitb977afefc8038f556e04930bcbceb4422b7d1062 (patch)
treee1efade544697a4dfb4fdcc81a45873d7d93e177 /test-suite
parent9a1cbeb18e10e7eb40363e648e15f4f9aae1f9b8 (diff)
Fix #5197, handling of algebraic universes
They were allowed to stay in terms in some cases. We now ensure that if an evar is defined as e.g. fun x => Type@{foo}, foo is properly refreshed to be non-algebraic as it could otherwise appear in the term and break the invariant. Also cleanup the implementation of refresh_universes to avoid using a mutable reference and simply rely on the Constr.map smartmap idiom instead. This might have compatibility issues, e.g. in HoTT where maybe more non-algebraic proxy universes could be generated, we'll see. For the bug report proper, there is a lack of bidirectional type-checking that makes the initial definition fail (there's a non-canonical choice of dependency if we don't consider the typing constraint). With the Program bidir hint it passes.
Diffstat (limited to 'test-suite')
-rw-r--r--test-suite/bugs/closed/5197.v44
1 files changed, 44 insertions, 0 deletions
diff --git a/test-suite/bugs/closed/5197.v b/test-suite/bugs/closed/5197.v
new file mode 100644
index 0000000000..b67e93d677
--- /dev/null
+++ b/test-suite/bugs/closed/5197.v
@@ -0,0 +1,44 @@
+Set Universe Polymorphism.
+Set Primitive Projections.
+Unset Printing Primitive Projection Compatibility.
+Axiom Ω : Type.
+
+Record Pack (A : Ω -> Type) (Aᴿ : Ω -> (forall ω : Ω, A ω) -> Type) := mkPack {
+ elt : forall ω, A ω;
+ prp : forall ω, Aᴿ ω elt;
+}.
+
+Record TYPE := mkTYPE {
+ wit : Ω -> Type;
+ rel : Ω -> (forall ω : Ω, wit ω) -> Type;
+}.
+
+Definition El (A : TYPE) : Type := Pack A.(wit) A.(rel).
+
+Definition Typeᶠ : TYPE := {|
+ wit := fun _ => Type;
+ rel := fun _ A => (forall ω : Ω, A ω) -> Type;
+ |}.
+Set Printing Universes.
+Fail Definition Typeᵇ : El Typeᶠ :=
+ mkPack _ _ (fun w => Type) (fun w A => (forall ω, A ω) -> Type).
+
+Definition Typeᵇ : El Typeᶠ :=
+ mkPack _ (fun _ (A : Ω -> Type) => (forall ω : Ω, A ω) -> _) (fun w => Type) (fun w A => (forall ω, A ω) -> Type).
+
+(** Bidirectional typechecking helps here *)
+Require Import Program.Tactics.
+Program Definition progTypeᵇ : El Typeᶠ :=
+ mkPack _ _ (fun w => Type) (fun w A => (forall ω, A ω) -> Type).
+
+(**
+The command has indeed failed with message:
+Error: Conversion test raised an anomaly
+**)
+
+Definition Typeᵇ' : El Typeᶠ.
+Proof.
+unshelve refine (mkPack _ _ _ _).
++ refine (fun _ => Type).
++ simpl. refine (fun _ A => (forall ω, A ω) -> Type).
+Defined.