Learning Structure-Aware Representations of Dependent Types

Agda is a dependently-typed programming language and a proof assistant, pivotal in proof formalization and programming language theory. This paper extends the Agda ecosystem into machine learning territory, and, vice versa, makes Agda-related resources available to machine learning practitioners. We introduce and release a novel dataset of Agda program-proofs that is elaborate and extensive enough to support various machine learning applications -- the first of its kind. Leveraging the dataset's ultra-high resolution, which details proof states at the sub-type level, we propose a novel neural architecture targeted at faithfully representing dependently-typed programs on the basis of structural rather than nominal principles. We instantiate and evaluate our architecture in a premise selection setup, where it achieves promising initial results, surpassing strong baselines.

Paper

References (30)

Scroll for more · 18 remaining

Similar papers

Peer review

Reviewer xpMx7/10 · confidence 4/52024-07-09

Summary

The article contributes to the field by detailing a method to capture and utilize the internal compilation states of Agda, a dependently typed programming language, through JSON files. These JSON files represent different compilation states, reflecting various stages of the coding process. Key contributions of the article include: - It explains how each JSON file mirrors Agda's internal state during compilation, which is dynamic and changes based on the current focus of the compilation process. This approach captures the evolution of the file content at different coding stages. - The method involves iterating through each definition within a file, focusing on all possible sub-terms rather than just potential prefixes of a proof. This detailed navigation allows for a more comprehensive utilization of the file as a data resource, enhancing the understanding of Agda’s compilation process. - By treating each file as a data resource and navigating its states preemptively, the approach acts like a type-safe data augmentation routine. This maximizes the resource utilization of the file content. - The article also highlights how each state's typing context is recorded, including the type, relevant definitions, and local variables. Additionally, it thoroughly explicates the structural aspects of terms in Agda, going beyond simple λ-expressions to include a variety of constructs like datatype declarations and pattern matching, which are all captured within the JSON structure. - For better readability and to aid practitioners interested in a more linear format, the dataset includes pretty-printed displays of each abstract syntax tree (AST). The article provides foundational insights into leveraging Agda’s internal mechanisms for better data handling and representation in JSON format, which could be useful for both researchers and developers working with dependently typed languages.

Strengths

- This article provides a detailed investigation of the role of representation learning in Automated Theorem Proving (ATP), which is novel. - It provides valuable resources for the community.

Weaknesses

- Although it's within the setting of premise selection, I still hope to provide a usable baseline for search-based ATP. - Can you provide some visual results on representation?

Questions

- Can you provide some visual results on representation? - Are you asking if it's possible to commit to open-sourcing the code in the future?

Rating

7

Confidence

4

Soundness

3

Presentation

3

Contribution

3

Limitations

- Premise selection is an interesting area, but it cannot truly generate theorems. It could be considered for expansion into a more general setting.

Authorsrebuttal2024-08-09

Thank you for your questions, we really appreciate your engagement. * `multiple positive samples` We don't have to do anything special! Think of some make-do proof that looks like `A (B C)`, where `A`, `B` and `C` are lemmas. There are several possible holes: `? (B C)`, `A (? C)`, `A (B ?)` and `A ?`. The last one contains *two* positive lemmas: `B` and `C`, so we want both of them to be picked by the premise selector. * `... negative samples selected ...` Consider the previous example, and a context providing availability to lemmas `A`, `B`, `C`, `D` and `E`. For this present hole, `A`, `D` and `E` are *negative* as they do not appear inside of it. * `... vanilla Transformer ...` We were also wondering the same thing; we already used a vanilla Transformer to catastrophic results. See the last row of Table 1. (ps: see also line 354)

Reviewer xpMx2024-08-09

- **negative samples selected:** I see. So, actually, the negative samples are randomly selected excluding the positive samples? - **Supplement the baseline:** Is the vanilla Transformer in the last row of Table 1 trained with autoregressive loss? I don't see any experimental results comparing the vanilla Transformer with Equation 3 in Table 1.

Authorsrebuttal2024-08-09

* No, we pick **all** negatives (in the current file). We experimented briefly with picking only hard/easy/random negatives, but this vanilla setting proved to work quite well. * No, it's trained using the exact same experimental setup, *i.e.*, premise-selection head and the modified infoNCE loss.

Reviewer xpMx2024-08-09

- **Supplement the baseline:** I see. Can you provide results from training a pre-trained model such as BERT in conjunction with Equation 3? Although the comparison may not be entirely fair, scaling the model from the this paper is also challenging, so the best approach is to combine it with an existing representation model. In the future, is it possible to scale up models designed with your architecture? - **Ablation study:** I suspect the model's performance comes from the position encoding. Could you provide an ablation study using a vanilla Transformer combined with binary-tree positional encoding[1] and Equation 3? **Reference:** [1]: Kogkalidis, K., Bernardy, J. P., & Garg, V. (2023). Algebraic Positional Encodings. arXiv preprint arXiv:2312.16045.

Authorsrebuttal2024-08-09

* It is not clear how to connect BERT with the current dataset/experimental setup, can you elaborate? We remind you that the experimental setup does not involve textual representations of any kind. * We have **already** provided this ablation; please inspect Table 1 (row: `- structured attention`), and paragraph `Ablations` in Section 5.2. As you say, a large part of the model gains are indeed due to the structured attention from the tree-structured positional encodings.

Reviewer xpMx2024-08-09

**Supplement the baseline:**: Considering the remarkable effect of this positional encoding[1], I would like to see whether it is possible to inject this structural bias by taking a pre-trained model like BERT and continuing the training using contrastive learning with this positional encoding. If possible, could you provide the experimental results of vanilla transformers combined with other positional encodings, such as Yarn[2] or RoPE[3]? **Reference:** [1]: Kogkalidis, K., Bernardy, J. P., & Garg, V. (2023). Algebraic Positional Encodings. arXiv preprint arXiv:2312.16045. [2]: YaRN: Efficient Context Window Extension of Large Language Models. [3]: Su, J., Ahmed, M., Lu, Y., Pan, S., Bo, W., & Liu, Y. (2024). Roformer: Enhanced transformer with rotary position embedding. Neurocomputing, 568, 127063.

Authorsrebuttal2024-08-09

We remark once more that our model is not directly compatible with or comparable to text-based LLMs (autoregressive, like GPT, or encoder-only, like BERT). The model does *not* operate on textual token sequences, but on complex structures made of a (really) small number of primitive symbols (namely: `Π`, `->`, `λ`, `@`, `Sort`, `Level`, `Literal`, `deBruijn`), plus references. That said, we can still attempt to train a YaRN-based sequential version, but from-scratch (rather than pretrained).

Authorsrebuttal2024-08-09

> `In the future, is it possible to scale up models designed with your architecture? ` We missed this one, sorry. The most honest answer is "it depends". There are projects ongoing, like Dedukti (see Conclusion), which attempt a common formalization interface/meta-language between different type-theory-based proof assistants. If/when such a project takes hold, and upon larger libraries becoming accessible, it would make sense to upscale the model. Until then, and for the time being, it is very likely that there's little benefits from model scaling given the current data availability. Otherwise, from an architectural perspective, there's nothing really stopping one from training larger (or smaller) variations of the proposed model.

Reviewer xpMx2024-08-09

**Scaling the model**: Given the slow growth of the Agda library and limitations of Dedukti , why not consider choosing Mathlib instead? It has a vast amount of data and mature methods for acquiring large datasets, such as [1], which make scaling easier. **Reference:** [1] Han, J. M., Rute, J., Wu, Y., Ayers, E. W., & Polu, S. (2021). Proof artifact co-training for theorem proving with language models. arXiv preprint arXiv:2102.06203.

Authorsrebuttal2024-08-09

That's a fair question -- the datasets used in the cited paper are all without exception **text-based**. We kindly ask you to inspect pages 17 - 20 of the linked paper, which present example datapoints. The data points presented are pretty-printed proofs (*i.e.*, strings), making them suitable for autoregressive language modeling. The data points we work with are *not* "strings that look like proofs" -- they are the "structural footprints of proofs". We explicitly refer to this this paper (in line 106), and compare their dataset extraction and modeling methodologies to ours (line 117+, and Section 4.2).

Authorsrebuttal2024-08-10

Hi again. We return with a **RoPE-based baseline**, as requested. | metric | stdlib[id] | stdlib[ood] | unimath | type-topo | | -------- | ----------- | -------------- | ---------- | ------------- | | AP | 22.56 | 12.83 | 18.00 |9.13 | | R@P | 11.74 | 8.95 | 8.33 |3.82 | | R@1 | 11.78 | 16.16 | 9.75 |3.22 | As you suggested, performance is **much better** than the vanilla sinusoidal positional encoding scheme. At the same time, it is still **much worse** than the tree-structured positional encoding we use (or any ablation, for that matter). Neither of the two observations is too surprising: * we know RoPE empirically outperforms sinusoidal encodings from the literature * RoPE is still a sequential encoding scheme; types are not sequences, and sequential models can't do them justice (section 4.2)

Authorsrebuttal2024-08-13

We address the limitations of hierarchical tree methods conceptually in lines 205-211. Practically, the papers you suggest are not suitable baselines due to their reliance on quadratic $O(n^2)$ attention, which is infeasible for our setup as discussed in lines 221-228. With lemma lengths ranging from $10^0$ to $10^4$ tokens and files counting $10^0$ to $10^3$ lemmas, quadratic attention results in $O(mn^2)$ complexity (for a batch size of 1), making it untenable. This is exactly why we chose a linear attention kernel (lines 233 - 248). While hierarchical tree and linear attention could be combined theoretically, no existing implementation that we know of exists. We sincerely apologize, because your suggested experiments are valid and interesting, but we cannot implement, train and evaluate such a mechanism within the 12 hours left before the discussion period closes. Please also keep in mind that training alone takes approximately 6-8 hours (assuming the compute resources are immediately available).

Reviewer 2Qh17/10 · confidence 2/52024-07-10

Summary

This paper is the first to extract data from Agda, a dependently typed programming language. The extracted data can be utilized by machine learning practitioners. Additionally, the paper proposes a novel neural structure designed to faithfully represent dependently typed programs. The experiments demonstrate the effectiveness of the proposed neural architecture.

Strengths

- The dataset extracted in this paper is the first based on the formal language Agda, which will significantly benefit the neural theorem proving community by providing more formal data. - The proposed neural representation structure performs very well compared to vanilla transformers, demonstrating strong ablation results. It offers a better inductive bias and completeness.

Weaknesses

I don’t see any major weaknesses in this paper, except that it is somewhat difficult to follow. It would definitely benefit from more illustrative figures to explain various concepts. Concepts in Agda, such as dynamic compilation, “holes,” typing contexts, and term structures, are hard to understand. Including figures with concrete examples of these components, in addition to textual descriptions, would be very helpful.

Questions

- Typos in line 162 `that that`.

Rating

7

Confidence

2

Soundness

3

Presentation

1

Contribution

3

Limitations

The authors have adequately addressed the limitations and posed no negative societal impact.

Reviewer ctFo6/10 · confidence 3/52024-07-10

Summary

The paper reported the creation of a new dataset to predict a term for filling the hole of a proof in Agda. The paper also proposed an attention-based neural architecture, trained it on the made dataset, and shows it outperforms the ordinary Transformer.

Strengths

+ Creating a new dataset for the problem of proof term predication on Agda. + The paper proposed an original attention-based model for proof term prediction and showed that it beaves more well than Transformer.

Weaknesses

- The importance of creating a new dataset could be discussed more appropriately and carefully. Specifically, I'd like to see why the dataset is necessary or valuable although there exist the datasets for automated theorem proving already (like the ones mentioned in the related work section and MiniF2F). I don't think it is sufficient just to say "there doesn't exist a dataset for Agda" because then one just could adopt the non-Agda datasets. - The experimental setting is unclear for me. Specifically, how is Transformer set up? Is it fine-tuned on the Agda dataset? If so, it is trained against the data in JSON format or text format? If the JSON format is adopted, I suspect it might be unfavorable for Transformer because it needs to parse JSON data by itself. - I'm unsure Transformer is appropriate as a baseline because, even if the models are restricted to be Transformer-based, there exist many previous works that claim their models outperform the vanilla Transformer as, e.g., the following [1] [1] Stanislas Polu, Ilya Sutskever: Generative Language Modeling for Automated Theorem Proving. CoRR abs/2009.03393 (2020). - The presentation could be improved. The following are unclear for me. - What is the outputs of the proposed model? An AST of a proof term? Or, just a text? - What is the design principles of the proposed model? Why did the authors think efficient and structured attention work well on the task of interest? - In Figure 3, what the x- and y-axis represent, respectively? - What is "the added cognitive load" mentioned in Section 5.2 (page 9)?

Questions

* Why is creating a dataset on Agda important? * Why did the paper choose the vanilla Transformer as a baseline? * Was the Transformer fine-tuned? If so, how?

Rating

6

Confidence

3

Soundness

2

Presentation

2

Contribution

3

Limitations

Certain limitations are described in the paper.

Reviewer ctFo2024-08-09

Thanks for the response. It resolves some of my concerns, especially the ones for the contributions on the dataset, so now I'm leaning towards acceptance. As a critical reviewer, I recommend the revision clarifies the contributions described in the response for the dataset, in the introduction. I couldn't find these contributions in the introduction of the submission, which prevents me from understanding the benefits of the new dataset compared with the existing ones (especially reading the related work section, which mentions the internal type structure as a difference, but what it means was unclear). The response says that, with the quote of lines 58 - 59, the contributions are mentioned in the introduction. Perhaps the crucial word in the lines is "program-proofs," but it is difficult, at least for me, to find that this phrase means that the dataset made by the paper is more structured (and in what sense) than the existing datasets. Furthermore, even after admitting the differences from the existing dataset, it is still not clear to me what the "subtype level" means. Does it mean what is called "inter-AST" in Section 4.2? In any case, it would be helpful to clarify what it means and clearly connect the contributions described in the introduction with the details in the remaining sections. >> I'm unsure Transformer is appropriate as a baseline because ... > Also a very good point, and one we ourselves make in Section 4.2 (lines 185 - 188). The vanilla Transformer, and all LLM-related endeavors suffer from exactly these biases, regardless of whether they are generative or encoder-only. This is why we think our work is an important alternative take: one that emphasizes structural discipline and tools fit for the task rather than tasks fit for the tool. I don't think this response addresses my concern of why only the vanilla LLM is used as a baseline and the other LLM-related models (claimed to better perform than the vanilla LLM) is not used.

Authorsrebuttal2024-08-09

Thank you for your engagement, and for revising your rejection. > ` ... "subtype level" .. ` Yes, that's correct! This is indeed one of the benefits of the extra structure. For example, consider the dependent type $\Pi_{x:A}(B~x)$, or in Agda syntax, `(x : A) -> B x`, which denotes a family of types `B` indexed by objects of type `A`. The dataset represents this as an AST that looks like: ``` DependentProduct |--- Argument | |--- Type: A (this would actually be an inter-AST pointer to the AST defining A) |--- Body |--- FunctionApplication |--- FunctionBody |--- Type: B (this would be an inter-AST pointer to the AST defining B) |--- FunctionArgument |--- @0 (this would be an intra-AST pointer to the Argument above) ``` This illustrates how structural relations are fully specified at the subtype level, all the way down to typing primitives. This is what allows the neural system to operate on a structural rather than textual level. Practically, our embedding layer only has the tiniest number of symbols (*i.e.*, only primitive type operators). Neural processing happens over complex structures made of these symbols. > `..LLM is used as a baseline and the other LLM-related models` We do not use a LLM. We use a (non-pretrained) tiny, customized Transformer made of 6 million parameters. This is **1000 times less** parameters than the LLMs that you cite and are currently in use (lines 563 - 566). The trained model is 26MB big. To make a fair architectural comparison, we compare against a Transformer of a similar size, because **this** is the architecture these LLMs rely on. Our comparison demonstrates that our model dramatically outperforms similarly sized Transformers. Comparing with overparameterized, closed-source, pretrained LLMs is beyond the scope of our work and offers no epistemic insights that we can think of. ---

Reviewer ctFo2024-08-09

Thanks for the clarification for the baseline. I'm not very convinced whether using a customized Transformer as a baseline is appropriate, but it would be helpful to describe in the main text the detail of the baseline and why it is used unless I missed an explanation in the main text of the submission.

Authorsrebuttal2024-08-09

You're very welcome! The model we revert to after all ablations in Table 1 is no longer customized -- it is basically a run-of-the-mill vanilla Transformer. It is a useful baseline exactly because: 1. it is the most common architecture empowering modern state of the art LLMs that find use in ATP tasks, and 2. it is what our model boils down to when we remove all of the task-adapted components

Reviewer XfNT7/10 · confidence 4/52024-07-11

Summary

This paper introduces a learning algorithm for Agda, a functional language used in proof assistance that is known for its dependent types. The paper includes the design of the algorithm, and an experimental evaluation,

Strengths

The Agda language has become very popular in the functional prog community, especially because of dependent types. This results in very structured programs. and I believe in a real challenge for ML. The authors design a relatively simple system to address this problem, but claim to achieve very interesting results. I believe that given the popularity of Agda and the results achieved, this is a solid contribution. The authors have a very clear writing style,

Weaknesses

The major weakness of the paper is that it assumes familiarity with Agda, The authors drop Figure 1 in the paper but make no effort to explain it. They assume the reader to know what are dependent types. One or two paragraphs would make a difference here. This makes it hard to understand the results (especially for non-experts like me). You define a positive to be an hole that is filled by a lemma in the proof? Does this mean that a hole/lemma pair could have been a positive, it just wasn´t considered? Also, is this for any proof? If this is a proof assistant, shouldn´t it be about a specific hole in a specific sequence of steps? , In B.1 you do mention scope and selecting a fixed number of holes. can you be more specific? Also how many positive and negative examples do you actually have It would also be interesting if we could have a baseline. say. are there comparable resuls for, say, Coq? Finally in "Practical' you seem to consider either Tree Based Models or Transformers. Any specific reason to ignore GNNs?

Questions

I mentioned above my main suggestions. Other details: Fig 1, please explain 1.1 universal: ie language that uses type theory as its foundational core. It would be nice to mention a few such languages? Page 6: it seems that the Taylor expansion is how you achieve global features, which seems to be goal here. Yet, later on you drop Taylot expansion and still obtain good results. J. Rute, M. Olsˇak, L. Blaauwbroek, F. I. S. Massolo, J. Piepenbrock, and V. Pestun. Graph2tac: ´ 442 Learning hierarchical representations of math concepts in theorem proving, 2024. 443 N -> Missing venue

Rating

7

Confidence

4

Soundness

3

Presentation

3

Contribution

4

Limitations

The authors do not see potential negative societal impact, and I would agree.

Reviewer xpMx2024-08-09

**Thank you for your response.** - I would like to know the details of how you construct multiple positive samples. - What does "negative pairs anchored to a common hole h" mean? Are the negative samples selected using the in-batch trick? - I would like to know if, as long as a suitable method for constructing positive and negative samples is used, the architecture becomes less important for the premise selection task, and a standard bidirectional encoder model can also be effective. I believe that a vanilla Transformer combined with a contrastive learning objective is also an important baseline.

Authorsrebuttal2024-08-10

Thanks once more for your engagement, we appreciate the ongoing discussion. You could certainly use a boolean mask to block out specific attention coefficients (*e.g.* you could attend to just "descendents" in the AST, or even something more elaborate), but it's not immediately clear whether this could faithfully capture the AST structure. Going for something more radical (*e.g.* attending to just some local neighborhood of nodes, given an appropriate definition of local) would result in the problems we attribute to GNNs (lines 211 - 217). Conceptually, this *should* also prove inadequate for capturing the long distance dependencies commonly found in "real life" dependent types (even though empirically this *could* also turn out not to be the case). Did you have something specific in mind? Is there some experiment that you'd like us to do along these lines (keeping the time window in mind, of course)

Reviewer XfNT2024-08-13

Thanks for the nice replies

Authorsrebuttal2024-08-13

Thank you for the nice questions :)

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC