@ Nullable static < S , I , O > ReplacementResult < S , I , O > computeParentExtension ( final MealyMachine < S , I , ? , O > hypothesis , final Alphabet < I > inputs , final ADTNode < S , I , O > node , final Set < S > targetStates , final ADSCalculator adsCalculator ) { final ADTNode < S , I , O > parentReset = node . getParent ( ) ; assert ADTUtil . isResetNode ( parentReset ) : "should not happen" ; final Word < I > incomingTraceInput = ADTUtil . buildTraceForNode ( parentReset ) . getFirst ( ) ; Map < S , S > currentToInitialMapping = targetStates . stream ( ) . collect ( Collectors . toMap ( Function . identity ( ) , Function . identity ( ) ) ) ; for ( final I i : incomingTraceInput ) { final Map < S , S > nextMapping = new HashMap <> ( ) ; for ( final Map . Entry < S , S > entry : currentToInitialMapping . entrySet ( ) ) { final S successor = hypothesis . getSuccessor ( entry . getKey ( ) , i ) ; // converging states if ( nextMapping . containsKey ( successor ) ) { return null ; } nextMapping . put ( successor , entry . getValue ( ) ) ; } currentToInitialMapping = nextMapping ; } final Optional < ADTNode < S , I , O > > potentialExtension = adsCalculator . compute ( hypothesis , inputs , currentToInitialMapping . keySet ( ) ) ; if ( potentialExtension . isPresent ( ) ) { final ADTNode < S , I , O > extension = potentialExtension . get ( ) ; for ( final ADTNode < S , I , O > finalNode : ADTUtil . collectLeaves ( extension ) ) { finalNode . setHypothesisState ( currentToInitialMapping . get ( finalNode . getHypothesisState ( ) ) ) ; } return new ReplacementResult <> ( parentReset , potentialExtension . get ( ) ) ; } return null ; }
Try to compute a replacement for a ADT sub - tree that extends the parent ADS .