Skip to content

Instantly share code, notes, and snippets.

@yoshihiro503
Last active February 18, 2018 12:56
Show Gist options
  • Save yoshihiro503/1886630cf8b5a633d39e53f3a3bf3de6 to your computer and use it in GitHub Desktop.
Save yoshihiro503/1886630cf8b5a633d39e53f3a3bf3de6 to your computer and use it in GitHub Desktop.
Require Import Arith List.
Import ListNotations.
Fixpoint range_aux (a len: nat) : list nat :=
match len with
| O => []
| S len' => a :: range_aux (S a) len'
end.
Definition range (a b: nat) : list nat := range_aux a (b - a + 1).
Lemma range_Forall : forall a b,
Forall (fun x => a <= x <= b) (range a b).
Proof.
(* 未解決 *)
Admitted.
@chiguri
Copy link

chiguri commented Feb 18, 2018

Definition range (a b: nat) : list nat := range_aux a (b + 1 - a). (* -aの位置を後ろにずらした *)
にしないと b < a のときにrange_auxがaのリストを作るのでrange_Forallが成り立ちません。
(Eval compute in (range 4 3). では[4]が出ます)
rangeの定義を上のものに変更するか、range_Forallの前提にa <= bを入れる必要があります。

@yoshihiro503
Copy link
Author

おお!ありがとうございます!
(b + 1 - a) の方針に修正します!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment