如何使用函数定义重写目标?

时间:2017-03-26 08:46:19

标签: coq coq-tactic

我有这段代码:

 let imagesArray = ["image1.png","image2.png","image3.png","image4.png"]

        var randomNum: UInt32 = 0
        randomNum = arc4random_uniform(UInt32(imagesArray.count))
        wheelBackgroundImageView.image = UIImage(named: imagesArray[Int(randomNum)])

我想使用is_eq定义重写当前的子目标。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

我认为问题在于您对is_eq的定义。请注意,在模块声明中,您为is_eq

指定了以下类型
is_eq : T -> T -> bool

但是在模块NAT中你使用了命题相等,其类型为:

= : forall T, T -> T -> Prop

我已经通过设置is_eq的另一个版本来修复你的代码,基于自然数的标准库布尔相等,并为反身性做一个简单的归纳证明。

 ...  same code as before.
 Require Import Nat.

 Definition is_eq (x: T) y := eqb x y.

 Lemma is_eq_reflexivity : forall x, is_eq x x = true.
 Proof.
   induction x ; simpl ; auto.
 Qed.