Skip to content

Commit

Permalink
Merge pull request #42 from alcides/fix_synth
Browse files Browse the repository at this point in the history
Fix Synthesis process
  • Loading branch information
alcides authored Mar 5, 2024
2 parents 6b72a6c + df48f1c commit f5f42df
Show file tree
Hide file tree
Showing 16 changed files with 24 additions and 23 deletions.
4 changes: 2 additions & 2 deletions aeon/sugar/desugar.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,12 @@ def process_phrase(phrase: str) -> str:

def bind_program_to_rec(prog: Term, d: Definition) -> Term:
ty, body = d.type, d.body
def_name = f"__internal__{d.name}" if d.name in grammar.internal_functions else d.name
# def_name = f"__internal__{d.name}" if d.name in grammar.internal_functions else d.name
# body = rename_internal_functions(body)
for arg_name, arg_type in d.args[::-1]:
ty = AbstractionType(arg_name, arg_type, ty)
body = Abstraction(arg_name, body)
return Rec(def_name, ty, body, prog)
return Rec(d.name, ty, body, prog)


def handle_import(path: str) -> Program:
Expand Down
36 changes: 18 additions & 18 deletions aeon/synthesis_grammar/synthesizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@

import configparser
import multiprocess as mp
from aeon.backend.evaluator import EvaluationContext
from aeon.backend.evaluator import eval
from aeon.core.substitutions import substitution
from aeon.core.terms import Term, Literal, Var
from aeon.core.types import BaseType, Top
from aeon.core.types import Type
from aeon.core.types import top
from aeon.frontend.anf_converter import ensure_anf
from aeon.synthesis_grammar.grammar import (
gen_grammar_nodes,
get_grammar_node,
classType,
)
from aeon.synthesis_grammar.identification import get_holes_info, iterate_top_level
from aeon.synthesis_grammar.utils import fitness_function_name_for
from aeon.typechecking.context import TypingContext
from aeon.typechecking.typeinfer import check_type_errors
from geneticengine.algorithms.gp.individual import Individual
from geneticengine.algorithms.gp.simplegp import SimpleGP
from geneticengine.core.grammar import extract_grammar, Grammar
Expand All @@ -27,24 +44,6 @@
from geneticengine.core.representations.tree.treebased import TreeBasedRepresentation
from loguru import logger

from aeon.backend.evaluator import EvaluationContext
from aeon.backend.evaluator import eval
from aeon.core.substitutions import substitution
from aeon.core.terms import Term, Literal, Var
from aeon.core.types import BaseType, Top
from aeon.core.types import Type
from aeon.core.types import top
from aeon.frontend.anf_converter import ensure_anf
from aeon.synthesis_grammar.grammar import (
gen_grammar_nodes,
get_grammar_node,
classType,
)
from aeon.synthesis_grammar.identification import get_holes_info, iterate_top_level
from aeon.synthesis_grammar.utils import fitness_function_name_for
from aeon.typechecking.context import TypingContext
from aeon.typechecking.typeinfer import check_type_errors


class SynthesisError(Exception):
pass
Expand Down Expand Up @@ -326,6 +325,7 @@ def synthesize_single_function(
)

# Step 2 Create grammar object.
# TODO Synthesis: grammar should also receive metadata from the decorator
grammar = create_grammar(holes, fun_name)
hole_name = list(holes.keys())[0]
# TODO Synthesis: This function (and its parent) should be parameterized with the type of search procedure
Expand Down
1 change: 0 additions & 1 deletion libraries/Image.ae
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
type Color;
type Image;


def Color_r: (c:Color) -> Int = uninterpreted;
def Color_g: (c:Color) -> Int = uninterpreted;
def Color_b: (c:Color) -> Int = uninterpreted;
Expand Down
2 changes: 1 addition & 1 deletion libraries/PSB2.ae
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def join_string_list : (list: List) -> String = native "lambda xs: ' '.join(word
def get_bb_synth_values : (input : List) -> (f:(a: Float) ->( b:Float ) -> (c:Int) -> Float ) -> List = native " lambda inputs: lambda function: [function(x)(y)(z) for x, y, z in inputs]";

@ignore()
def get_dg_synth_values : (input : List) -> (f: (a:{n:Int | 1 <= n && n <= 10000}) ->( b:{m:Int | 1 <= m && m <= 10000} ) -> Float ) -> List = native " lambda inputs: lambda function: [function(x)(y) for x, y in inputs]";
def get_dg_synth_values : (input : List) -> (f: (a:Int) ->( b:Int ) -> Float ) -> List = native " lambda inputs: lambda function: [function(x)(y) for x, y in inputs]";

@ignore()
def get_fb_synth_values : (input : List) -> (f: (a: Int) -> String ) -> List = native " lambda inputs: lambda function: [function(x) for x in inputs]";
Expand Down
2 changes: 1 addition & 1 deletion libraries/String.ae
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
type Unit;
type List;

def String_len : (i:String) -> Int = native "lambda i: len(i)";

Expand Down
2 changes: 2 additions & 0 deletions requirements.pip
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ numpy
argparse
configparser
multiprocess
pillow
scikit-image

0 comments on commit f5f42df

Please sign in to comment.