4
私はCoqを初めて使い、破壊戦術について簡単に質問します。私は次の定理を証明したいと思います述語関数を適用した結果を破壊する
Fixpoint count (v : nat) (xs : natlist) : nat :=
match xs with
| nil => 0
| h :: t =>
match beq_nat h v with
| true => 1 + count v xs
| false => count v xs
end
end.
::私は自然数のリスト内の指定された自然数の出現回数をカウントcount
機能を持っていると仮定し
Theorem count_cons : forall (n y : nat) (xs : natlist),
count n (y :: xs) = count n xs + count n [y].
た場合、私はn = 0の類似定理を証明していたので、単にyを0またはS y 'に破棄することができた。一般的なケースでは、(beq_nat n y)をtrueまたはfalseに破棄することができますが、それを働かせることはできません.Coq構文の一部が欠落しています。
アイデア?あなたはおそらくdestruct
を使用し
Fixpoint count (v : nat) (xs : natlist) : nat :=
match xs with
| nil => 0
| h :: t =>
match beq_nat h v with
| true => 1 + count v t
| false => count v t
end
end.
を意味
ああ、良いキャッチ - その最初のバグは、スタックのオーバーフローに入力中にタイプミスでした。私はdestruct(beq_nat n y)がdestruct(beq_nat y n)と同じではないという2つ目の点は私のハングアップだと思います。ありがとう! –