[英]Declaring implicit arguments in Coq: how many underscores are needed?
在下面的Coq代碼片段中(從一個真實示例中刪除),我試圖將exponent_valid
的第一個參數聲明為隱式:
Require Import ZArith.
Open Scope Z.
Record float_format : Set := mk_float_format {
minimum_exponent : Z
}.
Record float (fmt : float_format) : Set := mk_float {
exponent : Z;
exponent_valid : minimum_exponent fmt <= exponent
}.
Arguments exponent_valid {fmt} _.
據我所知, exponent_valid
函數有兩個參數:一個是float_format
類型,另一個是float
類型,第一個可以推斷出來。 但是,編譯上面的代碼段失敗,並顯示以下錯誤消息:
File "/Users/mdickinson/Desktop/Coq/floats/bug.v", line 13, characters 0-33:
Error: The following arguments are not declared: _.
事實上,將Arguments
聲明更改為:
Arguments exponent_valid {fmt} _ _.
使錯誤消息消失。
沒關系; 我是Coq的新手,我完全相信我忽略了一些東西。 但是,現在的位,這真的困惑我:如果我更換<=
中的定義exponent_valid
用<
中,代碼編譯沒有錯誤!
我有兩個問題:
_
? <=
with <
使exponent_valid
期望的參數數量有所不同? 如果它是相關的,我正在使用Coq 8.4pl5。
exponent_valid
有類型
forall (fmt : float_format) (f : float fmt), minimum_exponent fmt <= exponent fmt f.
沒有符號就是這樣
forall (fmt : float_format) (f : float fmt), Z.le (minimum_exponent fmt) (exponent fmt f).
Z.le
定義為
= fun x y : Z => not (@eq comparison (Z.compare x y) Gt).
not
被定義為
= fun A : Prop => A -> False.
所以exponent_valid
的類型可以轉換為
forall (fmt : float_format) (f : float fmt),
(minimum_exponent fmt ?= exponent fmt f) = Gt -> False,
這意味着該函數最多可以占用三個參數。
但是,我認為Arguments
命令是否應該考慮可轉換性或者即使需要提供有關函數的所有參數的信息也是有爭議的。 也許應該允許用戶刪除任何尾隨下划線。
你的理解是正確的,這對我來說就像一個(非常奇怪的)錯誤。 我剛剛提交了關於bug跟蹤器的報告 。
編輯 :啊,當我看着這些東西時,flockshade在下面的觀察完全沒有引起注意。 畢竟它確實有三個參數!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.