Skip to content

Commit

Permalink
Merge PR coq#9032: checker: check inductive types by roundtrip throug…
Browse files Browse the repository at this point in the history
…h the kernel.
  • Loading branch information
ppedrot committed Dec 13, 2018
2 parents caa4a00 + 0f3c1f2 commit 228f0d9
Show file tree
Hide file tree
Showing 7 changed files with 171 additions and 245 deletions.
377 changes: 134 additions & 243 deletions checker/checkInductive.ml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions checker/checkInductive.mli
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
(* * (see LICENSE file for the text of the license) *)
(************************************************************************)

(*i*)
open Names
open Environ
(*i*)

exception InductiveMismatch of MutInd.t * string
(** Some field of the inductive is different from what the kernel infers. *)

(*s The following function does checks on inductive declarations. *)

Expand Down
4 changes: 4 additions & 0 deletions checker/checker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ let explain_exn = function
(* let ctx = Check.get_env() in
hov 0
(str "Error:" ++ spc () ++ Himsg.explain_inductive_error ctx e)*)

| CheckInductive.InductiveMismatch (mind,field) ->
hov 0 (MutInd.print mind ++ str ": field " ++ str field ++ str " is incorrect.")

| Assert_failure (s,b,e) ->
hov 0 (anomaly_string () ++ str "assert failure" ++ spc () ++
(if s = "" then mt ()
Expand Down
2 changes: 2 additions & 0 deletions kernel/univ.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,8 @@ module ACumulativityInfo =
struct
type t = AUContext.t * Variance.t array

let repr (auctx,var) = AUContext.repr auctx, var

let pr prl (univs, variance) =
AUContext.pr prl ~variance univs

Expand Down
1 change: 1 addition & 0 deletions kernel/univ.mli
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ module ACumulativityInfo :
sig
type t

val repr : t -> CumulativityInfo.t
val univ_context : t -> AUContext.t
val variance : t -> Variance.t array
val leq_constraints : t -> Instance.t constraint_function
Expand Down
16 changes: 16 additions & 0 deletions test-suite/coqchk/inductive_functor_params.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Module Type T.
Parameter foo : nat -> nat.
End T.

Module F (A:T).
Inductive ind (n:nat) : nat -> Prop :=
| C : (forall x, x < n -> ind (A.foo n) x) -> ind n n.
End F.

Module A. Definition foo (n:nat) := n. End A.

Module M := F A.
(* Note: M.ind could be seen as having 1 recursively uniform
parameter, but module substitution does not recognize it, so it is
treated as a non-uniform parameter. *)
11 changes: 11 additions & 0 deletions test-suite/coqchk/inductive_functor_template.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

Module Type E. Parameter T : Type. End E.

Module F (X:E).
#[universes(template)] Inductive foo := box : X.T -> foo.
End F.

Module ME. Definition T := nat. End ME.
Module A := F ME.
(* Note: A.foo could live in Set, and coqchk sees that (because of
template polymorphism implementation details) *)

0 comments on commit 228f0d9

Please sign in to comment.