Ejemplo n.º 1
0
def reducedConcatPrimitives():
    #uses strConcat!!
    #[Primitive("empty_string", arrow(tpregex, tpregex), PRC(pregex.String("")))
    #] + [
    return [
        Primitive("string_" + i, arrow(tpregex, tpregex), PRC(
            pregex.String(i)))
        for i in printable[:-4] if i not in disallowed_list
    ] + [
        Primitive("string_" + name, arrow(tpregex, tpregex),
                  PRC(pregex.String(char))) for char, name in disallowed
    ] + [
        Primitive("r_dot", arrow(tpregex, tpregex), PRC(pregex.dot)),
        Primitive("r_d", arrow(tpregex, tpregex), PRC(pregex.d)),
        Primitive("r_s", arrow(tpregex, tpregex), PRC(pregex.s)),
        #Primitive("r_w", arrow(tpregex, tpregex), PRC(pregex.w)),
        Primitive("r_l", arrow(tpregex, tpregex), PRC(pregex.l)),
        Primitive("r_u", arrow(tpregex, tpregex), PRC(pregex.u)),
        #todo
        Primitive("r_kleene",
                  arrow(arrow(tpregex, tpregex), arrow(tpregex, tpregex)),
                  PRC(pregex.KleeneStar, 1)),
        #Primitive("r_plus", arrow(arrow(tpregex, tpregex), arrow(tpregex,tpregex)), PRC(pregex.Plus,1)),
        #Primitive("r_maybe", arrow(arrow(tpregex, tpregex), arrow(tpregex,tpregex)), PRC(pregex.Maybe,1)),
        Primitive(
            "r_alt",
            arrow(arrow(tpregex, tpregex), arrow(tpregex, tpregex),
                  arrow(tpregex, tpregex)), PRC(pregex.Alt, 2)),
    ] + [Primitive("r_const", arrow(tpregex, tpregex), None)]
Ejemplo n.º 2
0
def easyWordsPrimitives():
    return [
        Primitive("string_" + i, tpregex, pregex.String(i))
        for i in printable[10:62] if i not in disallowed_list
    ] + [
        Primitive("r_d", tpregex, pregex.d),
        Primitive("r_s", tpregex, pregex.s),
        #Primitive("r_w", tpregex, pregex.w),
        Primitive("r_l", tpregex, pregex.l),
        Primitive("r_u", tpregex, pregex.u),
        Primitive("r_kleene", arrow(tpregex, tpregex), _kleene),
        Primitive("r_plus", arrow(tpregex, tpregex), _plus),
        Primitive("r_maybe", arrow(tpregex, tpregex), _maybe),
        Primitive("r_alt", arrow(tpregex, tpregex, tpregex), _alt),
        Primitive("r_concat", arrow(tpregex, tpregex, tpregex), _concat),
    ]
Ejemplo n.º 3
0
def McCarthyPrimitives():
    "These are ~ primitives provided by 1959 lisp as introduced by McCarthy"
    return [
        Primitive("empty", tlist(t0), []),
        Primitive("cons", arrow(t0, tlist(t0), tlist(t0)), _cons),
        Primitive("car", arrow(tlist(t0), t0), _car),
        Primitive("cdr", arrow(tlist(t0), tlist(t0)), _cdr),
        Primitive("empty?", arrow(tlist(t0), tbool), _isEmpty),
        #Primitive("unfold", arrow(t0, arrow(t0,t1), arrow(t0,t0), arrow(t0,tbool), tlist(t1)), _isEmpty),
        #Primitive("1+", arrow(tint,tint),None),
        # Primitive("range", arrow(tint, tlist(tint)), range),
        # Primitive("map", arrow(arrow(t0, t1), tlist(t0), tlist(t1)), _map),
        # Primitive("index", arrow(tint,tlist(t0),t0),None),
        # Primitive("length", arrow(tlist(t0),tint),None),
        primitiveRecursion1,
        primitiveRecursion2,
        Primitive("if", arrow(tbool, t0, t0, t0), _if),
        Primitive("eq?", arrow(tint, tint, tbool), _eq),
        Primitive("+", arrow(tint, tint, tint), _addition),
        Primitive("-", arrow(tint, tint, tint), _subtraction),
    ] + [Primitive(str(j), tint, j) for j in xrange(2)]
Ejemplo n.º 4
0
def matchEmpericalNoLetterPrimitives(corpus):
    return lambda: [Primitive("empty_string", tpregex, pregex.String(""))] + [
        Primitive("string_" + i, tpregex, pregex.String(i))
        for i in printable[:-4]
        if i not in disallowed_list + list(printable[10:62])
    ] + [
        Primitive("string_" + name, tpregex, pregex.String(char))
        for char, name in disallowed
    ] + [
        Primitive("r_dot", tpregex, emp_dot_no_letter(corpus)),
        Primitive("r_d", tpregex, emp_d(corpus)),
        Primitive("r_s", tpregex, pregex.s),
        Primitive("r_kleene", arrow(tpregex, tpregex), _kleene),
        #Primitive("r_plus", arrow(tpregex, tpregex), _plus),
        #Primitive("r_maybe", arrow(tpregex, tpregex), _maybe),
        Primitive("r_alt", arrow(tpregex, tpregex, tpregex), _alt),
        Primitive("r_concat", arrow(tpregex, tpregex, tpregex), _concat),
    ]
Ejemplo n.º 5
0
def algolispPrimitives():
    return [
    Primitive("fn_call", arrow(tfunction, tlist(tsymbol), tsymbol), _fn_call),

    Primitive("lambda1_call", arrow(tfunction, tlist(tsymbol), tsymbol), lambda f: lambda sx: ["lambda1", [f] + sx] if type(sx)==list else ["lambda1", [f] + [sx]] ),
    Primitive("lambda2_call", arrow(tfunction, tlist(tsymbol), tsymbol), lambda f: lambda sx: ["lambda2", [f] + sx] if type(sx)==list else ["lambda2", [f] + [sx]] ),
    #symbol converters:
    # SYMBOL = constant | argument | function_call | function | lambda
    Primitive("symbol_constant", arrow(tconstant, tsymbol), lambda x: x),
    Primitive("symbol_function", arrow(tfunction, tsymbol), lambda x: x),
    #list converters
    Primitive('list_init_symbol', arrow(tsymbol, tlist(tsymbol)), lambda symbol: [symbol] ),
    Primitive('list_add_symbol', arrow(tsymbol, tlist(tsymbol), tlist(tsymbol)), lambda symbol: lambda symbols: symbols + [symbol] if type(symbols) == list else [symbols] + [symbol])
    ] + [
    #functions:
    Primitive(ec_name, tfunction, algo_name) for algo_name, ec_name in fn_lookup.items()
    ] + [
    #Constants
    Primitive(ec_name, tconstant, algo_name) for algo_name, ec_name in const_lookup.items()
    ]
Ejemplo n.º 6
0
def no_length():
    """this is the primitives without length because one of the reviewers wanted this"""
    return [p for p in bootstrapTarget() if p.name != "length"] + [
        Primitive("*", arrow(tint, tint, tint), _multiplication),
        Primitive("mod", arrow(tint, tint, tint), _mod),
        Primitive("gt?", arrow(tint, tint, tbool), _gt),
        Primitive("eq?", arrow(tint, tint, tbool), _eq),
        Primitive("is-prime", arrow(tint, tbool), _isPrime),
        Primitive("is-square", arrow(tint, tbool), _isSquare),
    ]
Ejemplo n.º 7
0
def bootstrapTarget_extra():
    """This is the bootstrap target plus list domain specific stuff"""
    return bootstrapTarget() + [
        Primitive("*", arrow(tint, tint, tint), _multiplication),
        Primitive("mod", arrow(tint, tint, tint), _mod),
        Primitive("gt?", arrow(tint, tint, tbool), _gt),
        Primitive("eq?", arrow(tint, tint, tbool), _eq),
        Primitive("is-prime", arrow(tint, tbool), _isPrime),
        Primitive("is-square", arrow(tint, tbool), _isSquare),
    ]
Ejemplo n.º 8
0
def basePrimitives():
    return [Primitive(str(j), tint, j) for j in xrange(6)] + [
        Primitive("*", arrow(tint, tint, tint), _multiplication),
        Primitive("gt?", arrow(tint, tint, tbool), _gt),
        Primitive("is-prime", arrow(tint, tbool), _isPrime),
        Primitive("is-square", arrow(tint, tbool), _isSquare),
        # McCarthy
        Primitive("empty", tlist(t0), []),
        Primitive("cons", arrow(t0, tlist(t0), tlist(t0)), _cons),
        Primitive("car", arrow(tlist(t0), t0), _car),
        Primitive("cdr", arrow(tlist(t0), tlist(t0)), _cdr),
        Primitive("empty?", arrow(tlist(t0), tbool), _isEmpty),
        Primitive("if", arrow(tbool, t0, t0, t0), _if),
        Primitive("eq?", arrow(tint, tint, tbool), _eq),
        Primitive("+", arrow(tint, tint, tint), _addition),
        Primitive("-", arrow(tint, tint, tint), _subtraction)
    ]
Ejemplo n.º 9
0
def primitives():
    return [Primitive(str(j), tint, j) for j in xrange(6)] + [
        Primitive("empty", tlist(t0), []),
        Primitive("singleton", arrow(t0, tlist(t0)), _single),
        Primitive("range", arrow(tint, tlist(tint)), range),
        Primitive("++", arrow(tlist(t0), tlist(t0), tlist(t0)), _append),
        # Primitive("map", arrow(arrow(t0, t1), tlist(t0), tlist(t1)), _map),
        Primitive("mapi", arrow(arrow(tint, t0, t1), tlist(t0), tlist(t1)),
                  _mapi),
        # Primitive("reduce", arrow(arrow(t1, t0, t1), t1, tlist(t0), t1), _reduce),
        Primitive("reducei", arrow(arrow(tint, t1, t0, t1), t1, tlist(t0), t1),
                  _reducei),
        Primitive("true", tbool, True),
        Primitive("not", arrow(tbool, tbool), _not),
        Primitive("and", arrow(tbool, tbool, tbool), _and),
        Primitive("or", arrow(tbool, tbool, tbool), _or),
        # Primitive("if", arrow(tbool, t0, t0, t0), _if),
        Primitive("sort", arrow(tlist(tint), tlist(tint)), sorted),
        Primitive("+", arrow(tint, tint, tint), _addition),
        Primitive("*", arrow(tint, tint, tint), _multiplication),
        Primitive("negate", arrow(tint, tint), _negate),
        Primitive("mod", arrow(tint, tint, tint), _mod),
        Primitive("eq?", arrow(tint, tint, tbool), _eq),
        Primitive("gt?", arrow(tint, tint, tbool), _gt),
        Primitive("is-prime", arrow(tint, tbool), _isPrime),
        Primitive("is-square", arrow(tint, tbool), _isSquare),

        # these are achievable with above primitives, but unlikely
        #Primitive("flatten", arrow(tlist(tlist(t0)), tlist(t0)), _flatten),
        ## (lambda (reduce (lambda (lambda (++ $1 $0))) empty $0))
        Primitive("sum", arrow(tlist(tint), tint), sum),
        # (lambda (lambda (reduce (lambda (lambda (+ $0 $1))) 0 $0)))
        Primitive("reverse", arrow(tlist(t0), tlist(t0)), _reverse),
        # (lambda (reduce (lambda (lambda (++ (singleton $0) $1))) empty $0))
        Primitive("all", arrow(arrow(t0, tbool), tlist(t0), tbool), _all),
        # (lambda (lambda (reduce (lambda (lambda (and $0 $1))) true (map $1 $0))))
        Primitive("any", arrow(arrow(t0, tbool), tlist(t0), tbool), _any),
        # (lambda (lambda (reduce (lambda (lambda (or $0 $1))) true (map $1 $0))))
        Primitive("index", arrow(tint, tlist(t0), t0), _index),
        # (lambda (lambda (reducei (lambda (lambda (lambda (if (eq? $1 $4) $0 0)))) 0 $0)))
        Primitive("filter", arrow(arrow(t0, tbool), tlist(t0), tlist(t0)),
                  _filter),
        # (lambda (lambda (reduce (lambda (lambda (++ $1 (if ($3 $0) (singleton $0) empty)))) empty $0)))
        #Primitive("replace", arrow(arrow(tint, t0, tbool), tlist(t0), tlist(t0), tlist(t0)), _replace),
        ## (FLATTEN (lambda (lambda (lambda (mapi (lambda (lambda (if ($4 $1 $0) $3 (singleton $1)))) $0)))))
        Primitive("slice", arrow(tint, tint, tlist(t0), tlist(t0)), _slice),
        # (lambda (lambda (lambda (reducei (lambda (lambda (lambda (++ $2 (if (and (or (gt? $1 $5) (eq? $1 $5)) (not (or (gt? $4 $1) (eq? $1 $4)))) (singleton $0) empty))))) empty $0))))
    ]
Ejemplo n.º 10
0
        return fix(argument)

    return inner


def curry(f):
    return lambda x: lambda y: f((x, y))


def _fix2(a1):
    return lambda a2: lambda body: \
        _fix((a1,a2))(lambda r: lambda (n,l): body(curry(r))(n)(l))


primitiveRecursion1 = Primitive("fix1",
                                arrow(t0, arrow(arrow(t0, t1), t0, t1), t1),
                                _fix)

primitiveRecursion2 = Primitive(
    "fix2", arrow(t0, t1, arrow(arrow(t0, t1, t2), t0, t1, t2), t2), _fix2)


def _match(l):
    return lambda b: lambda f: b if l == [] else f(l[0])(l[1:])


def primitives():
    return [Primitive(str(j), tint, j) for j in xrange(6)] + [
        Primitive("empty", tlist(t0), []),
        Primitive("singleton", arrow(t0, tlist(t0)), _single),
        Primitive("range", arrow(tint, tlist(tint)), range),
Ejemplo n.º 11
0
           lambda v4: \
           "(integrate" + \
           " " + v1 + \
           " " + v2 + \
           " " + v3 + \
           " " + v4 + \
           ")"
def _repeat(p):
    return "(repeat " + p + ")"
def _concat(p1):
    return lambda p2: "(concat " + p1 + " " + p2 + ")"


primitives = [
    # VAR
    Primitive("var_unit", tvar, "var_unit"),
    Primitive("var_double", arrow(tvar, tvar), _var_double),
    Primitive("var_half", arrow(tvar, tvar), _var_half),
    Primitive("var_next", arrow(tvar, tvar), _var_next),
    Primitive("var_prev", arrow(tvar, tvar), _var_prev),
    Primitive("var_opposite", arrow(tvar, tvar), _var_opposite),
    Primitive("var_name", tvar, "var_name"),

    # PROGRAMS
    Primitive("embed", arrow(tprogram, tprogram), _embed),
    Primitive("define", arrow(tvar, tprogram), _define),
    Primitive("integrate",
              arrow(tmaybe(tvar),
                    tmaybe(tbool),
                    tmaybe(tvar),
                    # tmaybe(tvar),
Ejemplo n.º 12
0
def OldDeepcoderPrimitives():
    return [
        Primitive("head", arrow(tlist(tint), tint), _head),
        Primitive("tail", arrow(tlist(tint), tint), _tail),
        Primitive("take", arrow(tint, tlist(tint), tlist(tint)), _take),
        Primitive("drop", arrow(tint, tlist(tint), tlist(tint)), _drop),
        Primitive("access", arrow(tint, tlist(tint), tint), _access),
        Primitive("minimum", arrow(tlist(tint), tint), _minimum),
        Primitive("maximum", arrow(tlist(tint), tint), _maximum),
        Primitive("reverse", arrow(tlist(tint), tlist(tint)), _reverse),
        Primitive("sort", arrow(tlist(tint), tlist(tint)), _sort),
        Primitive("sum", arrow(tlist(tint), tint), _sum)
    ] + [
        Primitive("map", arrow(int_to_int, tlist(tint), tlist(tint)),
                  _map),  #is this okay???
        Primitive("filter", arrow(int_to_bool, tlist(tint), tlist(tint)),
                  _filter),  #is this okay???
        Primitive("count", arrow(int_to_bool, tlist(tint), tint),
                  _count),  #is this okay???
        Primitive(
            "zipwith",
            arrow(int_to_int_to_int, tlist(tint), tlist(tint), tlist(tint)),
            _zipwith),  #is this okay???
        Primitive("scanl1", arrow(int_to_int_to_int, tlist(tint), tlist(tint)),
                  _scanl1),  #is this okay???
        # ] + [
        # Primitive("succ", arrow(tint, tint), _succ),
        # Primitive("pred", arrow(tint, tint), _pred),
        # Primitive("double", arrow(tint, tint), _double),
        # Primitive("half", arrow(tint, tint), _half),
        # Primitive("neg", arrow(tint, tint), _neg),
        # Primitive("square", arrow(tint, tint), _square),
        # Primitive("triple", arrow(tint, tint), _triple),
        # Primitive("third", arrow(tint, tint), _third),
        # Primitive("quad", arrow(tint, tint), _quad),
        # Primitive("quarter", arrow(tint, tint), _quarter),
        # ] + [
        # Primitive("pos", arrow(tint, tbool), _pos),
        # Primitive("neg", arrow(tint, tbool), _neg),
        # Primitive("even", arrow(tint, tbool), _even),
        # Primitive("odd", arrow(tint, tbool), _odd),
        # ] + [
        # Primitive("add", arrow(tint, tint, tint), _add),
        # Primitive("sub", arrow(tint, tint, tint), _sub),
        # Primitive("mult", arrow(tint, tint, tint), _mult),
        # Primitive("min", arrow(tint, tint, tint), _min),
        # Primitive("max", arrow(tint, tint, tint), _max)
    ] + [
        Primitive("succ_fn", int_to_int, _succ),
        Primitive("pred_fn", int_to_int, _pred),
        Primitive("double_fn", int_to_int, _double),
        Primitive("half_fn", int_to_int, _half),
        Primitive("negate_fn", int_to_int, _negate),
        Primitive("square_fn", int_to_int, _square),
        Primitive("triple_fn", int_to_int, _triple),
        Primitive("third_fn", int_to_int, _third),
        Primitive("quad_fn", int_to_int, _quad),
        Primitive("quarter_fn", int_to_int, _quarter),
    ] + [
        Primitive("pos_fn", int_to_bool, _pos),
        Primitive("neg_fn", int_to_bool, _neg),
        Primitive("even_fn", int_to_bool, _even),
        Primitive("odd_fn", int_to_bool, _odd),
    ] + [
        Primitive("add_fn", int_to_int_to_int, _add),
        Primitive("sub_fn", int_to_int_to_int, _sub),
        Primitive("mult_fn", int_to_int_to_int, _mult),
        Primitive("min_fn", int_to_int_to_int, _min),
        Primitive("max_fn", int_to_int_to_int, _max)
    ]
Ejemplo n.º 13
0
        return fix(argument)

    return inner


def curry(f):
    return lambda x: lambda y: f((x, y))


def _fix2(a1):
    return lambda a2: lambda body: \
        _fix((a1, a2))(lambda r: lambda n_l: body(curry(r))(n_l[0])(n_l[1]))


primitiveRecursion1 = Primitive("fix1",
                                arrow(t0, arrow(arrow(t0, t1), t0, t1), t1),
                                _fix)

primitiveRecursion2 = Primitive(
    "fix2", arrow(t0, t1, arrow(arrow(t0, t1, t2), t0, t1, t2), t2), _fix2)


def _match(l):
    return lambda b: lambda f: b if l == [] else f(l[0])(l[1:])


def primitives():
    return [Primitive(str(j), tint, j) for j in range(6)] + [
        Primitive("empty", tlist(t0), []),
        Primitive("singleton", arrow(t0, tlist(t0)), _single),
        Primitive("range", arrow(tint, tlist(tint)), _range),
Ejemplo n.º 14
0
def basePrimitives():
    return [Primitive("string_" + i, tpregex, pregex.String(i)) for i in printable[:-4] if i not in disallowed_list
    ] + [
    Primitive("string_" + name, tpregex, pregex.String(char)) for char, name in disallowed
    ] + [	
    	Primitive("r_dot", tpregex, pregex.dot),
        Primitive("r_d", tpregex, pregex.d),
        Primitive("r_s", tpregex, pregex.s),
        Primitive("r_w", tpregex, pregex.w),
        Primitive("r_l", tpregex, pregex.l),
        Primitive("r_u", tpregex, pregex.u),
        Primitive("r_kleene", arrow(tpregex, tpregex), _kleene),
        Primitive("r_plus", arrow(tpregex, tpregex), _plus),
        Primitive("r_maybe", arrow(tpregex, tpregex), _maybe),
        Primitive("r_alt", arrow(tpregex, tpregex, tpregex), _alt),
        Primitive("r_concat", arrow(tpregex, tpregex, tpregex), _concat),
    ]
Ejemplo n.º 15
0
def concatPrimitives():
    return [
        Primitive("string_" + i, arrow(tpregex, tpregex), PRC(
            pregex.String(i)))
        for i in printable[:-4] if i not in disallowed_list
    ] + [
        Primitive("string_" + name, arrow(tpregex, tpregex),
                  PRC(pregex.String(char))) for char, name in disallowed
    ] + [
        Primitive("r_dot", arrow(tpregex, tpregex), PRC(pregex.dot)),
        Primitive("r_d", arrow(tpregex, tpregex), PRC(pregex.d)),
        Primitive("r_s", arrow(tpregex, tpregex), PRC(pregex.s)),
        Primitive("r_w", arrow(tpregex, tpregex), PRC(pregex.w)),
        Primitive("r_l", arrow(tpregex, tpregex), PRC(pregex.l)),
        Primitive("r_u", arrow(tpregex, tpregex), PRC(pregex.u)),
        #todo
        Primitive("r_kleene",
                  arrow(arrow(tpregex, tpregex), arrow(tpregex, tpregex)),
                  PRC(pregex.KleeneStar, 1)),
        Primitive("r_plus",
                  arrow(arrow(tpregex, tpregex), arrow(tpregex, tpregex)),
                  PRC(pregex.Plus, 1)),
        Primitive("r_maybe",
                  arrow(arrow(tpregex, tpregex), arrow(tpregex, tpregex)),
                  PRC(pregex.Maybe, 1)),
        Primitive(
            "r_alt",
            arrow(arrow(tpregex, tpregex), arrow(tpregex, tpregex),
                  arrow(tpregex, tpregex)), PRC(pregex.Alt, 2)),
    ]
Ejemplo n.º 16
0
def bootstrapTarget():
    """These are the primitives that we hope to learn from the bootstrapping procedure"""
    return [
        # learned primitives
        Primitive("map", arrow(arrow(t0, t1), tlist(t0), tlist(t1)), _map),
        Primitive(
            "unfold",
            arrow(t0, arrow(t0, tbool), arrow(t0, t1), arrow(t0, t0),
                  tlist(t1)), _unfold),
        Primitive("range", arrow(tint, tlist(tint)), _range),
        Primitive("index", arrow(tint, tlist(t0), t0), _index),
        Primitive("fold", arrow(tlist(t0), t1, arrow(t0, t1, t1), t1), _fold),
        Primitive("length", arrow(tlist(t0), tint), len),

        # built-ins
        Primitive("if", arrow(tbool, t0, t0, t0), _if),
        Primitive("+", arrow(tint, tint, tint), _addition),
        Primitive("-", arrow(tint, tint, tint), _subtraction),
        Primitive("empty", tlist(t0), []),
        Primitive("cons", arrow(t0, tlist(t0), tlist(t0)), _cons),
        Primitive("car", arrow(tlist(t0), t0), _car),
        Primitive("cdr", arrow(tlist(t0), tlist(t0)), _cdr),
        Primitive("empty?", arrow(tlist(t0), tbool), _isEmpty),
    ] + [Primitive(str(j), tint, j) for j in range(2)]
Ejemplo n.º 17
0
from program import Primitive, Program
from listPrimitives import _map, _unfold, _range, _index, _fold, _if, _addition, _subtraction, _cons, _car, _cdr, _isEmpty, bootstrapTarget
from arithmeticPrimitives import addition
from type import arrow, baseType, t0, t1, tint, tlist, tbool

turtle = baseType("turtle")
tstate = baseType("tstate")
tangle = baseType("tangle")
tlength = baseType("tlength")

primitives = [
    Primitive("logo_UA", tangle, ""),
    Primitive("logo_UL", tlength, ""),
    Primitive("logo_ZA", tangle, ""),
    Primitive("logo_ZL", tlength, ""),
    Primitive("logo_DIVA", arrow(tangle, tint, tangle), ""),
    Primitive("logo_MULA", arrow(tangle, tint, tangle), ""),
    Primitive("logo_DIVL", arrow(tlength, tint, tlength), ""),
    Primitive("logo_MULL", arrow(tlength, tint, tlength), ""),
    Primitive("logo_ADDA", arrow(tangle, tangle, tangle), ""),
    Primitive("logo_SUBA", arrow(tangle, tangle, tangle), ""),
    # Primitive("logo_ADDL",  arrow(tlength,tlength,tlength), ""),
    # Primitive("logo_SUBL",  arrow(tlength,tlength,tlength), ""),

    # Primitive("logo_PU",  arrow(turtle,turtle), ""),
    # Primitive("logo_PD",  arrow(turtle,turtle), ""),
    Primitive("logo_PT", arrow(arrow(turtle, turtle), arrow(turtle, turtle)),
              None),
    Primitive("logo_FWRT", arrow(tlength, tangle, turtle, turtle), ""),
    Primitive("logo_GETSET", arrow(arrow(turtle, turtle), turtle, turtle), "")
] + [
Ejemplo n.º 18
0
def deepcoderPrimitives():
    return [
        Primitive("HEAD", arrow(tlist(tint), tint), _head),
        Primitive("LAST", arrow(tlist(tint), tint), _tail),
        Primitive("TAKE", arrow(tint, tlist(tint), tlist(tint)), _take),
        Primitive("DROP", arrow(tint, tlist(tint), tlist(tint)), _drop),
        Primitive("ACCESS", arrow(tint, tlist(tint), tint), _access),
        Primitive("MINIMUM", arrow(tlist(tint), tint), _minimum),
        Primitive("MAXIMUM", arrow(tlist(tint), tint), _maximum),
        Primitive("REVERSE", arrow(tlist(tint), tlist(tint)), _reverse),
        Primitive("SORT", arrow(tlist(tint), tlist(tint)), _sort),
        Primitive("SUM", arrow(tlist(tint), tint), _sum)
    ] + [
        Primitive("MAP", arrow(int_to_int, tlist(tint), tlist(tint)),
                  _map),  #is this okay???
        Primitive("FILTER", arrow(int_to_bool, tlist(tint), tlist(tint)),
                  _filter),  #is this okay???
        Primitive("COUNT", arrow(int_to_bool, tlist(tint), tint),
                  _count),  #is this okay???
        Primitive(
            "ZIPWITH",
            arrow(int_to_int_to_int, tlist(tint), tlist(tint), tlist(tint)),
            _zipwith),  #is this okay???
        Primitive("SCANL1", arrow(int_to_int_to_int, tlist(tint), tlist(tint)),
                  _scanl1),  #is this okay???
    ] + [
        Primitive("INC", int_to_int, _succ),
        Primitive("DEC", int_to_int, _pred),
        Primitive("SHL", int_to_int, _double),
        Primitive("SHR", int_to_int, _half),
        Primitive("doNEG", int_to_int, _negate),
        Primitive("SQR", int_to_int, _square),
        Primitive("MUL3", int_to_int, _triple),
        Primitive("DIV3", int_to_int, _third),
        Primitive("MUL4", int_to_int, _quad),
        Primitive("DIV4", int_to_int, _quarter),
    ] + [
        Primitive("isPOS", int_to_bool, _pos),
        Primitive("isNEG", int_to_bool, _neg),
        Primitive("isEVEN", int_to_bool, _even),
        Primitive("isODD", int_to_bool, _odd),
    ] + [
        Primitive("+", int_to_int_to_int, _add),
        Primitive("-", int_to_int_to_int, _sub),
        Primitive("*", int_to_int_to_int, _mult),
        Primitive("MIN", int_to_int_to_int, _min),
        Primitive("MAX", int_to_int_to_int, _max)
    ]