ExMaude. Result. Solution
(ExMaude v0.2.0)
View Source
A single solution from a Maude search operation.
Each solution represents a state that matches the search pattern, along with the state number in the search graph and any variable substitutions that make the pattern match.
Structure
:number- The solution number (1-indexed):state_num- The state number in the search graph:term- The matching term (optional):substitution- Map of variable names to their bound values
Variable Naming Conventions
Maude variables include their sort in the name for disambiguation:
| Variable | Description |
|---|---|
X:Nat | A natural number variable named X |
S:State | A state variable named S |
L:List{Nat} | A list of naturals variable named L |
When accessing substitutions, use the full variable name including sort:
solution.substitution["X:Nat"] # Correct
solution.substitution["X"] # Won't matchSubstitution Format
The substitution map contains variable bindings parsed from Maude output:
Solution 1 (state 5)
X:Nat --> 42
Y:Bool --> trueBecomes:
%{"X:Nat" => "42", "Y:Bool" => "true"}Examples
solution = %ExMaude.Result.Solution{
number: 1,
state_num: 5,
substitution: %{"S:State" => "active"}
}
# Access bindings
ExMaude.Result.Solution.get_binding(solution, "S:State") #=> "active"
# Check if has bindings
ExMaude.Result.Solution.has_bindings?(solution) #=> trueSee Also
ExMaude.Result.Search- Container for multiple solutionsExMaude.Maude.search/4- To perform searches
Summary
Functions
Gets a substitution value by variable name.
Checks if the solution has any variable bindings.
Creates a new Solution struct.
Types
@type t() :: %ExMaude.Result.Solution{ number: pos_integer(), state_num: non_neg_integer() | nil, substitution: %{required(String.t()) => String.t()}, term: ExMaude.Term.t() | nil }
Functions
Gets a substitution value by variable name.
Examples
solution = ExMaude.Result.Solution.new(1, substitution: %{"X:Nat" => "42"})
ExMaude.Result.Solution.get_binding(solution, "X:Nat") #=> "42"
ExMaude.Result.Solution.get_binding(solution, "Y:Nat") #=> nil
Checks if the solution has any variable bindings.
@spec new( pos_integer(), keyword() ) :: t()
Creates a new Solution struct.
Examples
solution = ExMaude.Result.Solution.new(1, state_num: 5, substitution: %{"X" => "42"})