Skip to content

Instantly share code, notes, and snippets.

@jirkamarsik
Created December 18, 2012 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jirkamarsik/4323622 to your computer and use it in GitHub Desktop.
Save jirkamarsik/4323622 to your computer and use it in GitHub Desktop.
An example of a non-trivial core.logic predicate.
(defn ^::rule fix-adjunctiono
"A rule which takes a left-most or right-most child A, which is an
adjunct, and puts the A on a separate level from the other children,
i.e. (R A ...) -> (R A (R ...)) or (R ... A) -> (R (R ...) A).
This solves the general case when modifiers and adjuncts end up as
children of the consituent they modify (e.g. in VPs)."
[in-tree out-tree]
(fresh [root children other-children adjunct head-child]
(conso root children in-tree)
(has-more-thano 2 children)
(conde [(conso adjunct other-children children)
(== out-tree (list root adjunct head-child))]
[(appendo other-children (list adjunct) children)
(== out-tree (list root head-child adjunct))])
(conso root other-children head-child)
(adjuncto in-tree adjunct)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment