Interface Program
- All Known Implementing Classes:
AProgram
public interface Program
-
Method Summary
Modifier and Type Method Description default List<Integer>arity(String name)The arities of all clauses with a given nameMap<String,List<Relation>>clauses()The program's clauses.default booleancontainsRecursive(String name)True iff any of the clauses namednamecontains an invocation to a recurisive clause.default intdepth(String name)The "depth" of a named clause.static Stream<RuleInvocation>invocations(Stream<Relation> relations)default booleanisRecursive(String name)True iff any of the clauses namednamedirectly contains an invocation of itself.default List<String>names()The names of all clausesdefault booleannoMagicNumbers()True iff the program contains no magic numbersdefault Stream<Relation>relations()All theRelations in the programdefault List<Relation>relationsWithComments()AllRelations that have comments.static Stream<Rule>rules(Stream<Relation> relations)default List<RuleInvocation>undefined()A collection ofRuleInvocations of rules not defined anywhere in the program.
-
Method Details
-
clauses
The program's clauses.A clause is identified by name; since prolog clauses support overloading by arity, each clause gives a list of possible
Relations. -
arity
The arities of all clauses with a given name -
names
The names of all clauses -
relationsWithComments
AllRelations that have comments.- See Also:
Relation.comment()
-
isRecursive
True iff any of the clauses namednamedirectly contains an invocation of itself. -
containsRecursive
True iff any of the clauses namednamecontains an invocation to a recurisive clause.- See Also:
isRecursive(java.lang.String)
-
undefined
A collection ofRuleInvocations of rules not defined anywhere in the program.This can be useful when looking at what "standard" library functions were called, or disallowing them altogether.
-
depth
The "depth" of a named clause.Implementations are free to define depth in any way.
The default implementation defines it thusly: the depth is an integer counting how many subrules are invoked until the tree "bottoms out" by invoking a fact with no subrules. Once a subrule is counted as invoked, other invocations of that subrule are ignored (to circumvent infinite loops in the case of recursion, mutual or otherwise) in that particular "path."
The actual depth is the maximum of all possible depths.
This is a stand-in measure for things like cyclomatic complexity and maximum runtime-depth, the latter of which cannot be computed statically (cf. Turing's Halting problem).
-
noMagicNumbers
default boolean noMagicNumbers()True iff the program contains no magic numbersThe default implementation defines that as "no rules have numeric literals that are not 0, 1, or 2; facts are permitted and encouraged to capture needed numeric constants."
-
rules
-
invocations
- See Also:
Rule.rhs()
-
relations
All theRelations in the program
-