Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Not enough information to resolve this refine goal

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Not enough information to resolve this refine goal


Chronological Thread 
  • From: Maximilian Wuttke <mwuttke97 AT posteo.de>
  • To: coq-club AT inria.fr
  • Subject: Re: [Coq-Club] Not enough information to resolve this refine goal
  • Date: Wed, 30 Sep 2020 22:21:05 +0200
  • Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=mwuttke97 AT posteo.de; spf=Pass smtp.mailfrom=mwuttke97 AT posteo.de; spf=None smtp.helo=postmaster AT mout01.posteo.de
  • Ironport-phdr: 9a23:VARTch0vE+PoTpf4smDT+DRfVm0co7zxezQtwd8ZseITLfad9pjvdHbS+e9qxAeQG9mCtLQf0aGP7/uocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmTiwbal8IRmoogndq8YbjIV/Iast1xXFpWdFdf5Lzm1yP1KTmBj85sa0/JF99ilbpuws+c1dX6jkZqo0VbNXAigoPGAz/83rqALMTRCT6XsGU2UZiQRHDg7Y5xznRJjxsy/6tu1g2CmGOMD9UL45VSi+46ptVRTljjoMOTwk/2HNksF+kbxVoByhqRJ8zYDbbo6aO/hica3SZt4aWWhMU9xNWyBdDI6xbY0CBPcBM+ZCqIn9okMDoxykCgijBePvzz5Ihnv33aIg1eQqDAHJ3BE8H9ISs3Tbssj+OaAXUeG70anI0SnDb/BI1jr56oXFaQghofaXXbJsb8XRzlMjGB7bgViJr4HuIjya2PgXvWeB8+pgSfygi3QhqwxpvzShxskih5XHiIwb113J6Tt1zYgxKNGkR0B1b8CoHZpUuiyYKod6X8MsTm9ntismy7AIt522cDQIxZg6wxPSaPqKeJWG7BLkUeaeOzZ4hHR9dbKwhhay7UigyvDnWcWuzFlKqS9Fn9/RvX4Ozxze8tWLR/h980u72DuC1Rrf5+9FLEwulKfWK4Ytz700m5YJrEjOES77lF/ogKOIakko4PWk5ur7brjgu5SSLZV7ihvkPaQrgsG/Afo3MgwJX2WD/OS806Dj/VHlTLlXlPE2iq7ZsIvGJcsFoa61GRJa3Zg75xa+CTepzsgYkGEaIF9GeB+LlYnkNlPULP32DPqzmVWhnTdzy/DDJLLhA5HNLnbZkLfmeLZw80tcyQQuzdBD+5JUCa8OLfbxV0LqrNzYCQQ5MxCqzObgEtlyy50RVXqVAqCFKKPSrUOI5uU3LuaQY48VoS/xJOQh5/7zlnA0gkQdfKms3ZsPcn+0BPVmI0ODYXrtmNgNC2kKvhBtBNDt3VaFSHtYY2u4d6M6/DAyToy8XqnZQYX4pbWR3SK6GpxfYCh5F0yQEnqgI4CbRusQay/Dfed5lScYWL/nR4J3hkLmjxPz17cydrmcwSYfr5+2jIEptd2Wrgk78HlPN+rYy3uEFjgmhmQTWzIxmqxy8xQkmwWzlJNgivkdLuR9ovZAUwM0L5nZlrUoE9fpRg/GONuEGg//H4eWRAopR9d0+OcgJkZwH9L73kLG2De2W+ZTj7uQGJEztK7RjSD8

Another very convenient way is to define `toList` by well-founded
recursion on the size of the list.

```
Set Implicit Arguments.

Require Import Omega.
From Coq Require Import Lists.List.
Import ListNotations.
From Equations Require Import Equations.

Inductive nonEmpty (A : Type) : Type :=
| singleton : A -> nonEmpty A
| consNE : A -> nonEmpty A -> nonEmpty A.

Section NonEmpty.

Variable A : Type.

Fixpoint toList (l : nonEmpty A) :=
match l with
| singleton x => (cons x nil)
| consNE x xs => (cons x (toList xs))
end.

Equations? fromList (l : list A) : length l > 0 -> nonEmpty A by wf
(length l) lt :=
{
fromList nil H := _;
fromList (cons x nil) _ := singleton x;
fromList (cons x (cons y l)) _ := consNE x (fromList (cons y l) _)
}.
Proof.
- exfalso. abstract omega.
- abstract omega.
Qed.

End NonEmpty.

Compute fromList [1] _. (* = singleton 1 *)
Compute fromList [1;2] _. (* = consNE 1 (singleton 2) *)
Compute fromList [1;2;3] _. (* = consNE 1 (consNE 2 (singleton 3)) *)
```

Here, I used the Equations plugin [1], which must be installed first.

[1]: <https://github.com/mattam82/Coq-Equations/>



Archive powered by MHonArc 2.6.19+.

Top of Page