Class NumericSULVerifier

java.lang.Object
net.maswag.falcaun.verification.NumericSULVerifier
All Implemented Interfaces:
AutoCloseable

public class NumericSULVerifier extends Object implements AutoCloseable
Verifies a Numeric System Under Learning (NumericSUL) against specified properties using various equivalence oracles and model checking techniques.

This class provides a framework for verifying the behavior of a numeric system under learning by comparing it against a set of Signal Temporal Logic (STL) properties. It uses learning algorithms, equivalence oracles, and model checkers to identify any discrepancies between the expected and actual behaviors.

Author:
Masaki Waga <masakiwaga@gmail.com>
  • Field Details

  • Constructor Details

    • NumericSULVerifier

      public NumericSULVerifier(NumericSUL sul, double signalStep, AdaptiveSTLUpdater<List<Double>> properties, SignalDiscretizer signalDiscretizer)

      Constructor for NumericSULVerifier.

      Parameters:
      sul - The system under test.
      signalStep - The signal step in the simulation
      properties - The LTL properties to be verified
      signalDiscretizer - The I/O mapper between the abstract and concrete signals.
  • Method Details

    • addRobustnessEqOracle

      void addRobustnessEqOracle(Function<IOSignal<List<Double>>,Double> costFunc, Function<RobustnessOracle,? extends EvaluationCountable.MealyEquivalenceOracle<String,String>> constructor)
      Add an equivalence oracle guided by the robustness of the given cost function. The SUL executions and their caches are shared with the membership oracle.
    • addWpMethodEQOracle

      public void addWpMethodEQOracle(int maxDepth)
    • addBFOracle

      public void addBFOracle(double multiplier)
    • addRandomWordEQOracle

      public void addRandomWordEQOracle(int minLength, int maxLength, int maxTests, Random random, int batchSize)
    • addRandomWalkEQOracle

      public void addRandomWalkEQOracle(double restartProbability, long maxSteps, Random random)
    • addCompleteExplorationEQOracle

      public void addCompleteExplorationEQOracle(int minDepth, int maxDepth, int batchSize)
    • addCornerCaseEQOracle

      public void addCornerCaseEQOracle(int length, int minStep)
      Add a corner case equivalence oracle.

      This oracle tries the corner case input, i.e., the inputs with the same values

      Parameters:
      length - The length of the input.
      minStep - The minimum step of the corner case.
    • setTimeout

      public void setTimeout(long timeout)
      Set timeout to the equivalence oracle added next time.
      Parameters:
      timeout - timeout in seconds.
    • addHillClimbingEQOracle

      public void addHillClimbingEQOracle(TemporalLogic.STLCost costFunc, int length, Random random, int maxTests, int generationSize, int childrenSize, boolean resetWord)
    • addHillClimbingEQOracle

      public void addHillClimbingEQOracle(Function<IOSignal<List<Double>>,Double> costFunc, int length, Random random, int maxTests, int generationSize, int childrenSize, boolean resetWord, PropertyOracle.MealyPropertyOracle<String,String,String> ltlOracle)

      addHillClimbingEQOracle.

      Parameters:
      costFunc - a Function object.
      length - a int.
      random - a Random object.
      maxTests - a int.
      generationSize - a int.
      childrenSize - a int.
      resetWord - a boolean.
      ltlOracle - a PropertyOracle.MealyPropertyOracle object.
    • addHillClimbingEQOracleAll

      public void addHillClimbingEQOracleAll(int length, Random random, int maxTests, int generationSize, int childrenSize, boolean resetWord)
    • addSAEQOracle

      public void addSAEQOracle(Function<IOSignal<List<Double>>,Double> costFunc, int length, Random random, int maxTests, int generationSize, int childrenSize, boolean resetWord, double alpha, PropertyOracle.MealyPropertyOracle<String,String,String> ltlOracle)

      addSAEQOracle.

      Parameters:
      costFunc - a Function object.
      length - a int.
      random - a Random object.
      maxTests - a int.
      generationSize - a int.
      childrenSize - a int.
      resetWord - a boolean.
      alpha - a double.
      ltlOracle - a PropertyOracle.MealyPropertyOracle object.
    • addMutateSelectEQOracle

      void addMutateSelectEQOracle(Function<IOSignal<List<Double>>,Double> costFunc, int length, Random random, int maxTests, int generationSize, int childrenSize, int changeSize, boolean resetWord)
    • addGAEQOracle

      public void addGAEQOracle(Function<IOSignal<List<Double>>,Double> costFunc, int length, int maxTests, GASelectionKind selectionKind, int generationSize, double crossoverProb, double mutationProbability, PropertyOracle.MealyPropertyOracle<String,String,String> ltlOracle)
      add a Genetic algorithm-based equivalence oracle
      Parameters:
      costFunc - The cost function assigning a Double to each OutputSignal. This is typically an STL formula.
      length - length of the generated signals
      maxTests - maximum test size
      selectionKind - kind of the selection method
      generationSize - size of each generation. This must be an even number.
      crossoverProb - probability to have crossover
      mutationProbability - probability to have mutation
      ltlOracle - the LTL formula
    • concreteInput

      public Signal concreteInput(VerificationResult.Counterexample<?> cex)
      Returns the concrete input signal of a counterexample.
      Parameters:
      cex - a counterexample in the result of run()
      Returns:
      the concrete input signal constructed from the abstract input of cex
    • run

      public VerificationResult<List<Double>> run()
      Run black-box checking.
      Returns:
      the result of black-box checking including the statistics of the SUL executions
      See Also:
    • writeDOTCex

      public void writeDOTCex(VerificationResult.Counterexample<?> cex, Appendable a) throws IOException
      Wirte the DOT of the Mealy machine witnessing a counterexample.
      Parameters:
      cex - a counterexample in the result of run()
      a - Write the DOT to a
      Throws:
      IOException - The exception by GraphDOT.write
    • writeDOTLearnedMealy

      public void writeDOTLearnedMealy(Appendable a) throws IOException
      Wirte the DOT of the learned Mealy machine
      Parameters:
      a - Write the DOT to a
      Throws:
      IOException - The exception by GraphDOT.write
    • writeETFLearnedMealy

      public void writeETFLearnedMealy(OutputStream os)
      Write the ETF of the learned Mealy machine.
      Parameters:
      os - Write the ETF to os
    • visualizeCex

      public void visualizeCex(VerificationResult.Counterexample<?> cex)
      Visualize the Mealy machine witnessing a counterexample.
      Parameters:
      cex - a counterexample in the result of run()
    • visualizeLearnedMealy

      public void visualizeLearnedMealy()
      Visualize the learned Mealy machine
    • getSutExecutionCount

      public int getSutExecutionCount()
      Returns:
      the number of the executions of the SUL
    • getEqEvaluationCount

      public int getEqEvaluationCount()
      Returns the number of the evaluations of input words by the equivalence oracles.

      This is not necessarily the number of the SUL executions by the equivalence oracles. For example, the corner-case equivalence oracle counts every evaluated word, including the ones answered by a cache, while the robustness-based equivalence oracles count only the actual executions.

      Returns:
      the number of the evaluations of input words by the equivalence oracles
    • getProperties

      public AdaptiveSTLUpdater<List<Double>> getProperties()
      Returns:
      Signal Temporal Logic (STL) properties to be verified
    • addSAEQOracleAll

      public void addSAEQOracleAll(int length, Random random, int maxTest, int generationSize, int childrenSize, boolean resetWord, double alpha)
    • addGAEQOracleAll

      public void addGAEQOracleAll(int length, int maxTest, GASelectionKind selectionKind, int populationSize, double crossoverProb, double mutationProb)
    • close

      public void close() throws Exception
      Close the SUL, e.g., the MATLAB engine or the Python interpreter.
      Specified by:
      close in interface AutoCloseable
      Throws:
      Exception
    • getSimulationTimeSecond

      public double getSimulationTimeSecond()
      Returns:
      the execution time for the simulations