Crate lambdas

Source

Modules§

domains
tutorials
A Guide-level Explanation of egg

Macros§

define_language
A macro to easily create a Language.
define_semantics
this macros defines two lazy static variables PRIMS and FUNCS
dsl_entries
dsl_entries_lookup_gen
fn_ptr_entries
load_args
this macro is used at the start of a DSL function to load arguments out of their args vec
load_args_lazy
this macro is used at the start of a DSL function to load arguments out of their args vec
rewrite
A macro to easily make Rewrites.
test_fn
Make a test function

Structs§

ArrowIter
ArrowIterTypeRef
AstDepth
A simple CostFunction that counts maximum ast depth.
AstSize
A simple CostFunction that counts total ast size.
BackoffScheduler
A RewriteScheduler that implements exponentional rule backoff.
ConditionEqual
A Condition that checks if two terms are equivalent.
ConditionalApplier
An Applier that checks a Condition before applying.
Context
CurriedFn
Wraps a DSL function in a struct that manages currying of the arguments which are fed in one at a time through .apply(). Example: the “+” primitive evaluates to a CurriedFn with arity 2 and empty partial_args. The expression (app + 3) evals to a CurriedFn with vec![3] as the partial_args. The expression (app (app + 3) 4) will evaluate to 7 (since .apply() will fill the last argument, notice that all arguments are filled, and return the result).
DSL
DSLEntry
DidMerge
Result of Analysis::merge indicating which of the inputs are different from the merged result.
Dot
A wrapper for an EGraph that can output GraphViz for visualization.
EClass
An equivalence class of enodes.
EGraph
A data structure to keep track of equalities between expressions.
Evaluator
Explanation
A data structure representing an explanation that two terms are equivalent.
Expr
An untyped lambda calculus expression, much like egg::RecExpr but with a public nodes field and many attached functions. See Lambda for details on the individual nodes.
Extractor
Extracting a single RecExpr from an EGraph.
FlatTerm
A single term in an flattened explanation. After the first term in a FlatExplanation, each term will be annotated with exactly one backward_rule or one forward_rule. This can appear in children FlatTerms, indicating that the child is being rewritten.
FromOpError
A generic error for failing to parse an operator. This is the error type used by define_language! for FromOp::Error, and is a sensible choice when implementing FromOp manually.
Id
A key to identify EClasses within an EGraph.
Iteration
Data generated by running a Runner one iteration.
LazyVal
Pattern
A pattern that can function as either a Searcher or Applier.
ProgramCost
the cost of a program, where app and lam cost 1, programs costs nothing, ivar and var and prim cost 100.
ProgramDepth
depth of a program. For example a leaf is depth 1.
RawTypeRef
RecExpr
A recursive expression from a user-defined Language.
Report
A report containing data about an entire Runner run.
Rewrite
A rewrite that searches for the lefthand side and applies the righthand side.
Runner
Faciliates running rewrites over an EGraph.
SearchMatches
The result of searching a Searcher over one eclass.
SimpleScheduler
A very simple RewriteScheduler that runs every rewrite every time.
Subst
A substitition mapping Vars to eclass Ids.
Symbol
An interned string.
SymbolLang
A simple language used for testing.
TermArgIter
TreeTerm
An explanation for a term and its equivalent children. Each child is a proof transforming the initial child into the final child term. The initial term is given by taking each first sub-term in each child_proofs recursivly. The final term is given by all of the final terms in each child_proofs.
TypeRef
TypeSet
Var
A variable for use in Patterns or Substs.

Enums§

ENodeOrVar
The language of Patterns.
Lambda
A node of an untyped lambda calculus expression compatible with egg but also used more widely throughout this crate. Note that there is no domain associated with this object. This makes it easy to run compression on domains that don’t have semantics yet, makes it easy to add new prims (eg learned functions), etc. You’ll have to specify a domain when you execute the expression, type check it, etc, but you can easily do that at the time through generics on those functions.
LazyValSource
RecExprParseError
An error type for failures when attempting to parse an s-expression as a RecExpr<L>.
StopReason
Error returned by Runner when it stops.
TNode
int [Term(“int”,None)]
Type
UnifyErr
Val
a value can either be some domain specific value Dom(D) like an Int, or it can be a primitive function or partially applied primitive function like + or (+ 2) or it can be a lambda function with some captured env like (lam (* $1 $0)) where $1 may have been captured from the surrounding code and this whole object may now be passed around

Constants§

SENTINEL

Traits§

Analysis
Arbitrary data associated with an EClass.
Applier
The righthand side of a Rewrite.
Condition
A condition to check in a ConditionalApplier.
CostFunction
A cost function that can be used by an Extractor.
Domain
The key trait that defines a domain
FromOp
A trait for parsing e-nodes. This is implemented automatically by define_language!.
FromVal
IterationData
Custom data to inject into the Iterations recorded by a Runner
Language
Trait that defines a Language whose terms will be in the EGraph.
LanguageChildren
A marker that defines acceptable children types for define_language!.
RewriteScheduler
A way to customize how a Runner runs Rewrites.
Searcher
The lefthand side of a Rewrite.

Functions§

assert_eq_val
convenience function for equality assertions
assert_error
assert_execution
convenience function for asserting that something executes to what you’d expect
merge_max
A utility for implementing Analysis::merge when the Data type has a total ordering. This will take the maximum of the two values.
merge_min
A utility for implementing Analysis::merge when the Data type has a total ordering. This will take the minimum of the two values.
ok
convenience function for returning arguments from a DSL function

Type Aliases§

DSLFn
Env
env[i] is the value at $i
FlatExplanation
FlatExplanation are the simpler, expanded representation showing one term being rewritten to another. Each step contains a full FlatTerm. Each flat term is connected to the previous by exactly one rewrite.
PatternAst
A RecExpr that represents a Pattern.
TreeExplanation
Explanation trees are the compact representation showing how one term can be rewritten to another.
UnifyResult
VError
VResult