coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- 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 21:36:01 +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 mout02.posteo.de
- Ironport-phdr: 9a23:zmRg/BSSYsDMTA26cx7gXNzWk9psv+yvbD5Q0YIujvd0So/mwa6yZR2N2/xhgRfzUJnB7Loc0qyK6v+mAjZLuM3d+Fk5M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aFRrwLxd6KfroEYDOkcu3y/qy+5rOaAlUmTaxe7x/IAi0oAnLuMQan4RuJrs/xxbGv3BFZ/lYyWR0KFyJgh3y/N2w/Jlt8yRRv/Iu6ctNWrjkcqo7ULJVEi0oP3g668P3uxbDSxCP5mYHXWUNjhVIGQnF4wrkUZr3ryD3q/By2CiePc3xULA0RTGv5LplRRP0lCsKMSMy/WfKgcJyka1bugqsqQFhzY7aYI+bN/Rwca3SctwYWWVPUd1cVzBDD46mc4cDE+QMMOReooLgp1UOtxy+BQy0Ce3o0DBJiX723ag70+QlEAHJxgogFM8Ov3TJsNX1KKQSXv6ox6TPyDXCYe5W2Svh6IjLbB8spfOBUKloccrW0kkvCx3KjlKKpYP4ITyYz+IAuHWU4OR8T+ygkXInqx1vrTi1wMchkpfEiIIbx13L6Sl0zps5KN+4RUN7YdCpDZtduj2EOoZyTM4vQW9mtiYnxrAHuZO3YiYHxIglyhPDavGKcoeF7BzlWe2MIjl4nGpodK+8ihuy60Sty+/xWtO63VtLtCZIk9jBumgO2hHX8MSLV/Rw80a71TqRyQzf9vtILV06mKbHLZMq36Q+mYAJsUvZGy/7gEX2g7GSdkUj4uWo7uPnYqj6ppOAKYN4kBn+MqM1msyjH+s4NRICUHWF9uik1b3j+1P2QKlSg/ErkaTUsIrWKMUZq6KjDQJY05wv5he+Aju+1dQXh3gHLFZLeBKdiIjpPknDIPX2DPein1SsjDRryO7CM7DjGZjNNn/DkKz9fblj7E5Q0hc8ws5H65JOFr4BOO7zWlP2tNHAEhA5NBW0z//7B9V5y4MRQnmCArSZMaPXqV+H/PgjI+iKZI8PuTbyMeIp5/D0jSxxpVhIdq6wmJATdXqQH/J8Ikzfb2C/rM0GFDIvtxo/Se3uiVSEGQFOe2qxUupo4y4mFJ6lANacbpiqm6CM22G3E8sFNSh9FlmQHCKwJM2/UPAWZXfKe5Mzonk/TbGkDrQZ+1S2rgajkuh/KfHI9ypeuZ+xjIEotd2Wrgk78HlPN+rY02yJSDgkzGYPWiNuhuZnpldhx1DF3aUq26UJR+wW3OtAV0IBDbCZyuV7D97oXQeYJ4WRT026T9LgDTxjF98=
Here's another implementation, where instead of `destruct eqn:` I use an
auxiliary function that makes a case distinction whether a list is empty
or not.
```
(** Returns either a proof that [l = nil] or a proof that [1 <= length
l]. *)
Definition list_nil_or_not_empty (l : list A) : (l = nil) + (1 <= length l).
Proof.
destruct l.
- left. reflexivity.
- right. cbn. abstract omega.
Defined.
Fixpoint fromList (l : list A) : 1 <= length l -> nonEmpty A.
Proof.
destruct l as [ | x l'].
- intros H. (* [H : 1 <= length nil] *)
exfalso. cbn in H. abstract omega.
- intros _. (* We can forget the hypothesis, since it is a tautology:
[1 <= length (x :: l')] *)
(* Instead, we make a case analysis whether [l'] is empty or not *)
destruct (list_nil_or_not_empty l') as [Hl'|Hl'].
+ (* [Hl' : l' = nil] *) (* We don't actually need the proof here
that [l' = nil]. *)
exact (singleton x).
+ (* [Hl' : 1 <= length l'] *)
refine (consNE x (fromList l' _)).
exact (consNE x (fromList l' Hl')).
Defined.
```
On 30/09/2020 21:19, Maximilian Wuttke wrote:
> ```
> Fixpoint fromList (l : list A) : 1 <= length l -> nonEmpty A.
> Proof.
> destruct l as [ | x l'].
> - intros H. exfalso. cbn in H. abstract omega.
> - destruct l' as [ | y l''] eqn:E.
> + intros _. exact (singleton x).
> + intros H. refine (consNE x (fromList l' _)).
> abstract (subst; cbn in *; omega).
> Defined.
> ```
- [Coq-Club] Not enough information to resolve this refine goal, Agnishom Chattopadhyay, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, jonikelee AT gmail.com, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Maximilian Wuttke, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Maximilian Wuttke, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Agnishom Chattopadhyay, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Maximilian Wuttke, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Agnishom Chattopadhyay, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Maximilian Wuttke, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Maximilian Wuttke, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, Maximilian Wuttke, 09/30/2020
- Re: [Coq-Club] Not enough information to resolve this refine goal, jonikelee AT gmail.com, 09/30/2020
Archive powered by MHonArc 2.6.19+.