Egglog (EgglogElixir v0.1.0)

Copy Markdown

Thin Elixir facade for native egglog.

Load a reusable native program with Egglog.Program.load/2, then run query-local facts, commands, requests, and a budget with Egglog.Program.run/3.

For interactive workflows where native egglog state should persist across calls, use Egglog.EGraph. It owns one mutable native session process and exposes native push/pop rollback points.

Summary

Functions

Runs a native egglog (check ...) and returns {:ok, true} or {:ok, false}.

Asserts that a native egglog check fails.

Closes the loaded program.

Evaluates an egglog expression after applying query-local input.

Extracts the cheapest native egglog term for an expression.

Loads a reusable query-local program.

Looks up a function row after evaluating the given argument expressions.

Returns native egglog's tuple count for the loaded program.

Parses egglog source into a reusable Egglog.Commands handle.

Bang variant of parse/1.

Runs query-local egglog input against a loaded program.

Builds a query-local DOT/SVG/JSON snapshot.

Functions

check(program, input, fact, opts \\ [])

@spec check(Egglog.Program.t(), Egglog.Program.input(), String.t(), keyword() | map()) ::
  {:ok, boolean()} | {:error, term()}

Runs a native egglog (check ...) and returns {:ok, true} or {:ok, false}.

See Egglog.Program.check/4 for supported options and defaults.

check?(program, input, fact, opts \\ [])

@spec check?(
  Egglog.Program.t(),
  Egglog.Program.input(),
  String.t(),
  keyword() | map()
) :: boolean()

Boolean variant of check/4.

See Egglog.Program.check?/4 for supported options and defaults.

check_fail(program, input, fact, opts \\ [])

@spec check_fail(
  Egglog.Program.t(),
  Egglog.Program.input(),
  String.t(),
  keyword() | map()
) ::
  :ok | {:error, term()}

Asserts that a native egglog check fails.

See Egglog.Program.check_fail/4 for supported options and defaults.

close(program)

@spec close(Egglog.Program.t()) :: :ok | {:error, term()}

Closes the loaded program.

eval(program, input, expr, opts \\ [])

@spec eval(Egglog.Program.t(), Egglog.Program.input(), String.t(), keyword() | map()) ::
  {:ok, Egglog.Program.value()} | {:error, term()}

Evaluates an egglog expression after applying query-local input.

Primitive native values are decoded to Elixir values; e-class values are returned as %{sort: sort, type: :value, value: text}.

See Egglog.Program.eval/4 for supported options and defaults.

eval!(program, input, expr, opts \\ [])

Bang variant of eval/4.

See Egglog.Program.eval!/4 for supported options and defaults.

extract(program, input, expr, opts \\ [])

@spec extract(
  Egglog.Program.t(),
  Egglog.Program.input(),
  String.t(),
  keyword() | map()
) ::
  {:ok, String.t()} | {:error, term()}

Extracts the cheapest native egglog term for an expression.

See Egglog.Program.extract/4 for supported options and defaults.

extract!(program, input, expr, opts \\ [])

@spec extract!(
  Egglog.Program.t(),
  Egglog.Program.input(),
  String.t(),
  keyword() | map()
) :: String.t()

Bang variant of extract/4.

See Egglog.Program.extract!/4 for supported options and defaults.

load(theory_spec, opts \\ [])

@spec load(String.t() | map(), keyword() | map()) ::
  {:ok, Egglog.Program.t()} | {:error, term()}

Loads a reusable query-local program.

Query-local facts and temporary commands do not mutate the loaded base. Concurrent calls against the same loaded program are serialized by that native resource; independent loaded programs can run independently.

See Egglog.Program.load/2 for supported options and defaults.

load!(theory_spec, opts \\ [])

@spec load!(String.t() | map(), keyword() | map()) :: Egglog.Program.t()

Bang variant of load/2.

lookup(program, input, name, arg_exprs, opts \\ [])

@spec lookup(
  Egglog.Program.t(),
  Egglog.Program.input(),
  String.t(),
  [String.t()],
  keyword() | map()
) ::
  {:ok, Egglog.Program.value() | nil} | {:error, term()}

Looks up a function row after evaluating the given argument expressions.

Returns {:ok, nil} when the table has no row for the evaluated key.

See Egglog.Program.lookup/5 for supported options and defaults.

lookup!(program, input, name, arg_exprs, opts \\ [])

@spec lookup!(
  Egglog.Program.t(),
  Egglog.Program.input(),
  String.t(),
  [String.t()],
  keyword() | map()
) ::
  Egglog.Program.value() | nil

Bang variant of lookup/5.

See Egglog.Program.lookup!/5 for supported options and defaults.

num_tuples(program)

@spec num_tuples(Egglog.Program.t()) :: {:ok, non_neg_integer()} | {:error, term()}

Returns native egglog's tuple count for the loaded program.

See Egglog.Program.num_tuples/1 for details.

parse(source)

@spec parse(String.t()) :: {:ok, Egglog.Commands.t()} | {:error, term()}

Parses egglog source into a reusable Egglog.Commands handle.

Parsed commands are useful when the same command sequence is executed repeatedly.

parse!(source)

@spec parse!(String.t()) :: Egglog.Commands.t()

Bang variant of parse/1.

run(program, input, opts \\ [])

@spec run(Egglog.Program.t(), Egglog.Program.input(), keyword() | map()) ::
  {:ok, Egglog.Program.run_result()} | {:error, term()}

Runs query-local egglog input against a loaded program.

See Egglog.Program.run/3 for the structured input fields accepted by this facade, supported options, and defaults.

run!(program, input, opts \\ [])

Bang variant of run/3.

snapshot(program, input, opts \\ [])

@spec snapshot(Egglog.Program.t(), Egglog.Program.input(), keyword() | map()) ::
  {:ok, map()} | {:error, term()}

Builds a query-local DOT/SVG/JSON snapshot.

See Egglog.Program.snapshot/3 for supported options and defaults.

snapshot!(program, input, opts \\ [])

@spec snapshot!(Egglog.Program.t(), Egglog.Program.input(), keyword() | map()) ::
  map()

Bang variant of snapshot/3.

See Egglog.Program.snapshot!/3 for supported options and defaults.