Search in sources :

Example 1 with CompContractViolation

use of edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation in project AMASE by loonwerks.

the class SoteriaPrettyPrintVisitor method visit.

@Override
public Void visit(SoteriaModel model) {
    write(model.includeStr);
    newline();
    model.compLib.accept(this);
    newline();
    // create a model for each top level fault
    String firstModelName = null;
    for (CompContractViolation topLevelFault : model.topLevelFaults) {
        String modelName = "model_" + topLevelFault.contractString.replace(" ", "_");
        String compLibName = model.compLib.compLibName;
        writeln("(* ----- COMPONENT INSTANCES, CONNECTIONS, OUT RANGE TOP LEVEL FAULT ----- *)");
        writeln("let " + modelName + " = ");
        // write instances and connections declarations in the first model
        if (firstModelName == null) {
            firstModelName = modelName;
            writeln("{instances = ");
            write("[");
            for (SoteriaCompInst compInst : model.compInstList) {
                compInst.accept(this);
            }
            writeln("];");
            writeln("connections = ");
            write("[");
            for (SoteriaCompConnection connection : model.connectionList) {
                connection.accept(this);
            }
            writeln("];");
        } else // create references to the instances and connections declarations in subsequent models
        {
            writeln("{instances = " + firstModelName + ".instances;");
            writeln("connections=" + firstModelName + ".connections;");
        }
        // write top level fault for the model
        write("top_fault = (");
        write("\"" + topLevelFault.compName + "\", ");
        write("F[\"" + topLevelFault.contractString + "\"; ");
        write("\"" + topLevelFault.contractViolationFaultStr + "\"]");
        write(")");
        writeln("} ;;");
        newline();
        // create model checks
        createModelChecks(modelName, compLibName);
        // create pre-analyses model visualizations
        preAnalysesVisualizations(modelName, compLibName);
    // model analyses
    // TODO: uncomment the following after further investigation
    // with regard to why soteria model_to_ftree not able to handle more than
    // 5 conjunctions in a formula
    // modelAnalysesAndVisualization(modelName, compLibName);
    // create post-analyses model visualizations
    }
    return null;
}
Also used : CompContractViolation(edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation) SoteriaCompInst(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaCompInst) SoteriaCompConnection(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaCompConnection)

Example 2 with CompContractViolation

use of edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation in project AMASE by loonwerks.

the class IvcToSoteriaGenerator method extractContractIvcElem.

private void extractContractIvcElem(SoteriaComp comp, SoteriaFormulaSubgroup formulaSubgroup, String propertyName) {
    // add each ivc element that are verified contracts from subsequent layer to component inputs (sans duplicate)
    comp.addInput(propertyName);
    CompContractViolation contractViolation = new CompContractViolation(comp.componentName, propertyName);
    formulaSubgroup.addFormulaElem(contractViolation);
}
Also used : CompContractViolation(edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation)

Example 3 with CompContractViolation

use of edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation in project AMASE by loonwerks.

the class IvcToSoteriaGenerator method extractPropertyResult.

private void extractPropertyResult(SoteriaComp comp, AgreeRenaming renaming, PropertyResult propertyResult) {
    // get original property name
    String origPropertyName = propertyResult.getName();
    String lustreName = renaming.getLustreNameFromAgreeVar(origPropertyName);
    String propertyName = updateElemName(comp.componentName + "_" + lustreName);
    // if it is a guarantee
    if (lustreName.startsWith("__GUARANTEE")) {
        // if it's a valid guarantee
        if (propertyResult.getStatus().equals(jkind.api.results.Status.VALID)) {
            // add property as an output to the soteria map
            comp.addOutput(propertyName);
            // add property violation as a top level fault to the model
            if (!isLowerLevel) {
                CompContractViolation contractViolation = new CompContractViolation(comp.componentName, propertyName);
                model.addTopLevelFault(contractViolation);
            }
            ValidProperty property = (ValidProperty) propertyResult.getProperty();
            SoteriaFormula formula = new SoteriaFormula(propertyName);
            // handle multiple ivc sets
            for (List<String> ivcSet : property.getIvcSets()) {
                SoteriaFormulaSubgroup formulaSubgroup = new SoteriaFormulaSubgroup(propertyName);
                extractIvcSets(comp, renaming, formulaSubgroup, ivcSet);
                if (!formulaSubgroup.elmeList.isEmpty()) {
                    formula.addFormulaSubgroup(formulaSubgroup);
                }
            }
            if (!formula.formulaBody.isEmpty()) {
                comp.addFormula(propertyName, formula);
            }
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.CANCELED)) {
            throw new SafetyException("One of the properties was canceled in the process of model checking." + " Rerun this analysis to proceed.");
        } else if (propertyResult.getStatus().equals(jkind.api.results.Status.INVALID)) {
            throw new SafetyException("One of the properties is invalid. The model must be valid using AGREE Verify All Layers.");
        }
    }
}
Also used : CompContractViolation(edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation) ValidProperty(jkind.results.ValidProperty) SoteriaFormulaSubgroup(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormulaSubgroup) SoteriaFormula(edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula) SafetyException(edu.umn.cs.crisys.safety.analysis.SafetyException)

Aggregations

CompContractViolation (edu.umn.cs.crisys.safety.analysis.soteria.CompContractViolation)3 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)1 SoteriaCompConnection (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaCompConnection)1 SoteriaCompInst (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaCompInst)1 SoteriaFormula (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormula)1 SoteriaFormulaSubgroup (edu.umn.cs.crisys.safety.analysis.soteria.SoteriaFormulaSubgroup)1 ValidProperty (jkind.results.ValidProperty)1