File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed
doc/changelog/11-standard-library Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change 1+ - **Changed: **
2+ implementation of :g: `Vector.nth ` to follow OCaml and compute strict subterms
3+ (`#16731 <https://github.com/coq/coq/pull/16731 >`_,
4+ fixes `#16738 <https://github.com/coq/coq/issues/16738 >`_,
5+ by Andrej Dudenhefner).
Original file line number Diff line number Diff line change 1+ Require Vector.
2+
3+ Inductive container : Type :=
4+ | container_v : Vector.t container 2 -> container
5+ | container_0 : container.
6+
7+ Fixpoint test (c : container) : unit :=
8+ match c with
9+ | container_0 => tt
10+ | container_v v => test (Vector.nth v (Fin.FS Fin.F1))
11+ end .
Original file line number Diff line number Diff line change @@ -106,12 +106,15 @@ Definition const {A} (a:A) := nat_rect _ [] (fun n x => cons _ a n x).
106106Computational behavior of this function should be the same as
107107ocaml function. *)
108108Definition nth {A} :=
109- fix nth_fix {m} (v' : t A m) (p : Fin.t m) {struct v'} : A :=
110- match p in Fin.t m' return t A m' -> A with
111- |Fin.F1 => caseS (fun n v' => A) (fun h n t => h)
112- |Fin.FS p' => fun v => (caseS (fun n v' => Fin.t n -> A)
113- (fun h n t p0 => nth_fix t p0) v) p'
114- end v'.
109+ fix nth_fix {n : nat} (v : t A n) {struct v} : Fin.t n -> A :=
110+ match v with
111+ | nil _ => fun p => False_rect A (Fin.case0 _ p)
112+ | cons _ x m v' => fun p =>
113+ match p in (Fin.t m') return t A (pred m') -> A with
114+ | Fin.F1 => fun _ => x
115+ | Fin.FS p' => fun v' => nth_fix v' p'
116+ end v'
117+ end .
115118
116119(** An equivalent definition of [nth]. *)
117120Definition nth_order {A} {n} (v: t A n) {p} (H: p < n) :=
You can’t perform that action at this time.
0 commit comments