Logic 基于coq的自动机模型化

Logic 基于coq的自动机模型化,logic,coq,automaton,Logic,Coq,Automaton,我在coq证明助手中对自动机的定义有问题,创建此代码时显示错误: (*automate*) Record automaton :Type:= mk_auto { states : Set; actions :Set; initial : states; transitions : states -> actions -> list states }. (*States*) Inductive st :Set:= q0 | q1 |q2 . Inductive

我在coq证明助手中对自动机的定义有问题,创建此代码时显示错误:

(*automate*)

Record automaton :Type:=
mk_auto {
   states : Set;
   actions :Set;
   initial : states;
   transitions : states -> actions -> list states
}.
(*States*)
Inductive st :Set:= q0 | q1 |q2 .
Inductive acts:Set:=pred(p:nat)|event(e:bool).
Definition a :acts:=pred(0).
Definition b:acts:=pred(1).
Definition c:acts:=event(true).
Function trans (q:st)(x:acts) :list st :=
match q, x with
  | q0, a =>  cons q1 nil
  | q1, b =>  cons q0 nil
  | q1, c =>  cons q2 nil
  | _,_ =>    nil (A:=_)
end.
错误是: 错误:此子句是多余的。(在本条下划线“|q1,c=>cons q2 nil”)


感谢您的关注。

当您执行模式匹配时,模式中有两种可能:构造函数或充当绑定器的自由变量。 例如,匹配的第一个大小写为“如果
q
是用
q0
构造的,对于分支中名为
a
x
的任何值,请执行…”

此分支中的
a
与您以前定义的
a
之间没有关系

因此,第2行和第3行是冗余的,它们都捕获了使用
q1
构造
q
并且
x
具有任何值的情况

我猜你想写点什么:

match q, x with
  | q0, pred 0 => cons q1 nil
  | q1, pred 1 => cons q0 nil
  | q1, event true => cons q2 nil
  | _, _ => nil (A := _)
end.
您可以在模式匹配分支中使用
Definition
创建别名。据我所知,使用这种别名的唯一方法是使用
表示法

如果将
a
b
c
的定义替换为:

Notation "'a'" := (pred 0).
Notation "'b'" := (pred 1).
Notation "'c'" := (event true).
然后,您的代码将像(我认为)您预期的那样运行。我建议您阅读Coq手册的一部分来了解符号

最好的,
V.

非常感谢您的回答。