Coq不会减少涉及决策程序的表达

时间:2019-04-23 13:41:12

标签: coq theorem-proving

我使用的是Coq版本8.8.1,在我生命中,我无法弄清为什么它不评估以下计算的值。

Require Import Coq.Lists.List.
Import Coq.Lists.List.ListNotations.
Require Import Coq.Classes.EquivDec.
Require Import Coq.Init.Nat.
Require Import Coq.Arith.EqNat.
Require Import Coq.Lists.ListSet.
Require Import Coq.Bool.Bool.

Inductive term : Set :=
  | var : nat -> term
  | fn : nat -> term -> term.

Scheme Equality for term.

Fixpoint uf_find (x : term) (ufs : set (set term)) : option (set term) :=
  match ufs with
  | [] => None
  | uh::ufs' => match (set_In_dec term_eq_dec x uh) with
                | left _ _ => Some uh 
                | right _ _ => uf_find x ufs'
                end
  end.
Compute uf_find (var 3) nil.
(* Why isn't this fully reduced? *)
Compute uf_find (var 3) (cons nil nil).

term_eq_dec类似的功能可以正常工作:

Fixpoint has_succ (x : nat) (l : list term) : option term :=
  match l with
  | [] => None
  | h::l'=> match term_eq_dec (var (S x)) h with
            | left _ _ => Some h
            | right _ _ => has_succ x l'
            end
  end.
Compute has_succ 3 [(var 2); (var 1); (var 4)].

0 个答案:

没有答案