diff --git a/aeon/sugar/desugar.py b/aeon/sugar/desugar.py index b0661ace..cec16e43 100644 --- a/aeon/sugar/desugar.py +++ b/aeon/sugar/desugar.py @@ -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: diff --git a/aeon/synthesis_grammar/synthesizer.py b/aeon/synthesis_grammar/synthesizer.py index 6166e680..1f5315ca 100644 --- a/aeon/synthesis_grammar/synthesizer.py +++ b/aeon/synthesis_grammar/synthesizer.py @@ -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 @@ -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 @@ -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 diff --git a/examples/PSB2/annotations/multi_objective/bouncing_balls_lexicase_annotations.ae b/examples/PSB2/annotations/multi_objective/bouncing_balls.ae similarity index 100% rename from examples/PSB2/annotations/multi_objective/bouncing_balls_lexicase_annotations.ae rename to examples/PSB2/annotations/multi_objective/bouncing_balls.ae diff --git a/examples/PSB2/annotations/multi_objective/dice_game_lexicase_annotations.ae b/examples/PSB2/annotations/multi_objective/dice_game.ae similarity index 100% rename from examples/PSB2/annotations/multi_objective/dice_game_lexicase_annotations.ae rename to examples/PSB2/annotations/multi_objective/dice_game.ae diff --git a/examples/PSB2/annotations/multi_objective/gcd_lexicase_annotations.ae b/examples/PSB2/annotations/multi_objective/gcd.ae similarity index 100% rename from examples/PSB2/annotations/multi_objective/gcd_lexicase_annotations.ae rename to examples/PSB2/annotations/multi_objective/gcd.ae diff --git a/examples/PSB2/annotations/multi_objective/snow_day_lexicase_annotations.ae b/examples/PSB2/annotations/multi_objective/snow_day.ae similarity index 100% rename from examples/PSB2/annotations/multi_objective/snow_day_lexicase_annotations.ae rename to examples/PSB2/annotations/multi_objective/snow_day.ae diff --git a/examples/PSB2/annotations/multi_objective/square_digit_lexicase_annotations.ae b/examples/PSB2/annotations/multi_objective/square_digits.ae similarity index 100% rename from examples/PSB2/annotations/multi_objective/square_digit_lexicase_annotations.ae rename to examples/PSB2/annotations/multi_objective/square_digits.ae diff --git a/examples/PSB2/annotations/single_objective/bouncing_balls_annotations.ae b/examples/PSB2/annotations/single_objective/bouncing_balls.ae similarity index 100% rename from examples/PSB2/annotations/single_objective/bouncing_balls_annotations.ae rename to examples/PSB2/annotations/single_objective/bouncing_balls.ae diff --git a/examples/PSB2/annotations/single_objective/dice_game_annotations.ae b/examples/PSB2/annotations/single_objective/dice_game.ae similarity index 100% rename from examples/PSB2/annotations/single_objective/dice_game_annotations.ae rename to examples/PSB2/annotations/single_objective/dice_game.ae diff --git a/examples/PSB2/annotations/single_objective/gcd_annotations.ae b/examples/PSB2/annotations/single_objective/gcd.ae similarity index 100% rename from examples/PSB2/annotations/single_objective/gcd_annotations.ae rename to examples/PSB2/annotations/single_objective/gcd.ae diff --git a/examples/PSB2/annotations/single_objective/snow_day_annotations.ae b/examples/PSB2/annotations/single_objective/snow_day.ae similarity index 100% rename from examples/PSB2/annotations/single_objective/snow_day_annotations.ae rename to examples/PSB2/annotations/single_objective/snow_day.ae diff --git a/examples/PSB2/annotations/single_objective/square_digit_annotations.ae b/examples/PSB2/annotations/single_objective/square_digit.ae similarity index 100% rename from examples/PSB2/annotations/single_objective/square_digit_annotations.ae rename to examples/PSB2/annotations/single_objective/square_digit.ae diff --git a/libraries/Image.ae b/libraries/Image.ae index b242d871..a08e61c3 100644 --- a/libraries/Image.ae +++ b/libraries/Image.ae @@ -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; diff --git a/libraries/PSB2.ae b/libraries/PSB2.ae index 859d1bd1..82cf79a7 100644 --- a/libraries/PSB2.ae +++ b/libraries/PSB2.ae @@ -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]"; diff --git a/libraries/String.ae b/libraries/String.ae index ea171381..64c6f84d 100644 --- a/libraries/String.ae +++ b/libraries/String.ae @@ -1,4 +1,4 @@ -type Unit; +type List; def String_len : (i:String) -> Int = native "lambda i: len(i)"; diff --git a/requirements.pip b/requirements.pip index 29b7f9ea..c1e8dd7a 100644 --- a/requirements.pip +++ b/requirements.pip @@ -13,3 +13,5 @@ numpy argparse configparser multiprocess +pillow +scikit-image