stitch_core

Functions

build_arg(name, val)

Builds command line argument version of a Python argument, so for example: - build_arg("max_arity",3) -> "--max-arity=3" - build_arg("silent",True) -> "--silent" - build_arg("silent",False) -> ""

compress(programs, iterations[, max_arity, ...])

Runs abstraction learning on a list of programs, optimizing for a compression objective (see Compression Objectives).

dc_to_stitch_vars(sexpr, depth, num_args)

dreamcoder_to_stitch(program, name_mapping)

Translates a program or list of programs from dreamcoder format to stitch format using the name_mapping obtained from name_mapping_dreamcoder() or name_mapping_stitch().

from_dreamcoder(json)

Takes a dreamcoder-style json dictionary and returns a dictionary of arguments to pass as kwargs to compress() or rewrite().

name_mapping_dreamcoder(json)

Takes a dreamcoder-style json dictionary and returns a list of tuples of the form (name, anonymous_abstraction) where name is the name of the abstraction (like "fn_0") and anonymous_abstraction is the dreamcoder-format anonymous abstraction like "#(lambda (foo (#(lambda bar $0))))".

name_mapping_stitch(json)

Same as name_mapping_dreamcoder() but when starting from a stitch output json, such as the .json field of CompressionResult.

parse(original_s)

Parses a string into an s-expression.

replace_prim(program, prim, new)

Replaces all instances of prim in program with new.

rewrite(programs, abstractions, **kwargs)

Rewrites a set of programs with a list of abstractions.

sexpr_replace(sexpr, old, new)

show_sexpr(sexpr)

stitch_to_dreamcoder(program, name_mapping)

Translates a program or list of programs from stitch format to dreamcoder format using the name_mapping obtained from name_mapping_dreamcoder() or name_mapping_stitch().

strip_lambdas(sexpr)

Classes

Abstraction(name, body, arity)

A functional abstraction

CompressionResult(json)

The result of calling compress().

RewriteResult(json)

The result of calling rewrite().

Exceptions

InvalidAbstractionException

ParseError

StitchException

Raised when the Stitch's Rust backend panics