Cannot pattern match on exist in program definitions

Aperta
#24 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Ambito
compilers

Direzione di ricerca

Riproduci l'esempio fornito di Coq 8.13.2 e confronta i pattern match sig che falliscono con le versioni sigT e Ssig funzionanti. Leggi le issue correlate coq/coq#4341 e coq/coq#10877; il lavoro è considerato completato quando i pattern match sig funzionano in entrambe le Program Definitions mostrate senza gli errori segnalati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

Coq 8.13.2

Operating system

Red Hat Enterprise Linux Workstation 7.4

Description of the problem

It is not possible to pattern match on terms
belonging to the sig type family in the following Program Definitions,
because the witnesses seem to get projected out by some hidden coercion.
However, changing sig into sigT or Ssig will allow
implementing the inspect pattern just fine.

From Coq Require Import Lia Logic.StrictProp NArith.NArith.

Obligation Tactic := idtac.

Section Context.

Import N.

Local Open Scope N_scope.

Context (f : N -> N) (mono : forall (a b : N) (l : a < b), f a < f b).

Print Coercions.

Fail Program Definition f_inspect (n : N) : positive :=
  let m := f (succ n) - f n in
  match exist _ m (eq_refl m) with
  | exist _ N0 e => _
  | exist _ (Npos p) e => p
  end.

Fail Program Definition f_inspect (n : N) : positive :=
  let m := f (succ n) - f n in
  match exist _ m (eq_refl m) in sig _ return positive with
  | exist _ N0 e => _
  | exist _ (Npos p) e => p
  end.

Program Definition f_inspect (n : N) : positive :=
  let m := f (succ n) - f n in
  match existT _ m (eq_refl m) in sigT _ return positive with
  | existT _ N0 e => _
  | existT _ (Npos p) e => p
  end.
Next Obligation. intros n m _ _ e. pose proof mono n (succ n) as l. lia. Qed.

Program Definition f_inspect' (n : N) : positive :=
  let m := f (succ n) - f n in
  match Sexists (fun n : N => Squash (m = n)) m (squash (eq_refl m)) in
  Ssig _ return positive with
  | Sexists _ N0 e => _
  | Sexists _ (Npos p) e => p
  end.
Next Obligation.
  intros n m _ _ e'.
  exfalso. apply sEmpty_ind. induction e' as [e].
  pose proof mono n (succ n) as l. lia. Qed.

End Context.
The command has indeed failed with message:
Found a constructor of inductive type sig while a constructor of N is expected.
The command has indeed failed with message:
Wrong inductive type.
Notes

This may be related to coq/coq#4341 or coq/coq#10877.

Lingua principale
Rocq Prover
Stelle
46
Fork
39
Merge medio
4g 12h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rocq-prover/stdlib

Tutte le issue di rocq-prover/stdlib

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.