Velus: 使用定理证明技术实现的可信Lustre编译器

Velus[1] 是由 Inria PARKAS 于2020年发起,旨在使用 Coq 证明辅助技术对类似 Lustre 与 Scade 同步数据流语言(注1)的语义提供具备形式化证明的实现。近年该项目主要由 Basile Pesin 推动该项目[2]。

注1: 虽然 Velus 项目没有注明提到的 Lustre 与 Scade 的实现版本,但由于 Lustre v6 于2020年发布、Scade 6 于2008年发布,因此认为 Velus 愿景中参考的语言为 Lustre v6 与 Scade 6。

Velus 支持的语法

Velus 已发表的最新进展为 “EMSOFT2023 - Verified Compilation of Synchronous Dataflow with
State Machines”。该工作拓展了过去 Velus 支持的语法语义,对 Lucid Synchrone 和 Scade 6中存在的 reset block, swith block, local scope, hierarchical state machine 提供支持。

抽象语法如下

// expressions 
e ::= 
    c
    | C 
    | x 
    | last x 
    | unary_op e 
    | e binary_op e 
    | e+ fby e+
    | e+ -> e+ 
    | e+ when C(x) 
    | merge x (C=> e+)+ 
    | case e of ( C => e+)+
    | f(e+)
    | (reset f every e) (e+)

// nodes and programs
td ::= type ty = ( | C)+
d ::= x_ck_ty 
ck ::= base clock | ck on C(x) 
n ::= node f(d+) returns (d+) blk 
G ::= td* n+ 

// blocks and declarations 
blk ::= x+ = e+;
    | var loc* let blk* tel 
    | reset blk+ every e 
    | switch e (C do blk+)+ end 
    | automaton initially autinits 
        (state C autoscope)+ end 
    | automaton initially C 
        (state C do blk+ unless trans+)+ end
loc ::= d | last d = e
autinits ::= C | if e then C else autinits 
autscope ::= var loc* do blk+ until trans+ 
trans ::= | e continue C | e then C 

注意到 Velus 支持的语法相比如 Scade 6 等语言,重点关注在语言本身的主要语法,而不是在编写大型程序场景中所需要的语法语义特性方面。具体来说,

  • 在预定义算子方面,关注一元,二元算子、核心时序算子、核心调用算子与重置等。并不关注 Scade 6 中支持的其他预定义算子。
  • 语法不关注在编写大型程序场中会使用到的 package、visibility、generic type、polymorphism 等特性。
  • 语法不关注如 struct, array 等数据结构及处理这些数据结构的算子。
  • 语法不关注用于同步的 signal 语法。
  • 语法简化了状态机语法,如对迁移语法的简化等。

Velus 的可信编译过程

Velus 基于 OCaml 技术栈实现。对编译器前端,采用 Menhir 作为 lexer/parser 生成器。在语义分析与source to source 转换阶段,采用 Coq 证明辅助技术。生成 Clight 后,采用 CompCert 可信编译。

参考

[1]: Verified Lustre compilation, https://velus.inria.fr/
[2]: velus github repo, https://github.com/INRIA/velus

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值