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

Annotations refactor alternative? #18

Closed
wants to merge 340 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
340 commits
Select commit Hold shift + click to select a range
98a4f3d
fitness function bug fixed
eduardo-imadeira Jun 21, 2023
13b14fe
changed the way dataclass are created
eduardo-imadeira Jun 21, 2023
23badf0
get_core updated to work with If blocks
eduardo-imadeira Jun 27, 2023
d7b96fa
String lib added
eduardo-imadeira Jun 27, 2023
2b872a2
bouncing_balls.ae example updated
eduardo-imadeira Jun 27, 2023
d3d0bfa
dice_game.ae example updated
eduardo-imadeira Jun 27, 2023
4eb448d
fizz_buzz.ae example updated
eduardo-imadeira Jun 27, 2023
9ff6dfb
middle_char psb2 problem added
eduardo-imadeira Jun 27, 2023
c4ca2a2
snow_day.ae example updated
eduardo-imadeira Jun 27, 2023
830d86c
twitter psb2 problem added
eduardo-imadeira Jun 27, 2023
d3ca874
Merge branch 'master' into grammar_extraction
eduardo-imadeira Jun 29, 2023
1bfde38
added a space to keyword "in" in aeon sugar grammar
eduardo-imadeira Jun 29, 2023
fd90a66
fitness function changed to work with array of strings
eduardo-imadeira Jun 29, 2023
74333a5
bouncing_balls.ae psb2 example program synthesis ready
eduardo-imadeira Jun 29, 2023
3335c57
dice_game.ae psb2 example program synthesis ready
eduardo-imadeira Jun 29, 2023
450aa2c
fizz_buzz.ae psb2 example program synthesis ready
eduardo-imadeira Jun 29, 2023
1839cb4
middle_char.ae psb2 example program synthesis ready
eduardo-imadeira Jun 29, 2023
315c0e5
snow_day.ae psb2 example program synthesis ready, without refinements
eduardo-imadeira Jun 29, 2023
a3b40d0
twitter.ae psb2 example program synthesis ready
eduardo-imadeira Jun 29, 2023
577c4ce
PSB2 library added
eduardo-imadeira Jun 29, 2023
9480d32
grammar file clean up
eduardo-imadeira Jul 3, 2023
7889623
using aeon functions inside a native function
eduardo-imadeira Jul 3, 2023
139b80f
test native with aeon function added
eduardo-imadeira Jul 3, 2023
0c2612c
1st attempt to fitness func inside psb2 example
eduardo-imadeira Jul 3, 2023
a69489e
Added missing dependencies
alcides Jul 3, 2023
a61f5d4
PSB2 lib updated
eduardo-imadeira Jul 4, 2023
a8a6eab
psb2 example fitness func updated
eduardo-imadeira Jul 4, 2023
08853e4
Merge remote-tracking branch 'origin/grammar_extraction' into grammar…
eduardo-imadeira Jul 4, 2023
b1901d2
fitness evaluation in grammar.py updated
eduardo-imadeira Jul 4, 2023
1ef041b
fitness evaluation added to aeon files
eduardo-imadeira Jul 10, 2023
7a748e2
real eval parameter changed
eduardo-imadeira Jul 10, 2023
266fec7
psb2 lib fixed
eduardo-imadeira Jul 10, 2023
afb1c91
requirements.pip updated
eduardo-imadeira Jul 10, 2023
93c4eee
logger added
eduardo-imadeira Jul 10, 2023
55e01c6
parser clean up
eduardo-imadeira Jul 10, 2023
8cf0e3d
gitignore updated
eduardo-imadeira Jul 11, 2023
03fe6d1
constraint level added to logger
eduardo-imadeira Jul 11, 2023
93c9c53
psb2 lib bug fixed
eduardo-imadeira Jul 11, 2023
62bc4cc
logger message for constraints
eduardo-imadeira Jul 11, 2023
6e9297e
main clean up
eduardo-imadeira Jul 11, 2023
c7469da
infer_test fixed
eduardo-imadeira Jul 11, 2023
46137fe
main clean up
eduardo-imadeira Jul 11, 2023
7b63197
added the synthesizer class to a individual file
eduardo-imadeira Jul 12, 2023
58cce3f
gitignore updated
eduardo-imadeira Jul 13, 2023
fdd57f0
added __init__.py files to enable package import
eduardo-imadeira Jul 13, 2023
10e3b83
Configure setup to include .lark files
eduardo-imadeira Jul 13, 2023
d8f5fc2
genetic engine configuration moved to class synthesizer
eduardo-imadeira Jul 13, 2023
297496e
main updated
eduardo-imadeira Jul 13, 2023
954ab55
logger updated
eduardo-imadeira Jul 13, 2023
04a1ef8
synth_fitness_test.py updated
eduardo-imadeira Jul 13, 2023
90c4a78
synthesizer fitness function clean up
eduardo-imadeira Jul 13, 2023
9eee8d3
geneticengine config updated
eduardo-imadeira Jul 13, 2023
e2a9ab5
genetic engine config updated
eduardo-imadeira Jul 14, 2023
e1249bb
export log function signature updated
eduardo-imadeira Jul 14, 2023
2e46efb
create a csv directory to store geneticengine results
eduardo-imadeira Jul 14, 2023
4178a98
Merge branch 'master' into grammar_extraction
alcides Jul 17, 2023
b7adae0
Merge remote-tracking branch 'origin/grammar_extraction' into grammar…
eduardo-imadeira Jul 17, 2023
68a69f9
PSB2 lib updated
eduardo-imadeira Jul 17, 2023
8ea2d99
create class components with abstraction type variables
eduardo-imadeira Jul 17, 2023
cf8277d
Refactor grammar.py for readability
eduardo-imadeira Jul 17, 2023
706daa6
pre-commit run --all-files
eduardo-imadeira Jul 17, 2023
daec1b7
remove print if log is not setup
eduardo-imadeira Jul 18, 2023
bac63b2
1st attempt to support lexicase
eduardo-imadeira Jul 21, 2023
bb9a7ce
refactor get_problem_type to avoid code duplication
eduardo-imadeira Jul 21, 2023
ac2ec02
Reorder python imports
eduardo-imadeira Jul 21, 2023
61fe3d4
get_holes_info renamed to get_holes_info_and_fitness_type
eduardo-imadeira Jul 21, 2023
c8c1108
aeon sugar grammar updated
eduardo-imadeira Jul 25, 2023
e21c372
aeon core grammar updated
eduardo-imadeira Jul 25, 2023
147cfde
example idea of using minimize annotations
eduardo-imadeira Jul 25, 2023
d00ae94
minimize and maximize terms added
eduardo-imadeira Jul 25, 2023
9147415
expression_min and expression_max added to parser
eduardo-imadeira Jul 25, 2023
0d206f6
test files fixed
eduardo-imadeira Jul 25, 2023
5fd58f6
aeon sugar grammar updated to support multi objective problems
eduardo-imadeira Jul 31, 2023
2cb4555
grammar syntax updated
eduardo-imadeira Jul 31, 2023
a872bcb
MultiObjectiveProblem term added
eduardo-imadeira Jul 31, 2023
deca7da
parser support to multiobjective problem added
eduardo-imadeira Jul 31, 2023
4047431
parser expression_min_max updated
eduardo-imadeira Aug 2, 2023
9272204
grammar updated, added soft_refinement_t
eduardo-imadeira Aug 2, 2023
f0547e4
SoftRefinedType added to types
eduardo-imadeira Aug 2, 2023
6f5df6f
added soft_refined_t to parser
eduardo-imadeira Aug 2, 2023
15dca5c
removed soft refinements from core grammar
eduardo-imadeira Aug 2, 2023
abf1e7e
sugar parser updated to support soft refinements
eduardo-imadeira Aug 2, 2023
15be5f3
SoftRefinedType structure updated
eduardo-imadeira Aug 3, 2023
d05e528
soft_refined_t updated in parser.py
eduardo-imadeira Aug 3, 2023
bc0f8de
refactor fitness related function to fitness.py file
eduardo-imadeira Aug 3, 2023
77c77f9
handle SoftRefinedType in desugar
eduardo-imadeira Aug 3, 2023
e8832c5
sugar grammar updated
eduardo-imadeira Aug 9, 2023
197592a
Macro Node added and Definitions args updated
eduardo-imadeira Aug 9, 2023
93b748e
sugar parser updated
eduardo-imadeira Aug 9, 2023
9126f74
unnecessary terms deleted
eduardo-imadeira Aug 9, 2023
4057675
SoftRefinedType deleted
eduardo-imadeira Aug 9, 2023
1230363
examples updated
eduardo-imadeira Aug 9, 2023
da78e81
examples updated
eduardo-imadeira Aug 24, 2023
46ad050
def_fun in sugar parser updated
eduardo-imadeira Aug 24, 2023
ab2aa22
file name changed, fitness.py to fitness_aux.py
eduardo-imadeira Aug 24, 2023
5620018
Fitness class created
eduardo-imadeira Aug 24, 2023
d7c4513
annotations module added
eduardo-imadeira Aug 24, 2023
c55e836
extract fitness from the annotations before definition desugaring
eduardo-imadeira Aug 24, 2023
106c7ee
__main__.py updated to work with annotations
eduardo-imadeira Aug 24, 2023
0c7d6fd
desugar return bug fixed
eduardo-imadeira Aug 24, 2023
a4e3b32
Refactor __main__.py for improved readability
eduardo-imadeira Aug 24, 2023
f2797fd
first attempt of supporting multi_maximize and multi_minimize
eduardo-imadeira Aug 28, 2023
f09774d
sugar grammar updated
eduardo-imadeira Aug 29, 2023
11672f5
Macro dataclass updated
eduardo-imadeira Aug 29, 2023
b5f1ff5
Refactor desugar function for improved readability
eduardo-imadeira Aug 29, 2023
5b4c6b3
Update sugar grammar to allow multiple expressions in soft_constraints
eduardo-imadeira Aug 30, 2023
295a723
sugar parser updated and Macro Object Updated
eduardo-imadeira Aug 30, 2023
1ca5916
better assertion message added
eduardo-imadeira Aug 30, 2023
3a3b464
Fitness Object Updated
eduardo-imadeira Aug 30, 2023
b21f23f
Refactor fitness extraction from a definition
eduardo-imadeira Aug 30, 2023
d452e1f
handle imports bug fixed
eduardo-imadeira Aug 30, 2023
9adcbfc
Simplify fitness extraction in desugar.py
eduardo-imadeira Aug 30, 2023
8572a39
Refactor term annotations to accept lists of terms
eduardo-imadeira Aug 30, 2023
3ea6046
bouncing_balls_lexicase_annotations.ae example updated
eduardo-imadeira Aug 30, 2023
1a03f9f
Refactor annotations for improved readability
eduardo-imadeira Aug 31, 2023
063522d
first example of property based testing added
eduardo-imadeira Sep 12, 2023
7e815b5
property based testing lib added
eduardo-imadeira Sep 12, 2023
30f4685
prop testing lib updated, forallints and forallfloats added
eduardo-imadeira Sep 13, 2023
367f719
property test file updated
eduardo-imadeira Sep 13, 2023
68b03fa
Merge branch 'property_testing' into annotations
eduardo-imadeira Sep 15, 2023
35aa7e3
deleted Fitness object
eduardo-imadeira Sep 15, 2023
ab9aa20
recursive imports handled
eduardo-imadeira Sep 15, 2023
4a69fd2
bug in updating ctx with uninterpreted funcs fixed
eduardo-imadeira Sep 15, 2023
5758765
property annotation added
eduardo-imadeira Sep 15, 2023
659bf89
property annotation example added
eduardo-imadeira Sep 15, 2023
51a1a99
transform abstraction into strongly typed abstraction in annotations
eduardo-imadeira Sep 18, 2023
dd167cb
refactor annotations_aux.py
eduardo-imadeira Sep 18, 2023
bed28bc
refactor annotations_aux.py
eduardo-imadeira Sep 18, 2023
87ecd5f
Merge remote-tracking branch 'origin/annotations' into annotations
eduardo-imadeira Sep 19, 2023
65770be
multiple properties annotation example added
eduardo-imadeira Sep 19, 2023
33f4916
annotations_aux.py clean up
eduardo-imadeira Sep 19, 2023
5e5b58b
first attempt of handling @properties annotation
eduardo-imadeira Sep 19, 2023
5ba7e46
refactor annotations_aux.py
eduardo-imadeira Sep 19, 2023
5e75011
_transform_to_aeon_list initialization of the aeon list bug fixed
eduardo-imadeira Sep 20, 2023
4235351
ensure that the extracted fitness is anf
eduardo-imadeira Sep 25, 2023
179ed11
prioritize an existing fitness function over annotations
eduardo-imadeira Sep 26, 2023
5d9dad3
PSB2 examples with annotations added
eduardo-imadeira Sep 26, 2023
589a737
merge master into annotations
eduardo-imadeira Sep 26, 2023
b3e880a
tests fixed
eduardo-imadeira Sep 26, 2023
aa1bc39
added args to mypy in github action
eduardo-imadeira Sep 26, 2023
23b6f99
mypy errors fixed
eduardo-imadeira Sep 26, 2023
04064d6
mypy errors fixed
eduardo-imadeira Sep 26, 2023
b6ad944
Merge remote-tracking branch 'origin/annotations' into annotations
eduardo-imadeira Sep 26, 2023
f870457
mypy errors fixed
eduardo-imadeira Sep 26, 2023
d131ef2
Merge remote-tracking branch 'origin/annotations' into annotations
eduardo-imadeira Sep 26, 2023
1441366
mypy errors fixed
eduardo-imadeira Sep 26, 2023
3d35dfe
requirements updated
eduardo-imadeira Sep 26, 2023
c3d8860
Removed options from main.
alcides Sep 27, 2023
b253318
More Review
alcides Sep 27, 2023
d07eabe
docstring added to synthesize method
eduardo-imadeira Sep 28, 2023
f3d5409
optional synthesis csv
eduardo-imadeira Sep 28, 2023
11fab14
single imports bug fixed
eduardo-imadeira Oct 3, 2023
7b24cfd
get_problem_type fixed
eduardo-imadeira Oct 3, 2023
8325559
docstring added to decorators files
eduardo-imadeira Oct 3, 2023
a152de5
Fixed mypy error
alcides Oct 3, 2023
ec11e7b
property based testing decorators name changed
eduardo-imadeira Oct 3, 2023
3eae78e
Merge remote-tracking branch 'origin/annotations' into annotations
eduardo-imadeira Oct 3, 2023
cd21910
type error in evaluating single objective problems solved
eduardo-imadeira Oct 3, 2023
bce097a
sugar example added
eduardo-imadeira Oct 3, 2023
11b4cee
dice_game examples modified
eduardo-imadeira Oct 3, 2023
13968a2
type error in evaluating single objective problems solved
eduardo-imadeira Oct 3, 2023
afa7a05
remove assert in synthesizer
eduardo-imadeira Oct 3, 2023
dcc5a24
sugar examples updated
eduardo-imadeira Oct 3, 2023
dcee111
psb2 annotations folder added
eduardo-imadeira Oct 6, 2023
55e43d5
decorators handling updated
eduardo-imadeira Oct 6, 2023
5df5d20
extract_fitness_from_synth method updated
eduardo-imadeira Oct 6, 2023
a4a9aca
minimize_flag to objectives_list in desugar.py
eduardo-imadeira Oct 6, 2023
49ec1d6
get_holes_info_and_fitness_type method to get_holes_info
eduardo-imadeira Oct 6, 2023
3a20437
get_holes_info test updated
eduardo-imadeira Oct 6, 2023
12df694
synthesizer updated to work with the objectives dict
eduardo-imadeira Oct 6, 2023
e1b8940
minimize_flag substituted with objectives_list in main
eduardo-imadeira Oct 6, 2023
d6600dd
tests fixed
eduardo-imadeira Oct 6, 2023
d841e23
Macro Class renamed to Decorator
eduardo-imadeira Oct 6, 2023
9ea149d
support to multiple holes
eduardo-imadeira Oct 9, 2023
bbbc35f
synth_fitness_test.py fixed
eduardo-imadeira Oct 11, 2023
a0d0f6d
logger level bug fixed
eduardo-imadeira Oct 11, 2023
fe432f6
Add docstrings and refactor function names for readability
eduardo-imadeira Oct 11, 2023
1887603
evaluate_fitness function test added
eduardo-imadeira Oct 11, 2023
f0ff2b2
WIP
alcides Oct 13, 2023
fe10b85
Fixed typing bugs
alcides Oct 13, 2023
579daff
Moved hole management
alcides Oct 13, 2023
c1e8e97
Moved hole management
alcides Oct 13, 2023
1479faf
Added tests for hole identification
alcides Oct 13, 2023
ad26d93
More synthesize work
alcides Oct 13, 2023
a6ea0f3
Work in Progress: Type errors. Let us try to merge with polytypes first
alcides Oct 16, 2023
46b5ea0
Added TODO about multiobjective
alcides Oct 17, 2023
8205519
Liquid variable lookup is reversed
alcides May 31, 2023
2a3ca84
Removed repeated ANF conversion
alcides Oct 17, 2023
a80fd68
Fixed ANF conversion places
alcides Oct 17, 2023
14cc4a4
Synthesizing directly from representation
alcides Oct 17, 2023
f80daf5
Minor refactoring
alcides Oct 17, 2023
45a9116
Bumped GeneticEngine
alcides Oct 17, 2023
93a1555
Added TODO for multiple procedures
alcides Oct 17, 2023
e1c1e35
Merge branch 'master' into annotations_refactor
alcides Oct 17, 2023
e706239
Fixed import
alcides Oct 17, 2023
575df59
Merge branch 'master' into annotations_refactor
alcides Oct 17, 2023
98b98ab
simple_synthesis example updated
eduardo-imadeira Nov 10, 2023
9ffab78
synthesizer clean up
eduardo-imadeira Nov 10, 2023
e336118
function to print grammar nodes added
eduardo-imadeira Nov 10, 2023
e69ec6b
preventing the declaration of types with special characters
eduardo-imadeira Nov 13, 2023
90a86cb
control flow grammar nodes for all types
eduardo-imadeira Nov 14, 2023
783950d
removing hole's function from the ctx of that hole
eduardo-imadeira Nov 14, 2023
901c172
get_core method bug fixed
eduardo-imadeira Nov 15, 2023
8a03a05
Merge branch 'annotations_refactor' of github.com:alcides/aeon into a…
alcides Nov 15, 2023
0e85dc6
pretty print added for prelude operations
eduardo-imadeira Nov 16, 2023
07534b9
test for pprint prelude ops added
eduardo-imadeira Nov 16, 2023
d75e5b2
unnecessary method deleted
eduardo-imadeira Nov 17, 2023
56f7075
black code formatter aeon/synthesis_grammar
eduardo-imadeira Nov 19, 2023
5007a93
forcing the type of If objects generated by grammar
eduardo-imadeira Nov 19, 2023
836094d
minimize_float decorator added
eduardo-imadeira Nov 20, 2023
d5dfa9b
synth let bug fixed
eduardo-imadeira Nov 22, 2023
65f37a8
PSB2 examples decorators updated
eduardo-imadeira Nov 23, 2023
3865006
exclude arithmetic operators from type_free_term_vars
eduardo-imadeira Nov 23, 2023
a1eff2c
SYNTHESIZER level added to logger
eduardo-imadeira Nov 23, 2023
b1a421e
Annotated all objected generated by the grammar
eduardo-imadeira Nov 23, 2023
e24b6da
removed ?main hole information from get_holes_info function
eduardo-imadeira Nov 23, 2023
527d975
black formatter
eduardo-imadeira Nov 23, 2023
b822019
synthesizer bugs fixed
eduardo-imadeira Nov 23, 2023
dc1cc78
refactor prelude ops
eduardo-imadeira Nov 28, 2023
7935f5a
pretty_print_term forcing the type of the abstractions
eduardo-imadeira Nov 28, 2023
56c09f3
logger remove sys.stderr
eduardo-imadeira Nov 28, 2023
e2d43f6
multi_minimize_float decorator added
eduardo-imadeira Nov 29, 2023
a712bd3
requirements.pip updated
eduardo-imadeira Nov 29, 2023
74ef802
remove annotation of the object generated by the grammar
eduardo-imadeira Nov 29, 2023
d97ff8b
examples updated
eduardo-imadeira Nov 30, 2023
914bddc
added SYNTH_TYPE level to logger
eduardo-imadeira Nov 30, 2023
04d0b46
timeout add to evaluator
eduardo-imadeira Dec 4, 2023
4cb4710
add config parser for geneticengine parameters
eduardo-imadeira Dec 5, 2023
b83442d
add default config for geneticengine
eduardo-imadeira Dec 5, 2023
aa75b25
get default config moved to synthesizer
eduardo-imadeira Dec 6, 2023
2190365
add config name to csv name
eduardo-imadeira Dec 6, 2023
ea69962
requirements.pip updated
eduardo-imadeira Dec 14, 2023
60ec12b
config parser updated
eduardo-imadeira Dec 14, 2023
2a49fe8
config parser updated
eduardo-imadeira Dec 14, 2023
18c89e5
config parser updated
eduardo-imadeira Dec 14, 2023
7756f2f
Merge remote-tracking branch 'origin/annotations_refactor' into annot…
eduardo-imadeira Dec 15, 2023
84efbc3
removed dill from pyproject.toml
eduardo-imadeira Dec 15, 2023
9dcd002
output csv updated
eduardo-imadeira Dec 15, 2023
79781f8
csv callbacks updated
eduardo-imadeira Dec 15, 2023
a80413c
transform nans into ERROR_FITNESS
eduardo-imadeira Dec 21, 2023
e3e1e5e
multi objective psb2 problems added
eduardo-imadeira Jan 22, 2024
74b9624
synthesizer ready for multi objective problems
eduardo-imadeira Jan 22, 2024
bf2c35f
filter_nan_values refactored
eduardo-imadeira Jan 22, 2024
8253acd
simple synthesis example updated
eduardo-imadeira Jan 23, 2024
2484c78
pprint term test on hold
eduardo-imadeira Jan 30, 2024
67708e2
psb2 library updated
eduardo-imadeira Jan 30, 2024
5eeaf83
square digits examples bug fixed
eduardo-imadeira Jan 30, 2024
a077624
synthesizer.py updated
eduardo-imadeira Jan 30, 2024
984332c
synth fitness test fixed
eduardo-imadeira Feb 2, 2024
fd80d9c
Merge branch 'annotations_refactor' of github.com:alcides/aeon into a…
alcides Feb 7, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
if [ -f requirements.pip ]; then pip install -r requirements.pip; fi
- name: Lint with mypy
run: |
mypy aeon
mypy aeon --no-strict-optional --ignore-missing-imports
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",
"python.formatting.provider": "none",
"python.linting.mypyEnabled": true,
"python.linting.enabled": true,
"files.watcherExclude": {
"**/target": true
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}
92 changes: 76 additions & 16 deletions aeon/__main__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
from __future__ import annotations

import argparse
import sys

from aeon.backend.evaluator import eval
from aeon.backend.evaluator import EvaluationContext
from aeon.backend.evaluator import eval
from aeon.core.types import top
from aeon.decorators import apply_decorators
from aeon.frontend.anf_converter import ensure_anf
from aeon.frontend.parser import parse_term
from aeon.logger.logger import export_log
from aeon.logger.logger import setup_logger
from aeon.prelude.prelude import evaluation_vars
from aeon.prelude.prelude import typing_vars
from aeon.sugar.desugar import desugar
from aeon.sugar.parser import parse_program
from aeon.sugar.program import Program
from aeon.typechecking.typeinfer import check_and_log_type_errors
from aeon.synthesis_grammar.identification import incomplete_functions_and_holes
from aeon.synthesis_grammar.synthesizer import synthesize, parse_config
from aeon.typechecking.typeinfer import check_type_errors
from aeon.utils.ctx_helpers import build_context
from aeon.logger.logger import setup_logger, export_log


def parse_arguments():
Expand All @@ -25,9 +31,16 @@ def parse_arguments():
"--log",
nargs="+",
default="",
help="set log level: \nTRACE \nDEBUG \nINFO \nTYPECHECKER \nCONSTRAINT " "\nWARNINGS \nERROR \nCRITICAL",
help="""set log level: \nTRACE \nDEBUG \nINFO \nWARNINGS \nTYPECHECKER \nSYNTH_TYPE \nCONSTRAINT \nSYNTHESIZER
\nERROR \nCRITICAL""",
)
parser.add_argument("-f", "--logfile", action="store_true", help="export log file")

parser.add_argument("-csv", "--csv-synth", action="store_true", help="export synthesis csv file")

parser.add_argument("-gp", "--gp-config", help="path to the GP configuration file")

parser.add_argument("-csec", "--config-section", help="section name in the GP configuration file")
return parser.parse_args()


Expand All @@ -36,14 +49,23 @@ def read_file(filename: str) -> str:
return file.read()


def process_code(core: bool, code: str) -> tuple:
if core:
context = build_context(typing_vars)
evaluation_ctx = EvaluationContext(evaluation_vars)
return parse_term(code), context, evaluation_ctx
else:
prog: Program = parse_program(code)
return desugar(prog)
def apply_decorators_in_program(p: Program) -> Program:
"""We apply the decorators meta-programming code to each definition in the program."""
new_definitions = []
for definition in p.definitions:
new_def, other_defs = apply_decorators(definition)
new_definitions.append(new_def)
new_definitions.extend(other_defs)
return Program(p.imports, p.type_decls, new_definitions)


def log_type_errors(errors: list[Exception | str]):
logger.log("TYPECHECKER", "-------------------------------")
logger.log("TYPECHECKER", "+ Type Checking Error +")
for error in errors:
logger.log("TYPECHECKER", "-------------------------------")
logger.log("TYPECHECKER", error)
logger.log("TYPECHECKER", "-------------------------------")


if __name__ == "__main__":
Expand All @@ -52,8 +74,46 @@ def process_code(core: bool, code: str) -> tuple:
export_log(args.log, args.logfile, args.filename)

aeon_code = read_file(args.filename)
p, ctx, ectx = process_code(args.core, aeon_code)
logger.info(p)

if not check_and_log_type_errors (ctx, p, top):
eval(p, ectx)
if args.core:
typing_ctx = build_context(typing_vars)
evaluation_ctx = EvaluationContext(evaluation_vars)
core_ast = parse_term(aeon_code)
else:
prog: Program = parse_program(aeon_code)
prog = apply_decorators_in_program(prog)
(
core_ast,
typing_ctx,
evaluation_ctx,
) = desugar(prog)
logger.info(core_ast)

core_ast_anf = ensure_anf(core_ast)
type_errors = check_type_errors(typing_ctx, core_ast_anf, top)
if type_errors:
log_type_errors(type_errors)
sys.exit(1)

incomplete_functions: list[tuple[str, list[str]]] = incomplete_functions_and_holes(typing_ctx, core_ast_anf)

if incomplete_functions:
filename = args.filename if args.csv_synth else None
synth_config = (
parse_config(args.gp_config, args.config_section) if args.gp_config and args.config_section else None
)

synthesis_result = synthesize(
typing_ctx,
evaluation_ctx,
core_ast_anf,
incomplete_functions,
filename,
synth_config,
)
print(f"Best solution:{synthesis_result}")
# print()
# pretty_print_term(ensure_anf(synthesis_result, 200))
sys.exit(1)

eval(core_ast, evaluation_ctx)
Empty file added aeon/backend/__init__.py
Empty file.
8 changes: 7 additions & 1 deletion aeon/backend/evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def get(self, name: str):
return self.variables[name]


def is_native_var(t: Application):
return isinstance(t.fun, Var) and t.fun.name == "native"


# pattern match term
def eval(t: Term, ctx: EvaluationContext = EvaluationContext()):
if isinstance(t, Literal):
Expand All @@ -45,7 +49,9 @@ def eval(t: Term, ctx: EvaluationContext = EvaluationContext()):
elif isinstance(t, Application):
f = eval(t.fun, ctx)
arg = eval(t.arg, ctx)
e = f(arg)
# e = real_eval(arg, __globals=ctx.variables) if is_native_var(t) else f(arg)
e = real_eval(arg, ctx.variables) if is_native_var(t) else f(arg)

if isinstance(t.fun, Var) and t.fun.name == "native_import":
globals()[arg] = e
return e
Expand Down
9 changes: 9 additions & 0 deletions aeon/bindings/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import math

import numpy as np
from PIL import Image
from PIL.ImageDraw import Draw
from skimage.metrics import mean_squared_error as mse

from aeon.bindings.binding_utils import curried

Expand All @@ -25,3 +27,10 @@ def Image_draw_rectangle(im, x, y, w, h, c):
def Image_diff(im1, im2):
s = sum((a - b) ** 2 for a, b in zip(im1.histogram(), im2.histogram()))
return math.sqrt(s)


@curried
def Image_diff_mse(im1, im2):
im1 = np.array(im1)
im2 = np.array(im2)
return mse(im1, im2)
Empty file added aeon/core/__init__.py
Empty file.
6 changes: 2 additions & 4 deletions aeon/core/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def term_label_dist(s1: str, s2: str):


def distance_terms(t1: Term, t2: Term):
return zss.simple_distance(t1, t2, term_children, term_label,
term_label_dist)
return zss.simple_distance(t1, t2, term_children, term_label, term_label_dist)


def pairwise_distance(ts: list[Term]):
Expand All @@ -66,7 +65,6 @@ def term_depth(t: Term):
elif isinstance(t, Let):
return 1 + max(term_depth(t.var_value), term_depth(t.body))
elif isinstance(t, If):
return 1 + max(term_depth(t.cond), term_depth(t.then),
term_depth(t.otherwise))
return 1 + max(term_depth(t.cond), term_depth(t.then), term_depth(t.otherwise))
else:
return 1
13 changes: 4 additions & 9 deletions aeon/core/liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,12 @@ def __repr__(self):
return f"{self.value}".lower()

def __eq__(self, other):
return isinstance(other,
LiquidLiteralBool) and other.value == self.value
return isinstance(other, LiquidLiteralBool) and other.value == self.value

def __hash__(self) -> int:
return hash(self.value)



class LiquidLiteralInt(LiquidTerm):
value: int

Expand All @@ -68,8 +66,7 @@ def __repr__(self):
return f"{self.value}"

def __eq__(self, other):
return isinstance(other,
LiquidLiteralInt) and other.value == self.value
return isinstance(other, LiquidLiteralInt) and other.value == self.value

def __hash__(self) -> int:
return hash(self.value)
Expand All @@ -85,8 +82,7 @@ def __repr__(self):
return f"{self.value}"

def __eq__(self, other):
return isinstance(other,
LiquidLiteralFloat) and other.value == self.value
return isinstance(other, LiquidLiteralFloat) and other.value == self.value

def __hash__(self) -> int:
return hash(self.value)
Expand All @@ -102,8 +98,7 @@ def __repr__(self):
return f"{self.value}"

def __eq__(self, other):
return isinstance(other,
LiquidLiteralString) and other.value == self.value
return isinstance(other, LiquidLiteralString) and other.value == self.value

def __hash__(self) -> int:
return hash(self.value)
Expand Down
5 changes: 5 additions & 0 deletions aeon/core/liquid_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
("/", ("Int", "Int", "Int")),
("-", ("Int", "Int", "Int")),
("%", ("Int", "Int", "Int")),
("*.", ("Float", "Float", "Float")),
("+.", ("Float", "Float", "Float")),
("/.", ("Float", "Float", "Float")),
("-.", ("Float", "Float", "Float")),
("%.", ("Float", "Float", "Float")),
("!", ("Bool", "Bool")),
]

Expand Down
98 changes: 97 additions & 1 deletion aeon/core/pprint.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
from __future__ import annotations

from aeon.core.liquid import LiquidLiteralBool
from aeon.core.terms import (
Abstraction,
Annotation,
Application,
Hole,
If,
Let,
Literal,
Rec,
Term,
TypeAbstraction,
TypeApplication,
Var,
)
from aeon.core.types import AbstractionType
from aeon.core.types import BaseType
from aeon.core.types import RefinedType
from aeon.core.types import Type
from aeon.core.types import type_free_term_vars
from aeon.core.types import TypeVar
from aeon.core.types import type_free_term_vars
from aeon.synthesis_grammar.grammar import aeon_prelude_ops_to_text


def pretty_print(t: Type) -> str:
Expand All @@ -28,3 +43,84 @@ def pretty_print(t: Type) -> str:
else:
return f"{{{t.name}:{it} | {t.refinement}}}"
assert False


def pretty_print_term(term: Term):
term_str: str = custom_preludes_ops_representation(term)[0]
print(term_str)


ops_to_abstraction: dict[str, str] = {
"%": "Int) -> Int",
"/": "Int) -> Int",
"*": "Int) -> Int",
"-": "Int) -> Int",
"+": "Int) -> Int",
"%.": "Float) -> Float",
"/.": "Float) -> Float",
"*.": "Float) -> Float",
"-.": "Float) -> Float",
"+.": "Float) -> Float",
">=": "Int) -> Bool",
">": "Int) -> Bool",
"<=": "Int) -> Bool",
"<": "Int) -> Bool",
"!=": "Int) -> Bool",
"==": "Int) -> Bool",
}


def custom_preludes_ops_representation(term: Term, counter: int = 0) -> tuple[str, int]:
prelude_operations: dict[str, str] = aeon_prelude_ops_to_text
match term:
case Application(fun=Var(name=var_name), arg=arg) if var_name in prelude_operations.keys():
op = var_name
arg_str, counter = custom_preludes_ops_representation(arg, counter)
counter += 1
new_var_name = f"__{prelude_operations[op]}_{counter}__"
abstraction_type_str = f"({new_var_name}:{ops_to_abstraction[op]}"
personalized_op = f": {abstraction_type_str} = (\\{new_var_name} -> {arg_str} {op} {new_var_name})"
return personalized_op, counter

case Application(fun=fun, arg=arg):
fun_str, counter = custom_preludes_ops_representation(fun, counter)
arg_str, counter = custom_preludes_ops_representation(arg, counter)
return f"= ({fun_str} {arg_str})", counter

case Annotation(expr=expr, type=type):
expr_str, counter = custom_preludes_ops_representation(expr, counter)
return f"({expr_str} : {type})", counter

case Abstraction(var_name=var_name, body=body):
body_str, counter = custom_preludes_ops_representation(body, counter)
return f"(\\{var_name} -> {body_str})", counter

case Let(var_name=var_name, var_value=var_value, body=body):
var_value_prefix = "= " if not isinstance(var_value, Application) else ""
var_value_str, counter = custom_preludes_ops_representation(var_value, counter)
body_str, counter = custom_preludes_ops_representation(body, counter)
return f"(let {var_name} {var_value_prefix}{var_value_str} in\n {body_str})", counter

case Rec(var_name=var_name, var_type=var_type, var_value=var_value, body=body):
var_value_str, counter = custom_preludes_ops_representation(var_value, counter)
body_str, counter = custom_preludes_ops_representation(body, counter)
return f"(let {var_name} : {var_type} = {var_value_str} in\n {body_str})", counter

case If(cond=cond, then=then, otherwise=otherwise):
cond_str, counter = custom_preludes_ops_representation(cond, counter)
then_str, counter = custom_preludes_ops_representation(then, counter)
otherwise_str, counter = custom_preludes_ops_representation(otherwise, counter)
return f"(if {cond_str} then {then_str} else {otherwise_str})", counter

case TypeAbstraction(name=name, kind=kind, body=body):
body_str, counter = custom_preludes_ops_representation(body, counter)
return f"ƛ{name}:{kind}.({body_str})", counter

case TypeApplication(body=body, type=type):
body_str, counter = custom_preludes_ops_representation(body, counter)
return f"({body_str})[{type}]", counter

case Literal(_, _) | Var(_) | Hole(_):
return str(term), counter

return str(term), counter
Loading
Loading