ExMaude. Maude
(ExMaude v0.2.0)
View Source
High-level API for interacting with Maude.
This module provides convenient functions for common Maude operations, handling pool management, command formatting, and response parsing internally.
Examples
# Reduce a term to normal form
{:ok, "6"} = ExMaude.Maude.reduce("NAT", "1 + 2 + 3")
# Rewrite using rules
{:ok, result} = ExMaude.Maude.rewrite("MY-MOD", "initial-state")
# Search state space
{:ok, solutions} = ExMaude.Maude.search("MY-MOD", "init", "goal")
# Execute raw command
{:ok, output} = ExMaude.Maude.execute("show module NAT .")Telemetry
This module emits the following telemetry events:
[:ex_maude, :command, :start]- Emitted when a command starts[:ex_maude, :command, :stop]- Emitted when a command completes[:ex_maude, :command, :exception]- Emitted when a command raises
Metadata includes :operation (:reduce, :rewrite, :search, :execute,
:parse, :load_file, :load_module) and :module (the Maude module name).
See ExMaude.Telemetry for full event documentation and integration examples.
Summary
Functions
Executes a raw Maude command.
Lists all loaded modules.
Loads a Maude file into all pool workers.
Loads a Maude module from a string.
Parses a term in the given module without reducing.
Reduces a term in the given module to its normal form.
Rewrites a term using the rules in the given module.
Searches for states reachable from an initial term.
Shows information about a module.
Returns Maude version information.
Functions
Executes a raw Maude command.
Use this for commands not covered by the high-level API.
Examples
ExMaude.Maude.execute("show module NAT .")
#=> {:ok, "fmod NAT is ..."}
ExMaude.Maude.execute("parse in NAT : 1 + 2 .")
#=> {:ok, "1 + 2"}
Lists all loaded modules.
@spec load_file(Path.t()) :: :ok | {:error, ExMaude.Error.t()}
Loads a Maude file into all pool workers.
The file is loaded into every worker in the pool to ensure consistent module availability across all operations.
Examples
ExMaude.Maude.load_file("/path/to/my-module.maude")
#=> :ok
Loads a Maude module from a string.
The module definition is loaded into all pool workers.
Examples
source = "fmod MY-MOD is sort Foo . endfm"
ExMaude.Maude.load_module(source)
#=> :ok
Parses a term in the given module without reducing.
Examples
ExMaude.Maude.parse("NAT", "1 + 2 + 3")
#=> {:ok, "1 + (2 + 3)"}
Reduces a term in the given module to its normal form.
Uses Maude's reduce command which applies equations until a normal form
is reached (equations are applied as simplification rules).
Examples
ExMaude.Maude.reduce("NAT", "1 + 2 + 3")
#=> {:ok, "6"}
ExMaude.Maude.reduce("BOOL", "true and false")
#=> {:ok, "false"}Options
:timeout- Maximum time in ms (default: 5000)
Rewrites a term using the rules in the given module.
Uses Maude's rewrite command which applies both equations and rules.
Rules can be non-deterministic and may not terminate.
Examples
ExMaude.Maude.rewrite("MY-MOD", "initial-state", max_rewrites: 100)
#=> {:ok, "final-state"}Options
:max_rewrites- Maximum number of rule applications (default: unlimited):timeout- Maximum time in ms (default: 5000)
Searches for states reachable from an initial term.
Uses Maude's search command to explore the state space defined by rewrite rules.
Returns solutions matching the target pattern.
Examples
ExMaude.Maude.search("MY-MOD", "init", "goal")
#=> {:ok, [%{solution: 1, state_num: 5, substitution: %{}}]}
ExMaude.Maude.search("MY-MOD", "init", "S:State", condition: "property(S)")
#=> {:ok, [%{solution: 1, state_num: 3, substitution: %{"S:State" => "s1"}}]}Options
:max_depth- Maximum search depth (default: 100):max_solutions- Maximum solutions to find (default: 1):arrow- Search arrow:=>1,=>+,=>*,=>!(default:=>*):condition- Additional search condition:timeout- Maximum time in ms (default: 30000)
Shows information about a module.
Examples
ExMaude.Maude.show_module("NAT")
#=> {:ok, "fmod NAT is ..."}
Returns Maude version information.
Examples
ExMaude.Maude.version()
#=> {:ok, "Maude (version available at runtime)"}