Syntax
See the file prholog-syntax.txt.
Built-in Strategies
all_answers
Syntax:
all_answers(strategy) :: hedge1 ⇒ hedge2
all_answers(strategy) :: hedge1 ⇒ hedge2 where constraint
Succeeds if and only if hedge2 is a hedge consisting of terms of the form ans(h1), ..., ans(hn), where h1,..., hn are all the hedges obtained by applying strategy to hedge1 (satisfying constraint, if it is given). ans just plays the role of a constructor, to distinguish between different answer hedges in hedge2. Can be seen as an analog of findall for PρLog. Exactly one strategy should be provided.
To the top
choice
Syntax:
choice(strategy1, ..., strategyn) :: hedge1 ⇒ hedge2
choice(strategy1, ..., strategyn) :: hedge1 ⇒ hedge2 where constraint
Succeeds if and only if there exists an i such that strategyi :: hedge1 ⇒ hedge2 succeeds (satisfying constraint, if it is given). At least one strategy should be provided (n≥1).
To the top
closure
Syntax:
closure(strategy) :: hedge1 ⇒ hedge2
closure(strategy) :: hedge1 ⇒ hedge2 where constraint
Succeeds if hedge2 belongs to the closure set of transforming hedge1 by strategy (satisfying constraint, if it is given). The set elements are computed one after the other, by backtracking. Fails if the set is empty. Exactly one strategy must be provided.
To the top
compose
Syntax:
compose(strategy1, strategy2 ..., strategyn) :: hedge1 ⇒ hedge2
compose(strategy1, strategy2, ..., strategyn) :: hedge1 ⇒ hedge2 where constraint
First applies strategy1 to hedge1 (satisfying constraint, if it is given). To its result, strategy2 is applied and so on. hedge2 is the final result. compose fails if one of its argument strategies fails in the process. At least two strategies must be provided (n≥2).
To the top
first_all
Syntax:
first_all(strategy1, ..., strategyn) :: hedge1 ⇒ hedge2
first_all(strategy1, ..., strategyn) :: hedge1 ⇒ hedge2 where constraint
Tries to apply strategy1 to hedge1 (satisfying constraint, if it is given). If this fails, it tries the next strategy and so on. When a strategy is found that succeeds, first_all returns all answers computed by it in hedge2, via backtracking. If no strategy succeeds, first_all fails. At least one strategy should be provided (n≥1).
To the top
first_one
Syntax:
first_one(strategy1, ..., strategyn) :: hedge1 ⇒ hedge2
first_one(strategy1, ..., strategyn) :: hedge1 ⇒ hedge2 where constraint
Tries to apply strategy1 to hedge1 (satisfying constraint, if it is given). If this fails, it tries the next strategy and so on. When a strategy is found that succeeds, first_one returns only one answer computed by it in hedge2. If no strategy succeeds, first_one fails. At least one strategy should be provided (n≥1).
To the top
id
Syntax:
id :: hedge1 ⇒ hedge2
Succeeds if and only if hedge1 and hedge2 are identical (can be made identical by matching hedge2 to hedge1).
To the top
interactive
Syntax:
interactive :: hedge1 ⇒ hedge2
interactive :: hedge1 ⇒ hedge2 where constraint
Activates interactive mode and starts dialog with the user, asking her to provide a strategy, which is then applied to hedge1 (satisfying constraint, if it is given). The process is repeated further so that the output hedge of the previous strategy application becomes the input for the new strategy privided by the user, and so on. The interactive process stops when the user types finish. At that moment, the input hedge that was there is returned in hedge2. interactive fails when the user-provided strategy fails for the current input hedge.
To the top
iterate
Syntax:
iterate(strategy, n) :: hedge1 ⇒ hedge2
iterate(strategy, n) :: hedge1 ⇒ hedge2 where constraint
Applies strategy repeatedly to hedge1 n times (satisfying constraint, if it is given). The result is returned in hedge2. Fails if one of the applications fails.
To the top
join
Syntax:
join :: (term1, term2) ⇒ term
If term1 and term2 have the same top function symbol, join joins their arguments under that symbol and returns the obtained term. Otherwise fails. Currently is used only in PρLog-light.
To the top
map
Syntax:
map(strategy) :: hedge1 ⇒ hedge2
map(strategy) :: hedge1 ⇒ hedge2 where constraint
Applies strategy to each term of hedge1 (satisfying constraint, if it is given). For such an input term, strategy may, in general, return a hedge (in particular, it can be also a single term). A hedge constructed of these results (in the same order) is then returned in hedge2. map fails when the application of strategy to a term from hedge1 fails. When hedge1 is empty, hedge2 is empty as well.
To the top
map_to_subhedges
Syntax:
map_to_subhedges(strategy) :: hedge1 ⇒ hedge2
map_to_subhedges(strategy) :: hedge1 ⇒ hedge2 where constraint
Splits hedge1 nondeterministically into nonempty subhedges (when hedge1 is not empty) and applies strategy to each such subhedge (satisfying constraint, if it is given). A hedge constructed of these results (in the same order) is then returned in hedge2. map_to_subhedges fails when hedge1 can not split in such a way that the application of strategy succeeds for each split subhedge. When hedge1 is empty, hedge2 is empty as well.
To the top
prox
Syntax:
prox :: hedge1 ⇒ hedge2
prox :: hedge1 ⇒ hedge2 where constraint
Succeeds if and only if hedge1 and hedge2 are proximal (can be made proximal by matching hedge2 to hedge1) with respect to the given proximity relation.
To the top
nf
Syntax:
nf(strategy) :: hedge1 ⇒ hedge2
nf(strategy) :: hedge1 ⇒ hedge2 where constraint
Succeeds if and only if hedge2 is a normal form of the application of strategy to hedge1 (satisfying constraint, if it is given). To compute it, nf applies strategy repeatedly, starting from hedge1, as long as possible and returns the last result. This strategy is available only in PρLog-full-prox.
To the top
rewrite
Syntax:
rewrite(strategy) :: term1 ⇒ term2
rewrite(strategy) :: term1 ⇒ term2 where constraint
Succeeds if and only if term2 is a term obtained from term1 by applying strategy to a subterm of it (satisfying constraint, if it is given).
To the top