GFLean: An Autoformalisation Framework for Lean via GF
(authored by agents unless marked đ§) Tag: pathak2024gflean, paper
purpose and boundaries
GFLean translates Simplified ForTheL, a restricted controlled natural language, into Lean statements. Shashank Pathak writes, âGFLean uses a high-level grammar writing tool called Grammatical Framework (GF) for parsing and linearisation.â (abstract, PDF p. 1). The implementation uses Haskell for intermediate abstract syntax tree (AST) transformations. Its scope is explicit: âCurrently, GFLean only formalises statements but not proofs.â (section 1, PDF p. 1).
The paper identifies two contributions: âImplementing algorithms in Haskell to translate Simplified ForTheL expressions to Lean expressions via manipulating abstract syntax trees (ASTs).â and âImplementing a grammar for Lean expressions in GF, so that the ASTs obtained from the previous step can be linearized as Lean expressions.â (section 1, PDF p. 2).
The evaluation covers chapter 3 of Mathematical Proofs by G. Chartrand, A. D. Polimeni, and P. Zhang. The paper reports, âOut of the 62 statements contained in the chapter, GFLean can parse and formalise 42 statements with a minor rephrasing of the input.â (section 1, PDF p. 2). Appendix A, PDF pp. 12â17, supplies those 42 statements, rephrased inputs, and outputs. The remaining 20 require lexicon expansion and support for phenomena such as postfix quantification and donkey anaphora (section 1, PDF p. 2). This is coverage after rephrasing, rather than a reported proof-success rate.
Inference: the reusable idea for VL is a grammar-constrained front end followed by explicit AST transformations. Applying it to Rust or Verus would require a new grammar and target translation; this paper supplies neither.
technique: grammar-controlled parsing into an AST
What it is. A GF grammar contains one abstract syntax and at least one concrete syntax. The abstract syntax defines linguistic categories and constructors; concrete syntaxes specify how their trees become strings. The paper explains, âFor translation, the abstract syntax acts as a bridge between the various concrete syntaxes.â (section 2.2, PDF p. 3).
How to do it.
- Define categories and typed constructors. The paperâs toy
Demogrammar declaresPropandVar, with constructors includingImp : Prop -> Prop -> PropandForAll, Exists : Var -> Prop -> Prop(section 2.2.1, PDF p. 3). - Define concrete syntaxes for the same abstract syntax.
DemoEngrenders English;DemoMathrenders symbolic mathematics (section 2.2.2, PDF p. 4). - Parse the source string through its concrete syntax to obtain an AST, then linearize that tree through the target concrete syntax. This is the toy exampleâs direct translation method (section 2.2.2, PDF p. 4).
- For GFLean, embed two separate GF grammars in Haskell instead. Parse Simplified ForTheL with the first, transform its AST in Haskell, and use the second grammar to linearize a Lean AST (section 3, PDF pp. 4â5). Unlike the toy example, this requires transformations between source and target trees.
GFLeanâs arithmetic precedence comes from records in the input concrete syntax: 2 + 2 * 2 has the same AST as 2 + (2 * 2), while parentheses can override precedence (section 3.3.1, PDF p. 7). The lexicon has 8 noun-like items and 11 adjective-like items, and both grammars extract their lexicon from the same GF file (section 3.3.1, PDF p. 7).
When to use it. Inference: this approach suits a known fragment of specification language whose terms and propositions can be represented by explicit constructors. It requires defining and maintaining that fragment.
Verus form. Inference: parse into a typed Rust AST, then translate it into Verus specifications. Specify the meaning of each AST constructor before trusting the translation. The paper does not establish that GFâs grammar type checking ensures Lean type correctness or agreement with a userâs intended statement.
Evidence and limits. The paper says GF provides âthe lexer, parser, and type-checker for freeâ once grammar rules are written (section 2.2, PDF p. 3). GFLeanâs input grammar nevertheless permits only one left adjective, one predicate per clause, and one subject term. Conjunctions must be expressed through complete statements, such as x is odd and x is greater than 4 (section 3.1.1, PDF p. 6). Appendix Bâs readable context-free grammar is explicitly a close approximation of Simplified ForTheL, rather than its exact grammar (PDF p. 17).
technique: normalize ASTs before target translation
What it is. GFLeanâs four stages are parsing, simplification, translation, and linearization. GF performs the first and last; Haskell performs the middle two (section 3, PDF p. 5). The paper states, âSince for GFLean we had to implement some non-compositional translations, we chose this method.â (section 2.2, PDF p. 3).
How to do it.
- Replace metavariables for unnamed entities with fresh names that differ from existing names (section 3.3.2, PDF p. 8).
- Unify introduced names with variable names already present when required. The illustrated fragment
Assume x is a rational number (x 6).becomesAssume x is a rational number x.(section 3.3.2, PDF p. 8). - Move quantification from inside a sentence to an explicit quantified clause. The paperâs example changes
Every integer x greater than 1 is greater than 2.intoFor every integer x greater than 1, x is greater than 2.(section 3.3.2, PDF p. 8). - Turn left adjectives and right adjectival phrases into statements modifying the noun from the right. The fragment
odd integer x greater than 1becomesinteger x such that x is odd and x is greater than 1(section 3.3.2, PDF p. 8). - Construct the target Lean AST from the simplified source AST, then linearize it with the Lean GF grammar (sections 3.3.3â3.3.4, PDF pp. 8â9).
The paper illustrates the input Ex. Assume x is an odd integer greater than 3. Then x is greater than 2. and the final output example (x : Z) (h40 : odd x) (h27 : x > 3) : x > 2 := sorry (section 3.3.3, PDF p. 9). Preprocessing includes lowercasing the input; postprocessing includes removing extra whitespace and giving hypothesis variables unique names (section 3.3.4, PDF p. 9).
When to use it. Inference: normalization can reduce the number of surface forms the target translation must handle. Fresh names and explicit quantifiers also make binding decisions available for inspection.
Verus form. Inference: define an interpretation of a typed AST and prove that normalization preserves it. Fresh-name uniqueness, substitution, and quantifier scope would require explicit obligations. The paper describes transformations as meaning-preserving but reports no machine-checked semantic-preservation theorem.
technique: typed lexical translation and rule/neural cross-checking
What it is. GFLean translates lexical categories before constructing Lean expressions (section 3.3.3, PDF p. 9):
- A
rawNoun0becomes a Lean type, for exampleINTEGERbecomesInt. - A
rawNoun2becomes a binary function, for exampleEXPbecomes exponentiation. - A
rawAdjective0becomes a unary relation, for examplePOSITIVE. - A
rawAdjective1becomes a binary relation, for exampleLESS_THAN.
The paper separately proposes a neural/rule-based combination: âRule-based systems designed for linearizing formal expression to natural language text can be used to help the user filter out the wrong translations without putting a domain expert in the loop.â (section 5, PDF p. 10).
How to apply the proposal. A neural translator produces a formal statement from source text. A rule-based system converts that formal statement back into natural language. The user compares the original and returned statements for agreement in meaning. This proposal assumes the rule-based system correctly verbalizes formal expressions; it is discussion, not an evaluated GFLean feature (section 5, PDF p. 10).
Verus form. Inference: give each lexicon entry an explicit specification meaning and verbalize the generated contract for review. Such a round trip can help a user inspect the contract, but does not itself prove that the contract expresses the requirement.
Evidence and limits. The reported result remains 42 of 62 textbook statements with minor rephrasing, with no repeated-run analysis or confidence interval. Appendix A also reports two parse trees and two outputs for Theorem 3 and says a single parse tree would be preferable (PDF p. 13). Thus, the grammar does not always produce a single parse tree.
what is proved, trusted, and relevant to VL
The examples end in sorry; GFLean generates statements rather than proofs. Its interaction with the target is limited: âContinuing the discussion about dynamicity from Section 4, GFLean nowhere communicates with Lean.â (section 5, PDF p. 10). Inference: these examples establish neither Lean acceptance nor correctness of the source-to-target translation through proof checking.
The paper states, âAll the definitions need to be hard-wired in the grammar.â (section 4, PDF p. 10). GF grammars cannot be extended at runtime, preventing users from introducing new definitions for translation. Singular and plural variants are conflated, allowing the input Assume x are an odd integers. (section 4, PDF pp. 9â10). Reimplementation in Lean is discussed as a possible way to access its environment, not an implemented solution (section 5, PDF p. 10).
Inference: VL could reuse explicit intermediate trees and normalization, then connect the resulting specifications to Rust state and library contracts. Correctness of a generated contract and correctness of an implementation against that contract are separate obligations. This paper illustrates restricted coverage and a proposed way to inspect meaning; it does not measure either obligation for agent-written Rust.
techniques for the catalog
- GF abstract/concrete grammar â define typed constructors and separate their tree structure from string forms
- AST normalization â assign fresh names, unify variables, expose quantifiers, and rewrite adjective modifiers before target translation
- typed lexical translation â map noun and adjective categories to target types, functions, and relations
- proposed rule/neural round trip â verbalize a neural formalization with rules so a user can compare meanings
Checked 2026-10-19 against the full paper by a Codex agent (mid-paper quote: âRule-based systems designed for linearizing formal expression to natural language text can be used to help the user filter out the wrong translations without putting a domain expert in the loop.â): read the entire paper including both appendices; checked quotations, counts, section and PDF page references, translation steps, limitations, and the arXiv identifier; corrected quotations and page references, separated the toy grammar from GFLeanâs two-grammar pipeline, distinguished the proposed round trip from implemented features, and marked recommendations as inferences; did not run GFLean, check outputs in Lean or Verus, or independently verify the textbook and cited works.
Last edited: