Safe Haskell | None |
---|---|
Language | Haskell2010 |
We use a flat semantics in GenI (bag of literals).
- data Literal gv = Literal {
- lHandle :: gv
- lPredicate :: gv
- lArgs :: [gv]
- type Sem = [Literal GeniVal]
- type LitConstr = (Literal GeniVal, [Text])
- type SemInput = (Sem, Flist GeniVal, [LitConstr])
- emptyLiteral :: Literal GeniVal
- removeConstraints :: SemInput -> SemInput
- sortSem :: Ord a => [Literal a] -> [Literal a]
- compareOnLiteral :: Ord a => Literal a -> Literal a -> Ordering
- sortByAmbiguity :: Sem -> Sem
- class HasConstants a where
- displaySemInput :: ([LitConstr] -> Text) -> SemInput -> Text
- isInternalHandle :: Text -> Bool
- subsumeSem :: Sem -> Sem -> [(Sem, Subst)]
- subsumeSemH :: Sem -> Sem -> [(Sem, Subst)]
- subsumeLiteral :: MonadUnify m => Literal GeniVal -> Literal GeniVal -> m (Literal GeniVal, Subst)
- unifySem :: Sem -> Sem -> [(Sem, Subst)]
- unifySemH :: Sem -> Sem -> [(Sem, Subst)]
- unifyLiteral :: MonadUnify m => Literal GeniVal -> Literal GeniVal -> m (Literal GeniVal, Subst)
Documentation
A single semantic literal containing its handle, predicate, and arguments
This can be paramaterised on the kinds of variables it uses, for example,
GeniVal
for a semantics that you might still want to do unification on
or Text
if it's supposed to be ground.
Literal | |
|
Pretty SemInput Source # | |
Pretty Sem Source # | |
GeniShow SemInput Source # | |
GeniShow LitConstr Source # | |
GeniShow Sem Source # | |
Eq gv => Eq (Literal gv) Source # | |
Data gv => Data (Literal gv) Source # | |
Ord gv => Ord (Literal gv) Source # | |
Binary g => Binary (Literal g) Source # | |
NFData g => NFData (Literal g) Source # | |
Pretty (Literal GeniVal) Source # | |
GeniShow (Literal GeniVal) Source # | |
DescendGeniVal a => DescendGeniVal (Literal a) Source # | |
Collectable a => Collectable (Literal a) Source # | |
HasConstants (Literal GeniVal) Source # | |
type LitConstr = (Literal GeniVal, [Text]) Source #
A literal and any constraints associated with it (semantic input)
type SemInput = (Sem, Flist GeniVal, [LitConstr]) Source #
Semantics, index constraints, literal constraints
The intention here is that for (sem, icons, lcons)
all (
elem
sem) lcons
emptyLiteral :: Literal GeniVal Source #
An empty literal, not sure you should really be using this
Utility functions
removeConstraints :: SemInput -> SemInput Source #
Strip any index or literal constraints from an input. Use with care.
compareOnLiteral :: Ord a => Literal a -> Literal a -> Ordering Source #
Default comparison for a literal
sortByAmbiguity :: Sem -> Sem Source #
Sort primarily putting the ones with the most constants first and secondarily by the number of instances a predicate occurs (if plain string; atomic disjunction/vars treated as infinite)
class HasConstants a where Source #
Anything that we would want to count the number constants in (as opposed to variables)
HasConstants GeniVal Source # | |
HasConstants a => HasConstants [a] Source # | |
HasConstants (Literal GeniVal) Source # | |
displaySemInput :: ([LitConstr] -> Text) -> SemInput -> Text Source #
Helper for displaying or pretty printing a semantic input
This gives you a bit of control over how each literal is displayed
isInternalHandle :: Text -> Bool Source #
Is a handle generated by GenI. GenI lets you write literals without a handle; in these cases a unique handle is generated and hidden from the UI.
Subsumption
subsumeSem :: Sem -> Sem -> [(Sem, Subst)] Source #
x
returns all the possible ways to unify
subsumeSem
yx
with some SUBSET of y
so that x
subsumes y
.
If x
does NOT subsume y
, we return the empty list.
subsumeSemH :: Sem -> Sem -> [(Sem, Subst)] Source #
Helper for subsumeSem
traversal
subsumeLiteral :: MonadUnify m => Literal GeniVal -> Literal GeniVal -> m (Literal GeniVal, Subst) Source #
p1
is the unification of subsumeLiteral
p2p1
and p2
if
both literals have the same arity, and the handles, predicates,
and arguments in p1
all subsume their counterparts in p2