示例#1
0
        'errors': set()
    },
    log_path=f'{problem}_nomutation.log',
    write_on_change={'errors'})

# Try to learn a state machine for one of the RERS problems
#problem = "Problem12"
problemset = "TrainingSeqReachRers2019"

sul = RERSSOConnector(f"../../rers/{problemset}/{problem}/{problem}.so")

eqc = StackedChecker(
    # MutationEquivalenceChecker(sul, ct,
    #                            target_pop_size=100000,
    #                            cluster=False,
    #                            ),
    SmartWmethodEquivalenceCheckerV4(sul,
                                     horizon=12,
                                     stop_on={'invalid_input'},
                                     stop_on_startswith={'error'},
                                     order_type='ce count'))


# Store found counterexamples
def onct(ctex):
    ct.add(ctex)
    ct.save(f'counterexamples_{problem}_nomutation.p')


eqc.onCounterexample(onct)

# Set up the teacher, with the system under learning and the equivalence checker
        'equivalence_query': 0,
        'test_query': 0,
        'state_count': 0,
        'error_count': 0,
        'errors': set()
    },
    log_path=logdir.joinpath(f'{problem}_{now}_afl_wtraces.log'),
    write_on_change={'state_count', 'error_count'})

sul = RERSSOConnector(path)
afl_dir = f'/home/tom/projects/lstar/experiments/learningfuzzing/{problemset}/{problem}'
bin_path = f'/home/tom/projects/lstar/experiments/learningfuzzing/{problemset}/{problem}/{problem}'

eqc = StackedChecker(
    AFLEquivalenceCheckerV2(sul, afl_dir, bin_path, feedback='w_traces'),
    SmartWmethodEquivalenceCheckerV2(sul,
                                     horizon=horizon,
                                     stop_on={'invalid_input'},
                                     stop_on_startswith={'error'}))

# Set up the teacher, with the system under learning and the equivalence checker
teacher = Teacher(sul, eqc)

# Set up the learner who only talks to the teacher
learner = TTTMealyLearner(teacher)

# Get the learners hypothesis
hyp = learner.run(show_intermediate=False,
                  render_options={'ignore_self_edges': ['error', 'invalid']},
                  on_hypothesis=savehypothesis(
                      f'hypotheses/afl_plain/{problem}', f'{problem}'))
示例#3
0
        'membership_query': 0,
        'equivalence_query': 0,
        'test_query': 0,
        'state_count': 0,
        'error_count': 0,
        'errors': set()
    },
    log_path=f'{problem}_mutating.log',
    write_on_change={'errors'})

sul = RERSSOConnector(f"../../../rers/{problemset}/{problem}/{problem}.so")

eqc = StackedChecker(
    GeneticEquivalenceChecker(sul, ct, pop_n=10000),
    SmartWmethodEquivalenceCheckerV4(sul,
                                     horizon=12,
                                     stop_on={'invalid_input'},
                                     stop_on_startswith={'error'},
                                     order_type='ce count'))


# Store found counterexamples
def onct(ctex):
    ct.add(ctex)
    ct.save(f'counterexamples_{problem}.p')


eqc.onCounterexample(onct)

# Set up the teacher, with the system under learning and the equivalence checker
teacher = Teacher(sul, eqc)
示例#4
0
    write_on_change={'state_count', 'error_count'})

constrpath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/constraints-{problem}.txt'
mappingpath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/{problem}_alphabet_mapping_C_version.txt'

sul = RERSSOConnector(path)
# afl_dir = f'{args.afl_dir}/{problemset}/{problem}'
# bin_path = f'{args.afl_dir}/{problemset}/{problem}/{problem}'
afl_dir = f'{afl_basedir}/{problemset}/{problem}'
bin_path = f'{afl_basedir}/{problemset}/{problem}/{problem}'
eqc = StackedChecker(
    AFLEquivalenceCheckerV2(sul,
                            afl_dir,
                            bin_path,
                            eqchecktype=EQCheckType.BOTH,
                            enable_dtraces=True),
    NuSMVEquivalenceChecker(sul, constrpath, mappingpath),
    SmartWmethodEquivalenceCheckerV2(sul,
                                     horizon=horizon,
                                     stop_on={'invalid_input'},
                                     stop_on_startswith={'error'}),
)

# Set up the teacher, with the system under learning and the equivalence checker
teacher = Teacher(sul, eqc)

# Set up the learner who only talks to the teacher
learner = TTTMealyLearner(teacher)

# Get the learners hypothesis
hyp = learner.run(show_intermediate=False,
                  render_options={'ignore_self_edges': ['error', 'invalid']},
示例#5
0
        solutionspath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/constraints-solution-{problem}.txt'
    else:
        solutionspath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/constraints-solution.csv'

    path = f"../../rers/{problemset}/{problem}/{problem}.so"
    sul = RERSSOConnector(path)

    fuzzerpath = Path(f'/home/tom/projects/lstar/libfuzzer/{problemset}/{problem}')

    eqc = StackedChecker(
        LibFuzzerEquivalenceChecker(sul,
                                    corpus_path=fuzzerpath.joinpath("corpus"),
                                    fuzzer_path=fuzzerpath.joinpath(f'{problem}_fuzz')),
        SmartWmethodEquivalenceCheckerV2(sul,
                                         horizon=horizon,
                                         stop_on={'invalid_input'},
                                         stop_on_startswith={'error'}),
        #NuSMVEquivalenceChecker(sul, constrpath, mappingpath, n_unrolls=10),
        # SmartWmethodEquivalenceCheckerV2(sul,
        #                                  horizon=horizon,
        #                                  stop_on={'invalid_input'},
        #                                  stop_on_startswith={'error'})
    )

    # Set up the teacher, with the system under learning and the equivalence checker
    teacher = Teacher(sul, eqc)

    # Set up the learner who only talks to the teacher
    learner = TTTMealyLearner(teacher)

    # Get the learners hypothesis
    hyp = learner.run(
示例#6
0
    if '2020' in problemset:
        solutionspath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/constraints-solution-{problem}.txt'
    else:
        solutionspath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/constraints-solution.csv'

    path = f"../rers/{problemset}/{problem}/{problem}.so"
    sul = RERSSOConnector(path)

    horizon = 2

    eqc = StackedChecker(
        SmartWmethodEquivalenceCheckerV2(sul,
                                         horizon=horizon,
                                         stop_on={'invalid_input'},
                                         stop_on_startswith={'error'}),
        NuSMVEquivalenceChecker(sul, constrpath, mappingpath, n_unrolls=10),
        # SmartWmethodEquivalenceCheckerV2(sul,
        #                                  horizon=horizon,
        #                                  stop_on={'invalid_input'},
        #                                  stop_on_startswith={'error'})
    )

    # Set up the teacher, with the system under learning and the equivalence checker
    teacher = Teacher(sul, eqc)

    # Set up the learner who only talks to the teacher
    learner = TTTMealyLearner(teacher)

    # Get the learners hypothesis
    hyp = learner.run(show_intermediate=False, )
示例#7
0
    path = f"../../rers/{problemset}/{problem}/{problem}.so"
    sul = RERSSOConnector(path)

    fuzzerpath = Path(
        f'/home/tom/projects/lstar/libfuzzer/{problemset}/{problem}')

    eqc = StackedChecker(
        SmartWmethodEquivalenceCheckerV2(sul,
                                         horizon=1,
                                         stop_on={'invalid_input'},
                                         stop_on_startswith={'error'}),
        LibFuzzerEquivalenceChecker(
            sul,
            corpus_path=Path(fuzzerpath).joinpath("corpus"),
            fuzzer_path=Path(fuzzerpath).joinpath(f'{problem}_fuzz')),
        NuSMVEquivalenceChecker(sul,
                                constrpath,
                                mappingpath,
                                n_unrolls=1000,
                                enable_dtraces=True),
        SmartWmethodEquivalenceCheckerV2(sul,
                                         horizon=horizon,
                                         stop_on={'invalid_input'},
                                         stop_on_startswith={'error'}),
    )

    # Set up the teacher, with the system under learning and the equivalence checker
    teacher = Teacher(sul, eqc)

    # Set up the learner who only talks to the teacher
    learner = TTTMealyLearner(teacher)
示例#8
0
    def get_alphabet(self):
        return ('add', 'sub', 'exec', 'show')


if __name__ == "__main__":
    sul = ArithmeticTest()

    #sul.process_input(['add', 'exec', 'show'])

    ct = CounterexampleTracker()

    eqc = SmartWmethodEquivalenceChecker(sul, horizon=3)

    eqc = StackedChecker(
        GeneticEquivalenceChecker(sul, ct, pop_n=100000),
        SmartWmethodEquivalenceChecker(sul, horizon=3, order_type='ce count'))

    eqc.onCounterexample(lambda ce: ct.add(ce))

    teacher = Teacher(sul, eqc)

    # We are learning a mealy machine
    learner = MealyLearner(teacher)

    def print_stats(hyp=None):
        print("Member queries:", teacher.member_query_counter)
        print("Equivalence queries:", teacher.equivalence_query_counter)
        print("Test queries:", teacher.test_query_counter)

    hyp = learner.run(show_intermediate=False, on_hypothesis=print_stats)
示例#9
0
    from learners.TTTmealylearner import TTTMealyLearner
    from suls.caches.rerstriecache import RersTrieCache
    from suls.rersconnectorv4 import RERSConnectorV4
    from teachers.teacher import Teacher
    from rers.check_result import check_result

    problem = "Problem12"
    problemset = "TrainingSeqReachRers2019"

    sul = RERSSOConnector(f"../rers/{problemset}/{problem}/{problem}.so")
    #sul = RERSConnectorV4(f'../rers/TrainingSeqReachRers2019/{problem}/{problem}')

    eqc = StackedChecker(
        BlockCopyEquivalenceChecker(sul, 3),
        SmartWmethodEquivalenceCheckerV2(sul,
                                         horizon=8,
                                         stop_on={'invalid_input'},
                                         stop_on_startswith={'error'})
    )

    teacher = Teacher(sul, eqc)
    learner = TTTMealyLearner(teacher)

    # Get the learners hypothesis
    hyp = learner.run(
        show_intermediate=True,
        render_options={'ignore_self_edges': ['error', 'invalid']},
        on_hypothesis=lambda x: check_result(x,
                                             f'../rers/TrainingSeqReachRers2019/{problem}/reachability-solution-{problem}.csv')
    )
示例#10
0
        'state_count': 0,
        'error_count': 0,
        'errors': set()
    },
    log_path=logdir.joinpath(f'{problem}_{now}_reach.log'),
    write_on_change={'state_count', 'error_count'})

sul = RERSSOConnector(path)
afl_dir = f'{args.afl_dir}/{problemset}/{problem}'
bin_path = f'{args.afl_dir}/{problemset}/{problem}/{problem}'

eqc = StackedChecker(
    AFLEquivalenceCheckerV2(sul,
                            afl_dir,
                            bin_path,
                            eqchecktype=EQCheckType.BOTH),
    SmartWmethodEquivalenceCheckerV2(sul,
                                     horizon=horizon,
                                     stop_on={'invalid_input'},
                                     stop_on_startswith={'error'}))

# Set up the teacher, with the system under learning and the equivalence checker
teacher = Teacher(sul, eqc)

# Set up the learner who only talks to the teacher
learner = TTTMealyLearner(teacher)

# Get the learners hypothesis
hyp = learner.run(show_intermediate=False,
                  render_options={'ignore_self_edges': ['error', 'invalid']},
                  on_hypothesis=savehypothesis(f'hypotheses/reach/{problem}',
示例#11
0
    constrpath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/constraints-{problem}.txt'
    mappingpath = f'/home/tom/projects/lstar/rers/{problemset}/{problem}/{problem}_alphabet_mapping_C_version.txt'

    sul = RERSSOConnector(path)

    afl_dir = f'{afl_basedir}/{problemset}/{problem}'
    bin_path = f'{afl_basedir}/{problemset}/{problem}/{problem}'
    eqc = StackedChecker(
        # SmartWmethodEquivalenceCheckerV2(sul,
        #                                  horizon=1,
        #                                  stop_on={'invalid_input'},
        #                                  stop_on_startswith={'error'}),
        # AFLEquivalenceCheckerV2(sul, afl_dir, bin_path,
        #                         eqchecktype=EQCheckType.BOTH,
        #                         enable_dtraces=True),
        NuSMVEquivalenceChecker(sul, constrpath, mappingpath,
                                n_unrolls=1000,
                                enable_dtraces=True),
        # SmartWmethodEquivalenceCheckerV2(sul,
        #                                  horizon=horizon,
        #                                  stop_on={'invalid_input'},
        #                                  stop_on_startswith={'error'}),

    )

    # Set up the teacher, with the system under learning and the equivalence checker
    teacher = Teacher(sul, eqc)

    # Set up the learner who only talks to the teacher
    learner = TTTMealyLearner(teacher)
示例#12
0
if __name__ == "__main__":
    problem = "Problem12"

    sul = RersTrieCache(
        RERSConnectorV4(f'../rers/TrainingSeqReachRers2019/{problem}/{problem}'),
        storagepath="cache"
    )

    exec_path = f'../afl/TrainingSeqReachRers2019/{problem}/{problem}'
    #afl_path = '/home/tom/projects/lstar/afl/output'
    afl_path = '/tmp/afl/output'

    eqc = StackedChecker(
        AFLEquivalenceChecker(sul, exec_path, afl_out_dir=afl_path),
        SmartWmethodEquivalenceCheckerV2(sul,
                                         horizon=12,
                                         stop_on={'invalid_input'},
                                         stop_on_startswith={'error'})
    )

    teacher = Teacher(sul, eqc)

    learner = TTTMealyLearner(teacher)
    # learner.enable_checkpoints('checkpoints3')
    # learner.load_checkpoint('/home/tom/projects/lstar/experiments/counterexampletracker/checkpoints3/cZsmSu/2020-05-06_20:00:33:790987')
    # Get the learners hypothesis
    hyp = learner.run(
        show_intermediate=False,
        render_options={'ignore_self_edges': ['error', 'invalid']},
        on_hypothesis=lambda x: check_result(x,
                                             f'../rers/TrainingSeqReachRers2019/{problem}/reachability-solution-{problem}.csv')