Program synthesis -- the automatic generation of code given a specification -- is one of the most fundamental tasks in artificial intelligence (AI) and many programmers' dream. Numerous synthesizers have been developed to tackle program synthesis, manifesting different ideas to approach the exponentially growing program space. While numerous smart program synthesis tools exist, reusing and remixing previously developed methods is tedious and time-consuming. We propose Herb.jl, a unifying program synthesis library written in the Julia programming language, to address these issues. Since current methods rely on similar building blocks, we aim to modularize the underlying synthesis algorithm into communicating and fully extendable sub-compartments, allowing for straightforward reapplication of these modules. To demonstrate the benefits of using Herb.jl, we show three common use cases: 1. how to implement a simple problem and grammar, and how to solve it, 2. how to implement a previously developed synthesizer with just a few lines of code, and 3. how to run a synthesizer against a benchmark.
프로그램 합성(주어진 명세에 따라 자동으로 코드를 생성하는 것)은 인공지능의 가장 기본적인 작업 중 하나이며, 많은 프로그래머의 꿈이기도 합니다. 지수적으로 증가하는 프로그램 공간을 처리하기 위해 수많은 지능형 프로그램 합성 도구가 개발되었지만, 기존 방법의 재사용과 재조합은 번거롭고 시간이 많이 소요됩니다. 본 논문은 이러한 문제를 해결하기 위해 Julia 프로그래밍 언어로 작성된 통합 프로그램 합성 라이브러리인 Herb.jl을 제시합니다. 기존 방법들이 유사한 구성 요소에 의존하기 때문에, 저자들은 기저 합성 알고리즘을 상호 통신 가능하고 완전히 확장 가능한 하위 구성 요소로 모듈화하여 이러한 모듈을 직접 재적용할 수 있도록 하는 것을 목표로 합니다.
# 입출력 명세 정의
problem = Problem([
IOExample(Dict(:x => 0), 1),
IOExample(Dict(:x => 1), 3),
IOExample(Dict(:x => 2), 5),
IOExample(Dict(:x => 3), 7)
])
# 문법 정의
grammar = @cfgrammar begin
Int = 1 | 2 | x
Int = Int + Int
Int = Int * Int
end
# 검색 실행
iterator = BFSIterator(grammar, :Int, max_depth=5)
solution, flag = synth(problem, iterator)
using HerbBenchmarks
pairs = get_all_problem_grammar_pairs(PBE_SLIA_Track_2019)
solved_problems = 0
for (problem, grammar) in pairs
solution = probe(grammar, :Start, problem; max_depth=5)
if !isnothing(solution)
solved_problems += 1
end
end