2017-08-15 11 views
1

natstringcoqに変換する関数を作成しようとしていました。ここに私の試みです。Arithをインポートしているにもかかわらず "_/_"の解釈が不明

Require Import Arith String. 

(* 
    append is part of the string library. Its signature is 
       (s1 : string) : string -> string 
*) 

Fixpoint convert_nat_to_string (n : nat) : string := 
match n with 
    | 0 => String "0" EmptyString 
    | 1 => String "1" EmptyString 
    | 2 => String "2" EmptyString 
    | 3 => String "3" EmptyString 
    | 4 => String "4" EmptyString 
    | 5 => String "5" EmptyString 
    | 6 => String "6" EmptyString 
    | 7 => String "7" EmptyString 
    | 8 => String "8" EmptyString 
    | 9 => String "9" EmptyString 
    | _ => (append (convert_nat_to_string (n/10))) (convert_nat_to_string (n mod 10)) 
end. 

しかし、最後の枝に、coqideは私がArithライブラリをインポートしているにもかかわらず、私のエラー

Error: Unknown interpretation for notation "_/_".

を与えます。なぜ誰かがこのエラーメッセージを受け取っているのか分かりませんか?


/Arithの一部であることを証明:コック8.6のよう

Coq < Require Import Arith. 
[Loading ML file z_syntax_plugin.cmxs ... done] 
[Loading ML file quote_plugin.cmxs ... done] 
[Loading ML file newring_plugin.cmxs ... done] 
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked 
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked 
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked 
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked 
<W> Grammar extension: in [tactic:simple_tactic], some rule has been masked 

Coq < Check 5/10. 
5/10 
    : nat 
+0

私はCoq 8.6を使用しています。あなたのコードをそのまま試してみましたが、私はあなたが見るエラーを再現できません。あなたは完全性と関連しなければならない別のエラーが表示されます。 'Program Fixpoint'を使うか、提案された方法(https://softwarefoundations.cis.upenn.edu/draft/qc-current/Typeclasses.html)に従うことができます(' string_of_nat'を探してください)。 –

+0

@AntonTrunovはそれを歓迎します。私はコマンドラインからコードを直接実行しようとしたが、あなたが言及したのと同じエラーが発生した。しかし、IDEから実行している間、私は質問で言及したエラーを私に与える。 – iamwhoiam

+0

私はCoqIDEユーザーではないので、修正方法はわかりません。 ProofGeneral + company-coq(オプション)にショットを付けることができます:) CoqIDEに関する多くの質問があります。私は、Emacsを設定することはあなたの優先事項の中にないかもしれないと認めます:) –

答えて

1

、この関数は、Coq.Arith.PeanoNatで利用可能です。

Require Import Coq.Arith.PeanoNat. 

Check 10/5. (* --> 10/5 : nat *) 
+0

Thanks Arthur。 'coqide'で使われている' coq'のバージョンを確認する方法があるかどうか知っていますか?これが本当に問題であることを確認できますか? – iamwhoiam

+0

コマンドラインで 'coqtop -v'を実行すると、私は' 8.5pl13'としてバージョンを取得します。 – iamwhoiam

+0

@iamwhoiam私のバージョンのcoqideは、起動時に使用しているCoqのバージョンを右下に表示します。それがあなたの上に存在しない場合は、ツールバーの "about"メニューを試してみてください。あなたはどのOSを使用していますか? –

関連する問題