簡體   English   中英

coq中的“==>”是什么意思?

[英]What does “==>” mean in coq?

我有以下代碼:這是排序的def:

Fixpoint sorted (l : list nat) := 
  match l with 
  | [] => true 
  | x::xs => match xs with 
             | [] => true 
             | y :: ys => (x <=? y) && (sorted xs) 
             end 
  end.

這是插入的定義:


Fixpoint insert (x : nat) (l : list nat) := 
  match l with 
  | [] => [x] 
  | y::ys => if x <=? y then x :: l 
             else y :: insert x ys 
  end.

這是 insert_spec 的定義:


Definition insert_spec (x : nat) (l : list nat) :=
  sorted l ==> sorted (insert x l).

在 insert_spec 中,“==>”是什么意思?

您似乎從 Software Foundations 的QuickChick guide獲得了代碼。 該指南中使用的許多(如果不是全部)符號可以在QuickChick 參考手冊中找到。 在那里,我們發現"==>"被定義為一個符號。

Module QcNotation.
  Export QcDefaultNotation.
  Notation "x ==> y" :=
    (implication x y) (at level 55, right associativity)
    : Checker_scope.
End QcNotation.

implication是 QuickChick 使用的通用“暗示是否為真”參數。

Parameter implication :
  ∀ {prop : Type} `{Checkable prop} (b : bool) (p : prop), Checker.

每當第一個參數為真時,QuickChick 測試第二個參數(在您使用 QuickChick 的任何上下文中)的計算結果是否也為真。

因此,對於您的特定代碼, "==>"用於表示我們要測試每當l被排序時, insert xl也被排序。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM