org.combinators.cls.inhabitation
Typeclass instance to minimize an argument collection wrt.
Typeclass instance to minimize an argument collection wrt. to its cardinality under the constraint
that inhabitant sets remain equal.
We have:
forall argvect in args,
exists argvect' in args.minimize,
forall i, argvect(i) <= argvect'(i)
Example:
Seq(Seq('A :&: 'B, 'C), Seq('A, 'D), Seq('A :&: 'B, 'C :&: D)).minimize =
Seq(Seq('A :&: 'B, 'C), Seq('A, 'D))
Finds all piecewise intersections of argument sequences in paths
, such that
correspondingly intersected targets are subtypes of tgt
.
Finds all piecewise intersections of argument sequences in paths
, such that
correspondingly intersected targets are subtypes of tgt
.
Avoids selecting redundant paths and argument vectors.
Assumes all argument sequences in paths
are of equal length.
Example:
covers('A :&: 'B,
(Seq('X, P), 'A) +: (Seq('Y, Q), 'A) +: (Seq('Z, P), 'B) +: Seq.empty) ==
Seq('X :&: 'Z, P) +: Seq('Y :&: 'Z, P) +: Seq.empty
Ensures target
is present as a left hand side of grammar
, if a (subtype-)equal left hand side exists.
Ensures target
is present as a left hand side of grammar
, if a (subtype-)equal left hand side exists.
The preexisting left hand sides will be cloned.
This is necessary, when inhabitStep
substitutes equal types.
Finds an entries of grammar
where the left hand side is a subtype of ty
.
Finds all entries of grammar
where the left hand side is a supertype of ty
.
Finds all productive left hand sides in grammar
.
Finds all productive left hand sides in grammar
.
A left hand side is productive, if any of its right hand sides only requires arguments, which are productive
left hand sides of the grammar.
Inhabits all types in targets and return a tree grammar to represent results.
Inhabits all types in targets and return a tree grammar to represent results. The tree grammar will contain entries (sigma -> Seq((c, args), rhs)), where sigma is a target type, c is a combinator name, args are the argument types necessary for c to inhabit sigma and rhs are all possible other combinator name, argument type pairs for target sigma. The resulting tree grammar is pruned to eliminate unproductive derivation chains.
Inhabits all elements of targets
.
Inhabits all elements of targets
.
Recursively performs inhabitation until there are now fresh targets.
Continues with the next target on failure.
Inhabits the arguments of a single combinator.
Inhabits the arguments of a single combinator.
Sequentially performs inhabitStep
for each target in tgts
.
Aborts and rolls back, whenever a step along the way fails.
Inhabits the arguments of multiple combinators.
Inhabits the arguments of multiple combinators.
Sequentially performs inhabitSequentially
for each target stream in tgts
.
Continues with the next stream when a step along the way fails.
Performs a single inhabitation step.
Performs a single inhabitation step.
Finds combinators which can inhabit tgt
, adds their application as right hand sides for the left hand side tgt
and returns a stream of new targets for each combinator that was used.
Removes combinators depending on tgt
if grammar
contains a pair (sigma -> rhs)
, where sigma
is a supertype
of tgt
and rhs
is an empty set.
Replaces all occurences of tgt
if a (subtype-)equal left hand side is already present.
the tree grammar constructed so far.
the current target.
an updated tree grammar and a stream of new targets for every new right hand side;
empty target streams indicate failure, while Stream.empty #:: Stream.empty[Stream[Type]]
indicates
success without fresh targets.
Rearranges intermediate results to a set of new grammar rules and recursive targets.
Rearranges intermediate results to a set of new grammar rules and recursive targets.
Input format: a map containing combinator names and alternative recursive targets to use that combinator.
Output format: a set of combinator names with the respective parameter types to inhabit for using the combinator,
and a collection of all parameter type collections to use the combinators in the set.
Example:
newProductionsAndTargets(Map("c" -> Seq(Seq('A, 'B), Seq('C), Seq('A, 'B))), "d" -> Seq(), "e" -> Seq(Seq())) ==
(Set(("c", Seq('A, 'B)), ("c", Seq('C)), ("e", Seq())),
Stream.empty #:: ('C #:: Stream.empty) #:: ('A #:: 'B #:: Stream.empty) #:: Stream.empty
Removes all unproductive left hand sides in grammar
.
Removes all unproductive left hand sides in grammar
.
FiniteCombinatoryLogic.groundTypesOf(TreeGrammar)
for a description of productivity.
Removes all entries of grammar
where arg
occurs in a right hand side.
Substitutes all right hand side occurences in grammar
of oldType
by newType
.
Type inhabitation for finite combinatory logic (FCL)