[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-408555-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-408555-en":131},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","kerspecgen-research-article-formal-kernel-specification-synthesis","KerSpecGen - Research Article - Formal Kernel specification synthesis","","Formal verification guarantees software correctness but makes writing kernel specifications costly, expertise-dependent, and constrained to specific targets. This work introduces KerSpecGen, an LLM-based framework that synthesizes formal kernel specifications by leveraging refined knowledge graphs to connect requirement descriptions with specification properties. The approach includes constructing a deduplicated, property-judged knowledge graph, fine-tuning a model on a custom dataset, and using LLM synthesis templates to produce complete candidate programs. Experiments on KerSpecProperty show an average +7.06 BLEU-4 gain over Few-shot.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/research-report/","Research & Report",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/kerspecgen-research-article-formal-kernel-specification-synthesis/408555/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/kerspecgen-research-article-formal-kernel-specification-synthesis/408555.png","ImageObject",300,407,{"name":42,"@type":43},"LangkahRina","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-28","2026-09-28",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",13,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What problem does KerSpecGen address in formal kernel specification writing?","Question",{"text":63,"@type":64},"It addresses the low efficiency and high difficulty of generating formal specifications, which are labor-intensive, require deep domain expertise, and are limited to specific targets.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How does KerSpecGen use knowledge graphs in its synthesis pipeline?",{"text":68,"@type":64},"It constructs a refined knowledge graph that represents progressive specification relationships, including deduplication, property judgment, and source annotation, to improve accuracy and connect requirements to properties.",{"name":70,"@type":61,"acceptedAnswer":71},"What do the benchmark results show about KerSpecGen’s performance?",{"text":72,"@type":64},"On the KerSpecProperty benchmark, KerSpecGen outperforms Few-shot by an average of 7.06 percentage points in BLEU-4, and for Llama-3.1-405B it yields better specification quality in 23 of 30 modules.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},408555,1791009791,{"code":4,"msg":82,"data":83},"success",[84,88,92,96,101,106,111,115,120,123,127],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":97,"doc_module":4,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},5,"Comic",60,"comic",{"id":102,"doc_module":4,"doc_module_name":25,"category_name":103,"show_sort_weight":104,"slug":105},6,"Technology",50,"technology",{"id":107,"doc_module":4,"doc_module_name":25,"category_name":108,"show_sort_weight":109,"slug":110},7,"Healthcare",40,"healthcare",{"id":112,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":113,"slug":114},8,30,"research-report",{"id":116,"doc_module":4,"doc_module_name":25,"category_name":117,"show_sort_weight":118,"slug":119},9,"Religion & Spirituality",20,"religion-spirituality",{"id":118,"doc_module":4,"doc_module_name":25,"category_name":121,"show_sort_weight":118,"slug":122},"World Cup","world-cup",{"id":124,"doc_module":4,"doc_module_name":25,"category_name":125,"show_sort_weight":124,"slug":126},10,"Lifestyle","lifestyle",{"id":128,"doc_module":4,"doc_module_name":25,"category_name":129,"show_sort_weight":97,"slug":130},19,"General","general",{"code":4,"msg":82,"data":132},{"doc_id":79,"user_id":133,"nickname":42,"user_avatar":134,"doc_module":4,"category_id":112,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":135,"file_id":136,"file_url":137,"file_type":138,"file_size":139,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":140,"language":141,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":142,"faqs":143,"seo_title":144,"seo_description":12,"update_tm":145,"read_time":146,"preview_page_count":33,"preview_urls":147},962090893776,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d","OPEN ACCESS  \nCitation: Wang Z, Zhu X, Wang H, Yu Y, Lan Y (2025) KerSpecGen: Co-piloting formal Kernel specification synthesis with refined knowledge graphs and large language models. PLoS One 20(12):  \ne0338821 . [https://doi.org/10.1371/journal](https://doi.org/10.1371/journal). pone.0338821  \nEditor: Hui Li, Dalian Maritime University, CHINA  \nReceived: March 9, 2025  \nAccepted: November 26, 2025  \nPublished: December 31, 2025  \nCopyright: © 2025 Wang et al. This is an open access article distributed under the terms of the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.  \nData availability statement: The data are available at: [https://github.com/zizzzw/](https://github.com/zizzzw/)[ ](https://github.com/zizzzw/)KerSpecGen/tree/master.  \nFunding: The author(s) received no specific funding for this work.  \nCompeting interests: No authors have  \ncompeting interests.  \nRESEARCH ARTICLE  \nKerSpecGen: Co-piloting formal Kernel specification synthesis with refined knowledge graphs and large language models  \nZi Wang1 , Xiaoyu Zhu2 , Hongqiang Wang2 , Yichun Yu3 , Yuqing Lan1,2 *  \n1 School of Cyber Science and Technology, Beihang University, Beijing, China, 2 School of Software, Beihang University, Beijing, China, 3 School of Computer Science and Engineering, Beihang University, Beijing, China  \n* [lanyuqing@buaa.edu.cn](lanyuqing@buaa.edu.cn)  \nAbstract  \nFormal verification ensures software correctness but faces challenges in kernel specification writing, which is labor-intensive, expertise-dependent, and limited to specific targets. For complex microkernels like seL4, these issues significantly reduce the practicality of formal methods. To address this, we propose KerSpecGen, a Large Language Model (LLM) based framework for synthesizing formal kernel specifications, which leverages knowledge graphs to bridge requirement descriptions and specification properties.  \nKerSpecGen’s core design includes three key components: 1) constructing a refined knowledge graph to represent progressive specification relationships (with deduplication, property judgment, and source annotation to improve accuracy); 2) building a custom dataset to fine-tune a model that converts specification properties into code; 3) designing LLM-oriented synthesis templates to transform generated code into complete candidate specification programs.  \nEvaluation on our KerSpecProperty benchmark (30 seL4 function modules, 624 properties) shows KerSpecGen outperforms the Few-shot method by an average of 7.06 percentage points in BLEU-4 . Specifically, for the Llama-3 . 1-405B model, KerSpecGen achieves better specification quality than the Few-shot method in 23 out of 30 functional modules. To our knowledge, this is the first work to generate formal specifications for complex microkernels. KerSpecGen yields high-quality reference specifications. While requiring minor adjustments for direct execution, it substantially reduces the burden of writing specifications from scratch.  \n1 Introduction  \nThe kernel serves as the cornerstone of all software, underpinning the security and reliability of operating systems, cloud platforms, and embedded devices, which makes its security and safety a paramount concern for both industry and academia.  \nPLOS One  [https://doi.org/10.1371/journal.pone.0338821](https://doi.org/10.1371/journal.pone.0338821) December 31, 2025 1/ 25  \nFormal verification, as a mathematically rigorous approach to proving software correctness, is widely recognized as a critical tool to guarantee the critical attributes (e.g. , memory safety, privilege isolation) of kernel systems. With the increasing complexity of modern kernels (e.g. , support for multi-core concurrency, confidential computing, and heterogeneous architectures), the demand for scalable formal verification becomes more urgent than ever. However, typical kernel formal ver","cbCaipcf3nHFKrAZ","https://ap.wps.com/l/cbCaipcf3nHFKrAZ","pdf",7439643,25,"English","# Abstract\n# 1 Introduction\n## Kernel security and formal verification challenges\n## Spec-writing complexity across preconditions, postconditions, and invariants\n## Example: seL4_TCB_Create specification layers","[{\"question\":\"What problem does KerSpecGen address in formal kernel specification writing?\",\"answer\":\"It addresses the low efficiency and high difficulty of generating formal specifications, which are labor-intensive, require deep domain expertise, and are limited to specific targets.\"},{\"question\":\"How does KerSpecGen use knowledge graphs in its synthesis pipeline?\",\"answer\":\"It constructs a refined knowledge graph that represents progressive specification relationships, including deduplication, property judgment, and source annotation, to improve accuracy and connect requirements to properties.\"},{\"question\":\"What do the benchmark results show about KerSpecGen’s performance?\",\"answer\":\"On the KerSpecProperty benchmark, KerSpecGen outperforms Few-shot by an average of 7.06 percentage points in BLEU-4, and for Llama-3.1-405B it yields better specification quality in 23 of 30 modules.\"}]","KerSpecGen - Research Article - Formal Kernel specification synthesis | PDF",1790579746,63,[148,152,156,160],{"page_no":22,"url":149,"width":150,"height":151},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/6cbf5d3334fe187b76597b713415a082.webp",983,1272,{"page_no":26,"url":153,"width":154,"height":155},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/e14b8b7643fb0cad520824c5128ccb5f.webp",982,1270,{"page_no":30,"url":157,"width":158,"height":159},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/9ca169cc8da04a41ba08a7b93b8fa2e4.webp",981,1269,{"page_no":33,"url":161,"width":162,"height":163},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-16/bc0265c86436d5698d9a201c1b23ddd6.webp",980,1268]