Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Probe Implementation #5

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ name = "Garden"
uuid = "22d0bc84-1826-4aaf-b584-c2a6a91114a2"
version = "0.1.0"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Herb = "c09c6b7f-4f63-49de-90d9-97a3563c0f4a"

[compat]
julia = "^1.8"
6 changes: 5 additions & 1 deletion src/Garden.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module Garden

greet() = print("Hello World!")
using DocStringExtensions
using Herb

include("probe/method.jl")
export probe, decide_probe, modify_grammar_probe

end # module Garden
17 changes: 17 additions & 0 deletions src/probe/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Probe

[Publication (Open Access)](https://doi.org/10.1145/3428295)

```
@article{DBLP:journals/pacmpl/BarkePP20,
author = {Shraddha Barke and
Hila Peleg and
Nadia Polikarpova},
title = {Just-in-time learning for bottom-up enumerative synthesis},
journal = {Proc. {ACM} Program. Lang.},
volume = {4},
number = {{OOPSLA}},
pages = {227:1--227:29},
year = {2020}
}
```
56 changes: 56 additions & 0 deletions src/probe/method.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Herb.HerbCore: AbstractRuleNode, AbstractGrammar
using Herb.HerbSpecification: AbstractSpecification, Problem
using Herb.HerbSearch: ProgramIterator

"""
$(TYPEDSIGNATURES)

Decide whether to keep a program, or discard it, based on the specification.
"""
function decide_probe(
program::AbstractRuleNode,
spec::AbstractSpecification
)::Bool end

"""
$(TYPEDSIGNATURES)

Modify the grammar based on the programs kept during the `decide` step.
"""
function modify_grammar_probe(
saved_programs::AbstractVector{<:AbstractRuleNode},
grammar::AbstractGrammar
)::AbstractGrammar end

"""
$(TYPEDSIGNATURES)

Synthesize a program using the `grammar` that follows the `spec` following the method from
["Just-in-time learning for bottom-up enumerative synthesis"](https://doi.org/10.1145/3428295).
```
"""
function probe(
iterator::ProgramIterator,
grammar::AbstractGrammar,
spec::Problem,
budget::Int,
max_total_iterations::Int;
kwargs...
)::AbstractRuleNode

# - Run a budgeted search
# - Gets an iterator with some limit (the low-level budget)
# - This is a normal iterator
# - Collect (partial) successes
# - Function to define success, which is just % of examples solved by default
# - Function takes any kind of specification
# - Boolean output: should the program be saved or not?
# - Modify the grammar
# - Function to modify the grammar based on the successes
# - Takes the successes (saved programs)
# - Modify the grammar: in place or return a new one, TBD
# - Rinse and repeat
# - Function defining high-level budget
# - For now, just a parameter defining the number of overall runs of budgeted search

end
11 changes: 11 additions & 0 deletions src/probe/ref.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@article{DBLP:journals/pacmpl/BarkePP20,
author = {Shraddha Barke and
Hila Peleg and
Nadia Polikarpova},
title = {Just-in-time learning for bottom-up enumerative synthesis},
journal = {Proc. {ACM} Program. Lang.},
volume = {4},
number = {{OOPSLA}},
pages = {227:1--227:29},
year = {2020}
}
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Herb = "c09c6b7f-4f63-49de-90d9-97a3563c0f4a"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ using JET
@testset "Code linting (JET.jl)" begin
JET.test_package(Garden; target_defined_modules = true)
end
# Write your tests here.
for (root, dirs, files) in walkdir(@__DIR__)
for file in filter(contains(r"test_"), files)
include(file)
end
end
end
21 changes: 21 additions & 0 deletions test/test_probe.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Herb.HerbGrammar: @cfgrammar
using Herb.HerbSearch: BFSIterator
using Herb.HerbSpecification: IOExample, Problem

@testset "Probe" begin
grammar = @cfgrammar begin
Int = Int + Int
Int = 1 | 2
end
problem = Problem(
[IOExample(Dict(), 2)]
)
result = probe(
BFSIterator,
grammar,
problem,
10,
20
)
@test !isnothing(result)
end
Loading