Hanliang Zhang

Hanliang Zhang

Auto-generated profile, based on publicly available information

Hanliang Zhang

University of Bristol

Research Focus & Metrics

Academic Career Length

4Years (2023-Present)

(Calculated once Scilit publication data is synced: current year − year of first publication + 1)

Representative Publications

View All Publications
10 June 2025 in Proceedings of the ACM on Programming Languages
Verified
Journal Article
Open access
HZHanliang Zhang
Hanliang Zhang
CDCristina David
Cristina David
MWMeng Wang
Meng Wang
BPBrandon Paulsen
Brandon Paulsen
DKDaniel Kroening
Daniel Kroening
Large language models (LLMs) show promise in code translation due to their ability to generate idiomatic code. However, a significant limitation when using LLMs for code translation is scalability: existing works have shown a drop in translation success rates for code exceeding around 100 lines. We overcome this limitation by developing a modular approach to translation, where we partition the code into small code fragments which can be translated independently and semantically validated (that is, by checking I/O equivalence). When this approach is applied naively, we discover that LLMs are unreliable when translating features of the source language that do not have a direct mapping to the target language, and that the LLM often gets stuck in repair loops when attempting to fix errors. To address these issues, we introduce two key concepts: (1) feature mapping , which integrates predefined translation rules with LLM-based translation to guide the LLM in navigating subtle language differences and producing semantically accurate code; and (2) type-compatibility , which facilitates localized checks at the function signature level to detect errors early, thereby narrowing the scope of potential repairs. We apply our approach to translating real-world Go codebases to Rust, demonstrating that we can consistently generate reliable Rust translations for projects up to 9,700 lines of code and 780 functions, with an average of 73% of functions successfully validated for I/O equivalence, considerably higher than any existing work.

6 November 2023 in Journal of Functional Programming
Verified
Journal Article
Open access
PDF file
HZHanliang Zhang
Hanliang Zhang
WTWenhao Tang
Wenhao Tang
RXRuifeng Xie
Ruifeng Xie
MWMeng Wang
Meng Wang
ZHZhenjiang Hu
Zhenjiang Hu
Bidirectional transformations (BXs) are a mechanism for maintaining consistency between multiple representations of related data. The lens framework, which usually constructs BXs from lens combinators, has become the mainstream approach to BX programming because of its modularity and correctness by construction. However, the involved bidirectional behaviors of lenses make the equational reasoning and optimization of them much harder than unidirectional programs. We propose a novel approach to deriving efficient lenses from clear specifications via program calculation, a correct-by-construction approach to reasoning about functional programs by algebraic laws. To support bidirectional program calculation, we propose contract lenses , which extend conventional lenses with a pair of predicates to enable safe and modular composition of partial lenses. We define several contract-lens combinators capturing common computation patterns including $\textit{fold}, \textit{filter},\textit{map}$ , and $\textit{scan}$ , and develop several bidirectional calculation laws to reason about and optimize contract lenses. We demonstrate the effectiveness of our new calculation framework based on contract lenses with nontrivial examples.

11 December 2024 in arXiv
Verified
Preprint
Open access
PDF file
HZHanliang Zhang
Hanliang Zhang
CDCristina David
Cristina David
MWMeng Wang
Meng Wang
BPBrandon Paulsen
Brandon Paulsen
DKDaniel Kroening
Daniel Kroening
Large language models (LLMs) show promise in code translation due to their ability to generate idiomatic code. However, a significant limitation when using LLMs for code translation is scalability: existing works have shown a drop in translation success rates for code exceeding around 100 lines. We overcome this limitation by developing a modular approach to translation, where we partition the code into small code fragments which can be translated independently and semantically validated (that is, checking I/O equivalence). When this approach is applied naively, we discover that LLMs are unreliable when translating features of the source language that do not have a direct mapping to the target language, and that the LLM often gets stuck in repair loops when attempting to fix errors. To address these issues, we introduce two key concepts: (1) feature mapping, which integrates predefined translation rules with LLM-based translation to guide the LLM in navigating subtle language differences and producing semantically accurate code; and (2) type-compatibility, which facilitates localized checks at the function signature level to detect errors early, thereby narrowing the scope of potential repairs. We apply our approach to translating real-world Go codebases to Rust, demonstrating that we can consistently generate reliable Rust translations for projects up to 6,600 lines of code and 369 functions, with an average of 73% of functions successfully validated for I/O equivalence, considerably higher than any existing work.

1 April 2026
Verified
Book Chapter
Closed access
PDF file
CDCristina David
Cristina David
HZHanliang Zhang
Hanliang Zhang
MWMeng Wang
Meng Wang

1 September 2026 in IEEE Security & Privacy
Verified
Journal Article
Closed access
JHJaemin Hong
Jaemin Hong
KLKanguk Lee
Kanguk Lee
HZHanliang Zhang
Hanliang Zhang
HKHyunhee Kang
Hyunhee Kang
EKEunsu Kim
Eunsu Kim
ZSZhong Shao
Zhong Shao

23 June 2025
Verified
Conference Paper
Open access
CDCristina David
Cristina David
PKPascal Kesseli
Pascal Kesseli
DKDaniel Kroening
Daniel Kroening
HZHanliang Zhang
Hanliang Zhang