In-place transformation stuff.

funnyqt.bidi | Bidirectional transformations (BX). |

funnyqt.coevo.tg | Co-Evolution transformations on TGraphs. |

funnyqt.edn | Printing/persisting and reading/loading query results and transformation
traces as EDN. |

funnyqt.emf | Core functions for accessing and manipulating EMF models. |

funnyqt.extensional | Specify models extensionally. |

funnyqt.generic | Generic protocols extended upon many different types, and generic functions. |

funnyqt.model2model | Rule-base out-place transformations similar to ATL or QVTo. |

funnyqt.pmatch | Graph Pattern Matching on arbitrary models. |

funnyqt.polyfns | Polymorphic functions dispatching on types of model elements. |

funnyqt.query | Generic query functions like regular path expressions & quantified expressions. |

funnyqt.query.emf | EMF-specific query functions |

funnyqt.query.tg | TG-specific query functions |

funnyqt.relational | Relational Model Querying. |

funnyqt.tg | Core functions for accessing and manipulating TGraphs. |

funnyqt.utils | Generic utility functions, e.g., for signaling errors, debugging, and profiling, |

funnyqt.visualization | Model visualization functions. |

funnyqt.xmltg | Convert XML to DOM-like TGraphs. |

Index Page | |

Alphabetic Var Index |

In-place transformation stuff.

Arglists: ========= (as-pattern rule-app) Docstring: ========== Performs the given rule application `rule-app` as a pattern. That is, returns the lazy sequence of matches without applying the rule's actions.

Arglists: ========= (as-test rule-app) Docstring: ========== Performs the given rule application `rule-app` as a test. That is, lets the rule find a match and returns a thunk that can be applied later to perform the rule's actions. If there's no match, returns nil. Note that if the actions of the rule `recur` to this rule, when called with `as-test` you get a plain, stack-consuming recursion instead because `recur` would recur to the thunk, not to the rule. Note further that when applying a ^:forall rule as test you get a vector of thunks, each thunk applying the actions to one match, instead.

Arglists: ========= (conjunctive-rule & rules) Docstring: ========== Returns a varargs function which applies `rules` in sequence to its args until one rule returns logical false. The function returns the value of the last rule application iff all rules could be applied. Else, it returns logical false. Thus, ((conjunctive-rule r1 r2 r3 r4 r5) x y) is equivalent to (and (r1 x y) (r2 x y) (r3 x y) (r4 x y) (r5 x y))

Arglists: ========= (conjunctive-rule* & rules) Docstring: ========== Returns a varargs function which applies `rules` in sequence until one rule returns logical false. The first rule is applied to the arguments given to the function, all others are applied with the result of the previous rule application. The function returns the value of the last rule application iff all rules could be applied. Else, it returns logical false. Thus, ((conjunctive-rule* r1 r2 r3 r4 r5) x y) is equivalent to (when-let [r (r1 x y)] (when-let [r (apply r2 r)] (when-let [r (apply r3 r)] (when-let [r (apply r4 r)] (when-let [r (apply r5 r)] r))))).

Arglists: ========= (create-state-space model comparefn rules) (create-state-space model comparefn rules options) Docstring: ========== Takes the `model` as initial state and applies all `rules` to it generating a state space graph. An optional map of options may be given. For a description of arguments and options except for :recur-pred, see `funnyqt.in-place/state-space-step-fn`. If the map of options contains a :recur-pred entry, its value must be a function of five arguments which determines if the state space generation should be resumed. It's signature should be: (fn [ssg state2model-map invalid-states invalid-transitions failed-state-space-preds] ...) If the recur-pred returns logical true, the state space generation is resumed. By default, i.e., when there is no :recur-pred entry in the map of options, `create-state-space` returns as soon as at least one predicate of `state-preds`, `transition-preds`, or `state-space-preds` fails. The return value has the form [state-space-graph state2model-map step-fn-retval] where state-space-graph is the final state space graph, state2model-map is the final map from SSG states to corresponding models, and step-fn-retval is the return value of the underlying `state-space-step-fn`. This vector also has :state-space-step-fn metadata which is the state space step function used internally by create-state-space. This allows for driving the state space generation further after create-state-space has returned because of a failed predicate or a user-defined recur-pred.

Arglists: ========= (defrule name doc-string? attr-map? [args] [pattern] & body) (defrule name doc-string? attr-map? ([args] [pattern] & body) +) Docstring: ========== Defines a rule with `name`, optional doc-string', optional `attr-map?', an `args` vector, an optional `pattern` vector, and following `body` code. Just like `defn`, overloading is supported as well. The `pattern` vector is optional. If no version has it, then you should use `defn` directly. `pattern` is a vector with the syntax of funnyqt.pmatch/defpattern. The pattern is optional. The purpose of this optionality is mainly overloading, i.e., you can have a rule like this: (defrule foobar "Matches a, b, and c, and performs actions on them." ([g] [a --> b --> c ...] (foobar g a b c)) ([g a] [b --> c ...] (foobar g a b c)) ([g a b] [c ...] (foobar g a b c)) ([g a b c] ;; No match vector, just actions (action1 a) (action2 b) (action3 c) (action4 a c))) The `pattern` may include every pattern feature of funnyqt.pmatch/defpattern with the exception of :as clauses. It may also have :extends clauses extending the patterns of other rules (only the other rule's pattern is extended; not the other rule's actions), or of another arity of the extending rule. The `body` may contain arbitrary code acting upon `args` and the elements matched by `pattern`. Rules expand to plain Clojure functions. When a rule gets applied, it tries to find a match. If it can't find one, it returns logical false. If it finds one, it applies its `body` on the match returning the value of the last form in `body`, which should be logical true by convention. In general, rules consider the same options as patterns. Rules may have ^:forall metadata attached to their name or the :forall option set in the attr-map. Such a rule first finds all matches eagerly (i.e., the underlying pattern has the :eager option set automatically), and then applies the actions to each match in sequence. The finding of matches is done in parallel (if some constraints hold, and there's no ^:sequential metadata). The result of a ^:forall rule is the vector of action results (one for each match). If you're not interested in that and want to save some memory, you can also add ^:no-result-vec metadata. In that case, applying the ^:forall rule returns only the number of matches. In any case, if there were no matches at all, nil is returned. Note that in a :forall rule, applying the actions on some match might invalidate a later match. If that is feasible, enable the :recheck option either in attr-map or as metadata. Then the pattern is rechecked before applying the actions. The same holds for applying a rule using `as-test'. Here, the matching is performed at the call but you might apply the returned action thunk some time in the future when the model has already changed. If that's the case in your scenario, again :recheck will enable rechecking the match before applying the actions. Also see `as-pattern` and `as-test`.

Arglists: ========= (disjunctive-rule & rules) Docstring: ========== Returns a varargs function which applies the first matching rule in `rules` to its args and returns the result of this application. If no rule matches, the function returns nil.

Arglists: ========= (explore-state-space model comparefn rules) (explore-state-space model comparefn rules options) Docstring: ========== Fires up a GUI that allows for creating and inspecting the state space by starting with initial model `model`, the given `comparefn` (see, e.g., `funnyqt.generic/equal-models?`), and the given `rules`. For a description of arguments, see `funnyqt.in-place/state-space-step-fn`. explore-state-space returns a vector of the form [ssg s2m-map] where ssg is the state space graph which has been built interactively, and s2m-map is the map from State vertices to the corresponding models. This vector has :state-space-step-fn metadata attached whose value is the step-wise state space generation function used internally.

Arglists: ========= (interactive-rule & rules) Docstring: ========== Returns a function which interactively applies the given `rules` to the returned function's arguments.

Arglists: ========= (iterated-rule r) Docstring: ========== Returns a varargs function which applies the rule `r` to the function's arguments as long as it returns logical true. The function returns the number of successful applications or nil if it couldn't be applied at least once.

Arglists: ========= (iterated-rule* r) Docstring: ========== Returns a varargs function which applies the rule `r` as long as it returns logical true. On the first application, `r` receives the arguments given to the function. The second till last application receive the value of the previous successful application. Returns the number of successful applications, or nil if it couldn't be applied at least once.

Arglists: ========= (letrule [rspecs] attr-map? & body) Docstring: ========== Establishes local rules just like `letfn` establishes local fns. Also see `rule` and `defrule`.

Arglists: ========= (match-list-cell-renderer) Docstring: ========== No docs attached.

Arglists: ========= (random-rule & rules) Docstring: ========== Returns a varargs funtion which randomly chooses one applicable rule in `rules` and applies it to the arguments given to the function. The function returns that rule's return value or nil if no rule was applicable.

Arglists: ========= (repeated-rule r) (repeated-rule n r) Docstring: ========== Returns a varargs function which applies the rule `r` at most `n` times to the arguments given to the function and returns the number of successfull applications. Stops as soon as `r` fails. The version of arity one returns a function (fn [n & args] ...), i.e., the maximum number of repetitions has to be provided as first argument when calling the returned functions. For example ((repeated-rule 10 r) m) and ((repeated-rule r) 10 m) are equivalent.

Arglists: ========= (repeated-rule* r) (repeated-rule* n r) Docstring: ========== Returns a function which applies the rule `r` at most `n` times and then returns the number of successfull applications. Stops as soon as `r` fails. On the first application, `r` receives `args`. The second to last application receive the result of the previous application. The version of arity one returns a function (fn [n & args] ...), i.e., the maximum number of repetitions has to be provided as first argument when calling the returned functions. For example ((repeated-rule* 10 r) m) and ((repeated-rule* r) 10 m) are equivalent.

Arglists: ========= (rule name? attr-map? [args] [pattern] & body) (rule name? attr-map? ([args] [pattern] & body) +) Docstring: ========== Defines an anonymous rule. Stands to `defrule` (which see) in the same way as `fn` stands to `defn`. Also see `letrule`.

Arglists: ========= (sequential-rule & rules) Docstring: ========== Returns a varargs function which applies all `rules` to its args in sequence collecting the individual application results in a vector. The function returns this vector if at least one rule could be applied. Else, it returns false.

Arglists: ========= (state-space-step-fn init-model comparefn rules) (state-space-step-fn init-model comparefn rules {:keys [additional-args select-state-fn select-rules-fn state-preds transition-preds state-space-preds], :or {select-state-fn first, select-rules-fn identity}, :as options}) Docstring: ========== Creates and returns a function for step-wise state space creation. The state space exploration uses `init-model` as initial model/state, applies `rules` in each state, and compares the models corresponding to states using `comparefn` (usually `funnyqt.generic/equal-models?` is a good `comparefn`). An optional map of further options may be given to `state-space-step-fn`. {:additional-args <seq of additional args for rule application> :select-rules-fn (fn [rules] ...) :select-state-fn (fn [undone-states] ...) :state-preds <seq of predicates on each state's model> :transition-preds <map of rule postconditions> :state-space-preds <seq of predicates on the states space graph>} The returned step-function is overloaded on arity and accepts these arguments: [] ;; arity zero [select-rules-fn] ;; arity one [select-rules-fn select-state-fn] ;; arity two The two arguments may override the values given in the map of options. During each step, first the rules to be applied in this step are computed using (select-rules-fn rules). The default select-rules-fn is clojure.core/identity. If rules should be applied in a random order, use clojure.core/shuffle as select-rules-fn. Then, the state to whose corresponding model the rules are going to be applied is selected by calling (select-state-fn undone-states) where undone-states is the sequence of states to which not all rules have been applied yet. The default select-state-fn is clojure.core/first. Then, each selected rule is applied using (apply rule model-of-a-state additional-args) so the :additional-args entry is for specifying further arguments to the rules in addition to the model corresponding to a state. The other three entries in the map of options allow for specifying validation predicates. - The :state-preds value is a sequence of predicates that receive a state's model. If any predicate returns logical false, the state of that model is an InvalidState. Else, it is a ValidState. Thus, use this entry for specifying invariants for the model under transformation. - The :transition-preds value is a map of the form {rule [pred1 pred2], ...}. When rule is executed to the model of a state, each predicate of this rule is called like (pred old-model match new-model). If that returns logical false, the transition from the state of old-model to the state of new-model is an InvalidTransition. Else, it is a ValidTransition. Thus, use this entry to specify postconditions of rules. - The :state-space-preds value is a sequence of predicates that receive the current state space graph. Use this entry to specify invariants of the state space graph itself. For example, the number of states might be bounded for some transformation, thus an invariant might want to check that (<= (vcount ssg) upper-bound). If that invariant fails, you probably have a bug in your implementation or you use a too strict `comparefn` which considers models different although they differ only in properties which are not important for the case at hand, e.g., the models might differ only in the order of references. Applying the step-function returns false if no rule could be applied, i.e., if the `select-state-fn` couldn't selected some state. Else, it returns a vector of the form [seq-of-invalid-states seq-of-invalid-transitions seq-of-failed-state-space-preds] where seq-of-invalid-states is the sequence of InvalidState vertices in the state space graph, seq-of-invalid-transitions is the sequence of InvalidTransition edges, and seq-of-failed-state-space-preds is the sequence of `state-space-preds` which failed for the current state space graph. The returned step-function has the following metadata: {:state-space-graph the-state-space-graph :state2model-map volatile-state2model-map} So this metadata is where you extract the states space graph and the map from states to corresponding models. The latter is a volatile so needs to be dereferenced (e.g., @volatile-state2model-map or using `clojure.core/deref`) in orded to obtain its current value.