idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
42,300
public static boolean match ( Version version , String begin , String end ) { E . checkArgumentNotNull ( version , "The version to match is null" ) ; return version . compareTo ( new Version ( begin ) ) >= 0 && version . compareTo ( new Version ( end ) ) < 0 ; }
Compare if a version is inside a range [ begin end )
65
12
42,301
public static void check ( Version version , String begin , String end , String component ) { E . checkState ( VersionUtil . match ( version , begin , end ) , "The version %s of '%s' is not in [%s, %s)" , version , component , begin , end ) ; }
Check whether a component version is matched expected range throw an exception if it s not matched .
67
18
42,302
public static String getImplementationVersion ( Class < ? > clazz ) { /* * We don't use Package.getImplementationVersion() due to * a duplicate package would override the origin package info. * https://stackoverflow.com/questions/1272648/reading-my-own-jars-manifest */ String className = clazz . getSimpleName ( ) + ".c...
Get implementation version from manifest in jar
248
7
42,303
public static String getPomVersion ( ) { String cmd = "mvn help:evaluate -Dexpression=project.version " + "-q -DforceStdout" ; Process process = null ; InputStreamReader isr = null ; try { process = Runtime . getRuntime ( ) . exec ( cmd ) ; process . waitFor ( ) ; isr = new InputStreamReader ( process . getInputStream ...
Get version from pom . xml
178
7
42,304
static void write ( Command cmd , OutputStream out ) throws UnsupportedEncodingException , IOException { encode ( cmd . getCommand ( ) , out ) ; for ( Parameter param : cmd . getParameters ( ) ) { encode ( String . format ( "=%s=%s" , param . getName ( ) , param . hasValue ( ) ? param . getValue ( ) : "" ) , out ) ; } ...
write a command to the output stream
270
7
42,305
static String decode ( InputStream in ) throws ApiDataException , ApiConnectionException { StringBuilder res = new StringBuilder ( ) ; decode ( in , res ) ; return res . toString ( ) ; }
decode bytes from an input stream of Mikrotik protocol sentences into text
45
15
42,306
private static void decode ( InputStream in , StringBuilder result ) throws ApiDataException , ApiConnectionException { try { int len = readLen ( in ) ; if ( len > 0 ) { byte buf [ ] = new byte [ len ] ; for ( int i = 0 ; i < len ; ++ i ) { int c = in . read ( ) ; if ( c < 0 ) { throw new ApiDataException ( "Truncated ...
decode bytes from an input stream into Mikrotik protocol sentences
210
13
42,307
static String hashMD5 ( String s ) throws ApiDataException { MessageDigest algorithm = null ; try { algorithm = MessageDigest . getInstance ( "MD5" ) ; } catch ( NoSuchAlgorithmException nsae ) { throw new ApiDataException ( "Cannot find MD5 digest algorithm" ) ; } byte [ ] defaultBytes = new byte [ s . length ( ) ] ; ...
makes MD5 hash of string for use with RouterOS API
248
12
42,308
static String hexStrToStr ( String s ) { StringBuilder ret = new StringBuilder ( ) ; for ( int i = 0 ; i < s . length ( ) ; i += 2 ) { ret . append ( ( char ) Integer . parseInt ( s . substring ( i , i + 2 ) , 16 ) ) ; } return ret . toString ( ) ; }
converts hex value string to normal strint for use with RouterOS API
79
15
42,309
private static void encode ( String word , OutputStream out ) throws UnsupportedEncodingException , IOException { byte bytes [ ] = word . getBytes ( "UTF-8" ) ; int len = bytes . length ; if ( len < 0x80 ) { out . write ( len ) ; } else if ( len < 0x4000 ) { len = len | 0x8000 ; out . write ( len >> 8 ) ; out . write (...
encode text using Mikrotik s encoding scheme and write it to an output stream .
254
18
42,310
private static int readLen ( InputStream in ) throws IOException { int c = in . read ( ) ; if ( c > 0 ) { if ( ( c & 0x80 ) == 0 ) { } else if ( ( c & 0xC0 ) == 0x80 ) { c = c & ~ 0xC0 ; c = ( c << 8 ) | in . read ( ) ; } else if ( ( c & 0xE0 ) == 0xC0 ) { c = c & ~ 0xE0 ; c = ( c << 8 ) | in . read ( ) ; c = ( c << 8 ...
read length bytes from stream and return length of coming word
302
11
42,311
void addParameter ( String name , String value ) { params . add ( new Parameter ( name , value ) ) ; }
Add a parameter to a command .
26
7
42,312
public static ApiConnection connect ( SocketFactory fact , String host , int port , int timeout ) throws MikrotikApiException { return ApiConnectionImpl . connect ( fact , host , port , timeout ) ; }
Create a new API connection to the give device on the supplied port using the supplied socket factory to create the socket .
46
23
42,313
public static ApiConnection connect ( String host ) throws MikrotikApiException { return connect ( SocketFactory . getDefault ( ) , host , DEFAULT_PORT , DEFAULT_COMMAND_TIMEOUT ) ; }
Create a new API connection to the give device on the default API port .
48
15
42,314
public static ApiConnection connect ( SocketFactory fact , String host , int port , int timeOut ) throws ApiConnectionException { ApiConnectionImpl con = new ApiConnectionImpl ( ) ; con . open ( host , port , fact , timeOut ) ; return con ; }
Create a new API connection to the give device on the supplied port
59
13
42,315
private void open ( String host , int port , SocketFactory fact , int conTimeout ) throws ApiConnectionException { try { InetAddress ia = InetAddress . getByName ( host . trim ( ) ) ; sock = fact . createSocket ( ) ; sock . connect ( new InetSocketAddress ( ia , port ) , conTimeout ) ; in = new DataInputStream ( sock ....
Start the API . Connects to the Mikrotik
248
11
42,316
Token next ( ) throws ScanException { text = null ; switch ( c ) { case ' ' : return EOL ; case ' ' : case ' ' : return whiteSpace ( ) ; case ' ' : nextChar ( ) ; return COMMA ; case ' ' : nextChar ( ) ; return SLASH ; case ' ' : nextChar ( ) ; return LESS ; case ' ' : nextChar ( ) ; return MORE ; case ' ' : nextChar (...
return the next token from the text
145
7
42,317
private Token name ( ) throws ScanException { text = new StringBuilder ( ) ; while ( ! in ( c , "[ \t\r\n=<>!]" ) ) { text . append ( c ) ; nextChar ( ) ; } String val = text . toString ( ) . toLowerCase ( Locale . getDefault ( ) ) ; switch ( val ) { case "where" : return WHERE ; case "not" : return NOT ; case "and" : ...
process name tokens which could be key words or text
126
10
42,318
private Token quotedText ( char quote ) throws ScanException { nextChar ( ) ; // eat the '"' text = new StringBuilder ( ) ; while ( c != quote ) { if ( c == ' ' ) { throw new ScanException ( "Unclosed quoted text, reached end of line." ) ; } text . append ( c ) ; nextChar ( ) ; } nextChar ( ) ; // eat the '"' return TE...
process quoted text
91
3
42,319
private void nextChar ( ) { if ( pos < line . length ( ) ) { c = line . charAt ( pos ) ; pos ++ ; } else { c = ' ' ; } }
return the next character from the line of text
41
9
42,320
static Command parse ( String text ) throws ParseException { Parser parser = new Parser ( text ) ; return parser . parse ( ) ; }
parse the given bit of text into a Command object
31
10
42,321
private Command parse ( ) throws ParseException { command ( ) ; while ( ! is ( Token . WHERE , Token . RETURN , Token . EOL ) ) { param ( ) ; } if ( token == Token . WHERE ) { where ( ) ; } if ( token == Token . RETURN ) { returns ( ) ; } expect ( Token . EOL ) ; return cmd ; }
run parse on the internal data and return the command object
81
11
42,322
private void next ( ) throws ScanException { token = scanner . next ( ) ; while ( token == Token . WS ) { token = scanner . next ( ) ; } text = scanner . text ( ) ; }
move to the next token returned by the scanner
44
9
42,323
public static double calcAverageDegree ( HashMap < Character , String [ ] > keys ) { double average = 0d ; for ( Map . Entry < Character , String [ ] > entry : keys . entrySet ( ) ) { average += neighborsNumber ( entry . getValue ( ) ) ; } return average / ( double ) keys . size ( ) ; }
Calculates the average degree of a keyboard or keypad . On the qwerty keyboard g has degree 6 being adjacent to ftyhbv and \ has degree 1 .
76
37
42,324
public static int neighborsNumber ( String [ ] neighbors ) { int sum = 0 ; for ( String s : neighbors ) { if ( s != null ) { sum ++ ; } } return sum ; }
Count how many neighbors a key has
41
7
42,325
public static Set < Character > getNeighbors ( final AdjacencyGraph adjacencyGraph , final Character key ) { final Set < Character > neighbors = new HashSet <> ( ) ; if ( adjacencyGraph . getKeyMap ( ) . containsKey ( key ) ) { String [ ] tmp_neighbors = adjacencyGraph . getKeyMap ( ) . get ( key ) ; for ( final String...
Returns a set of neighbors for a specific character .
148
10
42,326
public static int getTurns ( final AdjacencyGraph adjacencyGraph , final String part ) { int direction = 0 ; int turns = 1 ; char [ ] parts = part . toCharArray ( ) ; for ( int i1 = 0 ; i1 < parts . length ; i1 ++ ) { Character character = parts [ i1 ] ; if ( i1 + 1 >= parts . length ) { continue ; } Character next_cha...
Returns the number of turns in the part passed in based on the adjacency graph .
267
18
42,327
public static int getShifts ( final AdjacencyGraph adjacencyGraph , final String part ) { int current_shift = - 1 ; int shifts = 0 ; char [ ] parts = part . toCharArray ( ) ; for ( int i1 = 0 ; i1 < parts . length ; i1 ++ ) { Character character = parts [ i1 ] ; if ( i1 + 1 >= parts . length ) { continue ; } Character ...
Returns the number of shifts in case in the part passed in .
269
13
42,328
public static String generatePassphrase ( final String delimiter , final int words ) { return generatePassphrase ( delimiter , words , new Dictionary ( "eff_large" , DictionaryUtil . loadUnrankedDictionary ( DictionaryUtil . eff_large ) , false ) ) ; }
Generates a passphrase from the eff_large standard dictionary with the requested word count .
60
18
42,329
public static String generatePassphrase ( final String delimiter , final int words , final Dictionary dictionary ) { String result = "" ; final SecureRandom rnd = new SecureRandom ( ) ; final int high = dictionary . getSortedDictionary ( ) . size ( ) ; for ( int i = 1 ; i <= words ; i ++ ) { result += dictionary . getS...
Generates a passphrase from the supplied dictionary with the requested word count .
113
15
42,330
public static String generateRandomPassword ( final CharacterTypes characterTypes , final int length ) { final StringBuffer buffer = new StringBuffer ( ) ; String characters = "" ; switch ( characterTypes ) { case ALPHA : characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" ; break ; case ALPHANUMERIC : ...
Generates a random password of the specified length with the specified characters .
282
14
42,331
private static Match createBruteForceMatch ( final String password , final Configuration configuration , final int index ) { return new BruteForceMatch ( password . charAt ( index ) , configuration , index ) ; }
Creates a brute force match for a portion of the password .
43
13
42,332
public static Double getEntropyFromGuesses ( final BigDecimal guesses ) { Double guesses_tmp = guesses . doubleValue ( ) ; guesses_tmp = guesses_tmp . isInfinite ( ) ? Double . MAX_VALUE : guesses_tmp ; return Math . log ( guesses_tmp ) / Math . log ( 2 ) ; }
Gets the entropy from the number of guesses passed in .
71
12
42,333
public static BigDecimal getGuessesFromEntropy ( final Double entropy ) { final Double guesses_tmp = Math . pow ( 2 , entropy ) ; return new BigDecimal ( guesses_tmp . isInfinite ( ) ? Double . MAX_VALUE : guesses_tmp ) . setScale ( 0 , RoundingMode . HALF_UP ) ; }
Gets the number of guesses from the entropy passed in .
75
12
42,334
public static void main ( String ... args ) { Configuration configuration = new ConfigurationBuilder ( ) . createConfiguration ( ) ; Nbvcxz nbvcxz = new Nbvcxz ( configuration ) ; ResourceBundle resourceBundle = ResourceBundle . getBundle ( "main" , nbvcxz . getConfiguration ( ) . getLocale ( ) ) ; Scanner scanner = ne...
Console application which will run with default configurations .
693
9
42,335
private List < Match > findBestCombination ( final String password , final List < Match > all_matches , final Map < Integer , Match > brute_force_matches ) throws TimeoutException { if ( configuration . getCombinationAlgorithmTimeout ( ) <= 0 ) { throw new TimeoutException ( "findBestCombination algorithm disabled." ) ...
Finds the most optimal matches by recursively building out every combination possible and returning the best .
700
20
42,336
private void generateMatches ( final long start_time , final String password , final Match match , final Map < Match , List < Match > > non_intersecting_matches , final Map < Integer , Match > brute_force_matches , final List < Match > matches , int matches_length ) throws TimeoutException { if ( System . currentTimeMi...
Recursive function to generate match combinations to get an optimal match .
459
13
42,337
private double calcEntropy ( final List < Match > matches , final boolean include_brute_force ) { double entropy = 0 ; for ( Match match : matches ) { if ( include_brute_force || ! ( match instanceof BruteForceMatch ) ) { entropy += match . calculateEntropy ( ) ; } } return entropy ; }
Helper method to calculate entropy from a list of matches .
73
11
42,338
private List < Match > getAllMatches ( final Configuration configuration , final String password ) { List < Match > matches = new ArrayList <> ( ) ; for ( PasswordMatcher passwordMatcher : configuration . getPasswordMatchers ( ) ) { matches . addAll ( passwordMatcher . match ( configuration , password ) ) ; } keepLowes...
Gets all matches for a given password .
83
9
42,339
private boolean isValid ( ) { StringBuilder builder = new StringBuilder ( ) ; for ( Match match : matches ) { builder . append ( match . getToken ( ) ) ; } return password . equals ( builder . toString ( ) ) ; }
Checks if the sum of the matches equals the original password .
52
13
42,340
public BigDecimal getGuesses ( ) { final Double guesses_tmp = Math . pow ( 2 , getEntropy ( ) ) ; return new BigDecimal ( guesses_tmp . isInfinite ( ) ? Double . MAX_VALUE : guesses_tmp ) . setScale ( 0 , RoundingMode . HALF_UP ) ; }
The estimated number of tries required to crack this password
72
10
42,341
public boolean isRandom ( ) { boolean is_random = true ; for ( Match match : matches ) { if ( ! ( match instanceof BruteForceMatch ) ) { is_random = false ; break ; } } return is_random ; }
Returns whether the password is considered to be random .
52
10
42,342
public int getBasicScore ( ) { final BigDecimal guesses = getGuesses ( ) ; if ( guesses . compareTo ( BigDecimal . valueOf ( 1e3 ) ) == - 1 ) return 0 ; else if ( guesses . compareTo ( BigDecimal . valueOf ( 1e6 ) ) == - 1 ) return 1 ; else if ( guesses . compareTo ( BigDecimal . valueOf ( 1e8 ) ) == - 1 ) return 2 ; e...
This scoring function returns an int from 0 - 4 to indicate the score of this password using the same semantics as zxcvbn .
132
27
42,343
private static List < String > translateLeet ( final Configuration configuration , final String password ) { final List < String > translations = new ArrayList ( ) ; final TreeMap < Integer , Character [ ] > replacements = new TreeMap <> ( ) ; for ( int i = 0 ; i < password . length ( ) ; i ++ ) { final Character [ ] r...
Removes all leet substitutions from the password and returns a list of plain text versions .
240
19
42,344
private static void replaceAtIndex ( final TreeMap < Integer , Character [ ] > replacements , Integer current_index , final char [ ] password , final List < String > final_passwords ) { for ( final char replacement : replacements . get ( current_index ) ) { password [ current_index ] = replacement ; if ( current_index ...
Internal function to recursively build the list of un - leet possibilities .
155
16
42,345
private static List < Character [ ] > getLeetSub ( final String password , final String unleet_password ) { List < Character [ ] > leet_subs = new ArrayList <> ( ) ; for ( int i = 0 ; i < unleet_password . length ( ) ; i ++ ) { if ( password . charAt ( i ) != unleet_password . charAt ( i ) ) { leet_subs . add ( new Cha...
Gets the substitutions for the password .
133
9
42,346
private static ValidDateSplit isDateValid ( String day , String month , String year ) { try { int dayInt = Integer . parseInt ( day ) ; int monthInt = Integer . parseInt ( month ) ; int yearInt = Integer . parseInt ( year ) ; if ( dayInt <= 0 || dayInt > 31 || monthInt <= 0 || monthInt > 12 || yearInt <= 0 || ( yearInt...
Verify that a date is valid . Year must be two digit or four digit and between 1900 and 2029 .
138
23
42,347
public static double fractionOfStringUppercase ( String input ) { if ( input == null ) { return 0 ; } double upperCasableCharacters = 0 ; double upperCount = 0 ; for ( int i = 0 ; i < input . length ( ) ; i ++ ) { char c = input . charAt ( i ) ; char uc = Character . toUpperCase ( c ) ; char lc = Character . toLowerCas...
Of the characters in the string that have an uppercase form how many are uppercased?
192
20
42,348
public static BigDecimal getTimeToCrack ( final Result result , final String guess_type ) { BigDecimal guess_per_second = BigDecimal . valueOf ( result . getConfiguration ( ) . getGuessTypes ( ) . get ( guess_type ) ) ; return result . getGuesses ( ) . divide ( guess_per_second , 0 , BigDecimal . ROUND_FLOOR ) ; }
Gets the estimated time to crack in seconds .
92
10
42,349
public static String getTimeToCrackFormatted ( final Result result , final String guess_type ) { ResourceBundle mainResource = result . getConfiguration ( ) . getMainResource ( ) ; BigDecimal seconds = getTimeToCrack ( result , guess_type ) ; BigDecimal minutes = new BigDecimal ( 60 ) ; BigDecimal hours = minutes . mul...
Gets the estimated time to crack formatted as a string .
764
12
42,350
public DictionaryBuilder addWord ( final String word , final int rank ) { this . dictonary . put ( word . toLowerCase ( ) , rank ) ; return this ; }
Add word to dictionary .
38
5
42,351
@ SuppressLint ( "MissingPermission" ) @ RequiresPermission ( anyOf = { ACCESS_COARSE_LOCATION , ACCESS_FINE_LOCATION } ) public Observable < Beacon > observe ( ) { if ( ! isBleSupported ( ) ) { return Observable . empty ( ) ; } if ( isAtLeastAndroidLollipop ( ) ) { scanStrategy = new LollipopScanStrategy ( bluetoothAd...
Creates an observable stream of BLE beacons which can be subscribed with RxJava Uses appropriate BLE scan strategy according to Android version installed on a device
149
31
42,352
public static < I , D > List < Word < I > > findMalerPnueli ( Query < I , D > ceQuery ) { return ceQuery . getInput ( ) . suffixes ( false ) ; }
Returns all suffixes of the counterexample word as distinguishing suffixes as suggested by Maler &amp ; Pnueli .
48
28
42,353
public static < I , D > List < Word < I > > findShahbaz ( Query < I , D > ceQuery , AccessSequenceTransformer < I > asTransformer ) { Word < I > queryWord = ceQuery . getInput ( ) ; int queryLen = queryWord . length ( ) ; Word < I > prefix = ceQuery . getPrefix ( ) ; int i = prefix . length ( ) ; while ( i <= queryLen ...
Returns all suffixes of the counterexample word as distinguishing suffixes after stripping a maximal one - letter extension of an access sequence as suggested by Shahbaz .
158
34
42,354
@ 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 ...
Try to compute a replacement for a ADT sub - tree that extends the parent ADS .
479
18
42,355
private static CompactDFA < Character > constructSUL ( ) { // input alphabet contains characters 'a'..'b' Alphabet < Character > sigma = Alphabets . characters ( ' ' , ' ' ) ; // @formatter:off // create automaton return AutomatonBuilders . newDFA ( sigma ) . withInitial ( "q0" ) . from ( "q0" ) . on ( ' ' ) . to ( "q1...
creates example from Angluin s seminal paper .
244
11
42,356
public static < I > DFACacheOracle < I > createDAGCacheOracle ( Alphabet < I > alphabet , MembershipOracle < I , Boolean > delegate ) { return new DFACacheOracle <> ( new IncrementalDFADAGBuilder <> ( alphabet ) , delegate ) ; }
Creates a cache oracle for a DFA learning setup using a DAG for internal cache organization .
61
21
42,357
public static < S , I , O > int computeEffectiveResets ( final ADTNode < S , I , O > adt ) { return computeEffectiveResetsInternal ( adt , 0 ) ; }
Computes how often reset nodes are encountered when traversing from the given node to the leaves of the induced subtree of the given node .
44
28
42,358
public static < S , I , O > ADTNode < S , I , O > buildADSFromObservation ( final Word < I > input , final Word < O > output , final S finalState ) { if ( input . size ( ) != output . size ( ) ) { throw new IllegalArgumentException ( "Arguments differ in length" ) ; } final Iterator < I > inputIterator = input . iterat...
Build a single trace ADS from the given information .
282
10
42,359
@ Nonnull public List < S > bfsStates ( ) { List < S > stateList = new ArrayList <> ( ) ; Set < S > visited = new HashSet <> ( ) ; int ptr = 0 ; stateList . add ( root ) ; visited . add ( root ) ; int numStates = 1 ; while ( ptr < numStates ) { S curr = stateList . get ( ptr ++ ) ; for ( int i = 0 ; i < alphabetSize ; ...
Retrieves a list of all states in this PTA that are reachable from the root state . The states will be returned in breadth - first order .
153
32
42,360
@ Nonnull public Iterator < S > bfsIterator ( ) { Set < S > visited = new HashSet <> ( ) ; final Deque < S > bfsQueue = new ArrayDeque <> ( ) ; bfsQueue . add ( root ) ; visited . add ( root ) ; return new AbstractIterator < S > ( ) { @ Override protected S computeNext ( ) { S next = bfsQueue . poll ( ) ; if ( next == ...
Retrieves an iterator that can be used for iterating over all states in this PTA that are reachable from the root state in a breadth - first order .
170
34
42,361
protected List < List < Row < I > > > incorporateCounterExample ( DefaultQuery < I , D > ce ) { return ObservationTableCEXHandlers . handleClassicLStar ( ce , table , oracle ) ; }
Incorporates the information provided by a counterexample into the observation data structure .
48
19
42,362
protected boolean completeConsistentTable ( List < List < Row < I > > > unclosed , boolean checkConsistency ) { boolean refined = false ; List < List < Row < I > > > unclosedIter = unclosed ; do { while ( ! unclosedIter . isEmpty ( ) ) { List < Row < I >> closingRows = selectClosingRows ( unclosedIter ) ; unclosedIter ...
Iteratedly checks for unclosedness and inconsistencies in the table and fixes any occurrences thereof . This process is repeated until the observation table is both closed and consistent .
225
33
42,363
protected Word < I > analyzeInconsistency ( Inconsistency < I > incons ) { int inputIdx = alphabet . getSymbolIndex ( incons . getSymbol ( ) ) ; Row < I > succRow1 = incons . getFirstRow ( ) . getSuccessor ( inputIdx ) ; Row < I > succRow2 = incons . getSecondRow ( ) . getSuccessor ( inputIdx ) ; int numSuffixes = tabl...
Analyzes an inconsistency . This analysis consists in determining the column in which the two successor rows differ .
240
20
42,364
public static < N extends AbstractDTNode < ? , ? , ? , N > > Iterator < N > nodeIterator ( N root ) { return new NodeIterator <> ( root ) ; }
Iterator that traverses all nodes of a subtree of a given discrimination tree node .
41
17
42,365
@ Nullable @ Override public DefaultQuery < I , D > disprove ( A hypothesis , Collection < ? extends I > inputs ) throws ModelCheckingException { final DefaultQuery < I , D > result = propertyOracle . disprove ( hypothesis , inputs ) ; if ( result != null ) { LOGGER . logEvent ( "Property violated: '" + toString ( ) + ...
Try to disprove this propertyOracle and log whenever it is disproved .
110
15
42,366
@ Nullable @ Override public DefaultQuery < I , D > doFindCounterExample ( A hypothesis , Collection < ? extends I > inputs ) throws ModelCheckingException { final DefaultQuery < I , D > result = propertyOracle . findCounterExample ( hypothesis , inputs ) ; if ( result != null ) { LOGGER . logEvent ( "Spurious countere...
Try to find a counterexample to the given hypothesis and log whenever such a spurious counterexample is found .
121
25
42,367
protected RedBlueMerge < SP , TP , BlueFringePTAState < SP , TP > > tryMerge ( BlueFringePTA < SP , TP > pta , BlueFringePTAState < SP , TP > qr , BlueFringePTAState < SP , TP > qb ) { return pta . tryMerge ( qr , qb ) ; }
Attempts to merge a blue state into a red state .
84
11
42,368
public SampleSetEQOracle < I , D > add ( Word < I > input , D expectedOutput ) { testQueries . add ( new DefaultQuery <> ( input , expectedOutput ) ) ; return this ; }
Adds a query word along with its expected output to the sample set .
47
14
42,369
@ SafeVarargs public final SampleSetEQOracle < I , D > addAll ( MembershipOracle < I , D > oracle , Word < I > ... words ) { return addAll ( oracle , Arrays . asList ( words ) ) ; }
Adds several query words to the sample set . The expected output is determined by means of the specified membership oracle .
55
23
42,370
public SampleSetEQOracle < I , D > addAll ( MembershipOracle < I , D > oracle , Collection < ? extends Word < I > > words ) { if ( words . isEmpty ( ) ) { return this ; } List < DefaultQuery < I , D > > newQueries = new ArrayList <> ( words . size ( ) ) ; for ( Word < I > w : words ) { newQueries . add ( new DefaultQue...
Adds words to the sample set . The expected output is determined by means of the specified membership oracle .
133
21
42,371
protected static < I , D > void fetchResults ( Iterator < DefaultQuery < I , D > > queryIt , List < D > output , int numSuffixes ) { for ( int j = 0 ; j < numSuffixes ; j ++ ) { DefaultQuery < I , D > qry = queryIt . next ( ) ; output . add ( qry . getOutput ( ) ) ; } }
Fetches the given number of query responses and adds them to the specified output list . Also the query iterator is advanced accordingly .
90
26
42,372
private QueryResult < S , O > filterAndProcessQuery ( Word < I > query , Word < O > partialOutput , Function < Word < I > , QueryResult < S , O > > processQuery ) { final LinkedList < I > filteredQueryList = new LinkedList <> ( query . asList ( ) ) ; final Iterator < I > queryIterator = filteredQueryList . iterator ( )...
Filters all the query elements corresponding to reflexive edges in the reuse tree executes the shorter query and fills the filtered outputs into the resulting output word .
278
30
42,373
public static < S , I , D > int findLinear ( Query < I , D > ceQuery , AccessSequenceTransformer < I > asTransformer , SuffixOutput < I , D > hypOutput , MembershipOracle < I , D > oracle ) { return AcexLocalSuffixFinder . findSuffixIndex ( AcexAnalyzers . LINEAR_FWD , true , ceQuery , asTransformer , hypOutput , oracl...
Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations in linear ascending order .
101
24
42,374
public static < I , D > int findLinearReverse ( Query < I , D > ceQuery , AccessSequenceTransformer < I > asTransformer , SuffixOutput < I , D > hypOutput , MembershipOracle < I , D > oracle ) { return AcexLocalSuffixFinder . findSuffixIndex ( AcexAnalyzers . LINEAR_BWD , true , ceQuery , asTransformer , hypOutput , or...
Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations in linear descending order .
102
24
42,375
public static < I , D > int findRivestSchapire ( Query < I , D > ceQuery , AccessSequenceTransformer < I > asTransformer , SuffixOutput < I , D > hypOutput , MembershipOracle < I , D > oracle ) { return AcexLocalSuffixFinder . findSuffixIndex ( AcexAnalyzers . BINARY_SEARCH_BWD , true , ceQuery , asTransformer , hypOut...
Searches for a distinguishing suffixes by checking for counterexample yielding access sequence transformations using a binary search as proposed by Rivest &amp ; Schapire .
107
35
42,376
private void closeTransition ( final ADTTransition < I , O > transition ) { if ( ! transition . needsSifting ( ) ) { return ; } final Word < I > accessSequence = transition . getSource ( ) . getAccessSequence ( ) ; final I symbol = transition . getInput ( ) ; this . oracle . reset ( ) ; for ( final I i : accessSequence...
Close the given transitions by means of sifting the associated long prefix through the ADT .
379
18
42,377
private void ensureConsistency ( final ADTNode < ADTState < I , O > , I , O > leaf ) { final ADTState < I , O > state = leaf . getHypothesisState ( ) ; final Word < I > as = state . getAccessSequence ( ) ; final Word < O > asOut = this . hypothesis . computeOutput ( as ) ; ADTNode < ADTState < I , O > , I , O > iter = ...
Ensure that the output behavior of a hypothesis state matches the observed output behavior recorded in the ADT . Any differences in output behavior yields new counterexamples .
257
33
42,378
private boolean validateADS ( final ADTNode < ADTState < I , O > , I , O > oldADS , final ADTNode < ADTState < I , O > , I , O > newADS , final Set < ADTState < I , O > > cutout ) { final Set < ADTNode < ADTState < I , O > , I , O > > oldNodes ; if ( ADTUtil . isResetNode ( oldADS ) ) { oldNodes = ADTUtil . collectRese...
Validate the well - definedness of an ADT replacement i . e . both ADTs cover the same set of hypothesis states and the output behavior described in the replacement matches the hypothesis output .
681
39
42,379
public void initialize ( final Collection < S > states , final Function < S , Word < I > > asFunction , final Function < Word < I > , Word < O > > outputFunction ) { final FastMealyState < O > init = this . observationTree . addInitialState ( ) ; for ( final S s : states ) { final Word < I > as = asFunction . apply ( s...
Extended initialization method that allows to initialize the observation tree with several hypothesis states .
136
16
42,380
public void addState ( final S newState , final Word < I > accessSequence , final O output ) { final Word < I > prefix = accessSequence . prefix ( accessSequence . length ( ) - 1 ) ; final I sym = accessSequence . lastSymbol ( ) ; final FastMealyState < O > pred = this . observationTree . getSuccessor ( this . observat...
Registers a new hypothesis state at the observation tree . It is expected to register states in the order of their discovery meaning whenever a new state is added information about all prefixes of its access sequence are already stored . Therefore providing only the output of the last symbol of its access sequence is s...
197
59
42,381
public Optional < Word < I > > findSeparatingWord ( final S s1 , final S s2 , final Word < I > prefix ) { final FastMealyState < O > n1 = this . nodeToObservationMap . get ( s1 ) ; final FastMealyState < O > n2 = this . nodeToObservationMap . get ( s2 ) ; final FastMealyState < O > s1Succ = this . observationTree . get...
Find a separating word for two hypothesis states after applying given input sequence first .
228
15
42,382
public Word < I > findSeparatingWord ( final S s1 , final S s2 ) { final FastMealyState < O > n1 = this . nodeToObservationMap . get ( s1 ) ; final FastMealyState < O > n2 = this . nodeToObservationMap . get ( s2 ) ; return NearLinearEquivalenceTest . findSeparatingWord ( this . observationTree , n1 , n2 , this . alpha...
Find a separating word for two hypothesis states .
108
9
42,383
protected static < I , D > void link ( AbstractBaseDTNode < I , D > dtNode , TTTState < I , D > state ) { assert dtNode . isLeaf ( ) ; dtNode . setData ( state ) ; state . dtLeaf = dtNode ; }
Establish the connection between a node in the discrimination tree and a state of the hypothesis .
67
18
42,384
protected void initializeState ( TTTState < I , D > state ) { for ( int i = 0 ; i < alphabet . size ( ) ; i ++ ) { I sym = alphabet . getSymbol ( i ) ; TTTTransition < I , D > trans = createTransition ( state , sym ) ; trans . setNonTreeTarget ( dtree . getRoot ( ) ) ; state . setTransition ( i , trans ) ; openTransiti...
Initializes a state . Creates its outgoing transition objects and adds them to the open list .
107
19
42,385
private void splitState ( TTTTransition < I , D > transition , Word < I > tempDiscriminator , D oldOut , D newOut ) { assert ! transition . isTree ( ) ; notifyPreSplit ( transition , tempDiscriminator ) ; AbstractBaseDTNode < I , D > dtNode = transition . getNonTreeTarget ( ) ; assert dtNode . isLeaf ( ) ; TTTState < I...
Splits a state in the hypothesis using a temporary discriminator . The state to be split is identified by an incoming non - tree transition . This transition is subsequently turned into a spanning tree transition .
249
39
42,386
protected boolean finalizeAny ( ) { GlobalSplitter < I , D > splitter = findSplitterGlobal ( ) ; if ( splitter != null ) { finalizeDiscriminator ( splitter . blockRoot , splitter . localSplitter ) ; return true ; } return false ; }
Chooses a block root and finalizes the corresponding discriminator .
62
13
42,387
protected TTTState < I , D > getAnyTarget ( TTTTransition < I , D > trans ) { if ( trans . isTree ( ) ) { return trans . getTreeTarget ( ) ; } return trans . getNonTreeTarget ( ) . anySubtreeState ( ) ; }
Retrieves the target state of a given transition . This method works for both tree and non - tree transitions . If a non - tree transition points to a non - leaf node it is updated accordingly before a result is obtained .
63
46
42,388
private TTTState < I , D > getAnyState ( Iterable < ? extends I > suffix ) { return getAnySuccessor ( hypothesis . getInitialState ( ) , suffix ) ; }
Retrieves the state reached by the given sequence of symbols starting from the initial state .
41
18
42,389
protected D query ( Word < I > prefix , Word < I > suffix ) { return oracle . answerQuery ( prefix , suffix ) ; }
Performs a membership query .
30
6
42,390
protected D query ( AccessSequenceProvider < I > accessSeqProvider , Word < I > suffix ) { return query ( accessSeqProvider . getAccessSequence ( ) , suffix ) ; }
Performs a membership query using an access sequence as its prefix .
42
13
42,391
public static < E > int linearSearchFwd ( AbstractCounterexample < E > acex , int low , int high ) { assert ! acex . testEffects ( low , high ) ; E effPrev = acex . effect ( low ) ; for ( int i = low + 1 ; i <= high ; i ++ ) { E eff = acex . effect ( i ) ; if ( ! acex . checkEffects ( effPrev , eff ) ) { return i - 1 ;...
Scan linearly through the counterexample in ascending order .
120
13
42,392
public static < E > int exponentialSearchBwd ( AbstractCounterexample < E > acex , int low , int high ) { assert ! acex . testEffects ( low , high ) ; int ofs = 1 ; E effHigh = acex . effect ( high ) ; int highIter = high ; int lowIter = low ; while ( highIter - ofs > lowIter ) { int next = highIter - ofs ; E eff = ace...
Search for a suffix index using an exponential search .
156
10
42,393
public E insert ( E element ) { E evicted = null ; if ( size ( ) >= capacity ) { if ( evictPolicy == EvictPolicy . REJECT_NEW ) { // reject the new element return element ; } // Evict first, so we do not need to resize evicted = evict ( ) ; } deque . offerLast ( element ) ; return evicted ; }
Inserts an element into the deque and returns the one that had to be evicted in case of a capacity violation .
81
25
42,394
public ADTNode < S , I , O > sift ( final SymbolQueryOracle < I , O > oracle , final Word < I > word , final ADTNode < S , I , O > subtree ) { ADTNode < S , I , O > current = subtree ; while ( ! ADTUtil . isLeafNode ( current ) ) { current = current . sift ( oracle , word ) ; } return current ; }
Successively sifts a word through the ADT induced by the given node . Stops when reaching a leaf .
98
23
42,395
public ADTNode < S , I , O > extendLeaf ( final ADTNode < S , I , O > nodeToSplit , final Word < I > distinguishingSuffix , final Word < O > oldOutput , final Word < O > newOutput ) { if ( ! ADTUtil . isLeafNode ( nodeToSplit ) ) { throw new IllegalArgumentException ( "Node to split is not a leaf node" ) ; } if ( ! ( d...
Splitting a leaf node by extending the trace leading into the node to split .
248
16
42,396
public LCAInfo < S , I , O > findLCA ( final ADTNode < S , I , O > s1 , final ADTNode < S , I , O > s2 ) { final Map < ADTNode < S , I , O > , ADTNode < S , I , O > > s1ParentsToS1 = new HashMap <> ( ) ; ADTNode < S , I , O > s1Iter = s1 ; ADTNode < S , I , O > s2Iter = s2 ; while ( s1Iter . getParent ( ) != null ) { s...
Return the lowest common ancestor for the given two nodes .
411
11
42,397
@ Nonnull public static String getResults ( ) { StringBuilder sb = new StringBuilder ( ) ; for ( Entry < String , Counter > e : CUMULATED . entrySet ( ) ) { sb . append ( e . getValue ( ) . getSummary ( ) ) . append ( ", (" ) . append ( e . getValue ( ) . getCount ( ) / MILLISECONDS_PER_SECOND ) . append ( " s)" ) . ap...
Get profiling results as string .
123
6
42,398
public static void logResults ( ) { for ( Entry < String , Counter > e : CUMULATED . entrySet ( ) ) { LOGGER . logProfilingInfo ( e . getValue ( ) ) ; } }
Log results in category PROFILING .
47
9
42,399
public static < I , O > MealyCacheOracle < I , O > createDAGCache ( Alphabet < I > alphabet , MembershipOracle < I , Word < O > > mqOracle ) { return MealyCacheOracle . createDAGCacheOracle ( alphabet , mqOracle ) ; }
Creates a cache oracle for a Mealy machine learning setup using a DAG for internal cache organization .
62
22