24 package org.lightjason.agentspeak.language.unify;
26 import com.codepoetics.protonpack.StreamUtils;
34 import java.util.List;
36 import java.util.stream.Collectors;
37 import java.util.stream.Stream;
49 public final <T extends ITerm>
boolean unify(
final Set<
IVariable<?>> p_variables,
final Stream<T> p_source,
final Stream<T> p_target )
51 final List<T> l_target = p_target.collect( Collectors.toList() );
52 final List<T> l_source = p_source.collect( Collectors.toList() );
54 if ( ( l_target.isEmpty() ) || ( l_source.isEmpty() ) )
57 if ( l_target.size() != l_source.size() )
60 return StreamUtils.zip(
67 if ( ( t instanceof
IVariable<?> ) && ( s instanceof IVariable<?> ) )
70 ( (IVariable<?>) t ).mutex()
78 if ( t instanceof IVariable<?> )
85 if ( ( s instanceof
IRawTerm<?> ) || ( t instanceof IRawTerm<?> ) )
89 if ( ( s instanceof
ILiteral ) && ( t instanceof ILiteral ) )
91 final ILiteral l_sourceliteral = (ILiteral) s;
92 final ILiteral l_targetliteral = (ILiteral) t;
103 ).allMatch( i -> i );
Stream< ITerm > orderedvalues( @Nullable final IPath... p_path)
returns a stream over the ordered values in sequential ordering
interface of an unification algorithm
IPath fqnfunctor()
returns the full-qualified functor with path and name
class for a mutex relocated variable
class for a relocated variable
final< T extends ITerm > boolean unify(final Set< IVariable<?>> p_variables, final Stream< T > p_source, final Stream< T > p_target)
unify algorithm