Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用Coq解析一种简单的命令式语言_Coq - Fatal编程技术网

用Coq解析一种简单的命令式语言

用Coq解析一种简单的命令式语言,coq,Coq,我试图在Coq中解析以下简单命令式语言: Set Warnings "-notation-overridden,-parsing". From Coq Require Import Bool.Bool. From Coq Require Import Init.Nat. From Coq Require Import Arith.Arith. From Coq Require Import Arith.EqNat. From Coq Require Import omega.Omega. Fro

我试图在Coq中解析以下简单命令式语言:

Set Warnings "-notation-overridden,-parsing".
From Coq Require Import Bool.Bool.
From Coq Require Import Init.Nat.
From Coq Require Import Arith.Arith.
From Coq Require Import Arith.EqNat.
From Coq Require Import omega.Omega.
From Coq Require Import Lists.List.
From Coq Require Import Strings.String.
Import ListNotations.

Definition vname := string.
Definition val := Z.

Inductive type :=
| Int: type.

Inductive expr :=
| var : vname -> expr
| int : val -> expr
| add : expr -> expr -> expr.

Inductive com :=
| Skip : com
| Seq : com -> com -> com
| Bind : vname -> type -> com -> com
| Assign : vname -> expr -> com.

Bind Scope move_scope with com.
Notation "'SKIP'" :=
  Skip : move_scope.
Notation "c1 ;; c2" :=
  (Seq c1 c2) (at level 80, right associativity) : move_scope.
Notation "'LET' x ':' t 'IN' b 'END'" :=
  (Bind x t b) (at level 80, right associativity) : move_scope.
Notation "x '::=' e" :=
  (Assign x e) (at level 60) : move_scope.

Definition prog0 : com := SKIP.

Definition prog1 : com := (LET "x" : Int IN SKIP END).
但是,尝试分析let表达式时会出现错误:

语法错误:“:”应在中的[constr:operconstr level 200]之后 [施工:操作施工]

为什么会这样?如何解决它?

问题是:是一个保留的Coq关键字。不幸的是::连接列表的头和尾也是保留的。您可以使用:::-或任何其他您喜欢的符号-

Notation "'LET' x ':::' t 'IN' b 'END'" :=
  (Bind x t b) (at level 40, right associativity) : move_scope.
Definition prog1 : com := (LET "x" ::: Int IN SKIP END).
问题是:是一个保留的Coq关键字。不幸的是::连接列表的头和尾也是保留的。您可以使用:::-或任何其他您喜欢的符号-

Notation "'LET' x ':::' t 'IN' b 'END'" :=
  (Bind x t b) (at level 40, right associativity) : move_scope.
Definition prog1 : com := (LET "x" ::: Int IN SKIP END).

好的,那么禁币是写在上面的,我猜上面的信息只是说它没有找到:根据它的定义,在正确的地方。看看:是在哪里定义的会很有趣。好吧,那么禁止的标记是写在里面的,我猜上面的消息只是说它没有找到:根据它的定义在正确的地方。看看:的定义在哪里会很有趣。