Search in sources :

Example 1 with AgreeLayout

use of com.rockwellcollins.atc.agree.analysis.AgreeLayout in project AGREE by loonwerks.

the class AgreeProgramToSimulationProgram method transform.

public static SimulationProgram transform(final AgreeProgram agreeProgram, final SimulationProgramType type) {
    Objects.requireNonNull(agreeProgram, "agreeProgram must not be null");
    // Build a Component Instance to AgreeNode map
    final Program lustreProgram = LustreAstBuilder.getAssumeGuaranteeLustreProgram(agreeProgram);
    final AgreeRenaming agreeRenaming = new AgreeRenaming();
    final AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, agreeProgram.topNode.compInst, layout);
    SimulationProgram program;
    try {
        final SimulationProgramBuilder builder = new SimulationProgramBuilder(type, agreeProgram.topNode.compInst, lustreProgram, agreeRenaming);
        populateMetadata(builder, agreeProgram, lustreProgram, agreeRenaming, agreeRenaming.getRefMap());
        program = builder.build();
    } catch (final Exception ex) {
        throw new AGREESimulatorException(lustreProgram, ex);
    }
    try {
        program = CreateLocalVariablesForPropertyExpressions.transform(program);
        program = RemovePropertySatisficationRequirements.transform(program);
        program = RemoveCondacts.transform(program);
        program = InlineNodeCalls.transform(program);
        program = ReplaceFollowedByOperator.transform(program);
        program = ReplacePreOperator.transform(program);
        program = CreateSimulationProperties.transform(program);
        program = RemoveProperties.transform(program);
        program = CreateSimulationGuarantee.transform(program);
    } catch (final Exception ex) {
        throw new AGREESimulatorException(program.getLustreProgram(), ex);
    }
    return program;
}
Also used : SimulationProgram(edu.uah.rsesc.aadlsimulator.agree.SimulationProgram) Program(jkind.lustre.Program) SimulationProgram(edu.uah.rsesc.aadlsimulator.agree.SimulationProgram) AgreeProgram(com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) SimulationProgramBuilder(edu.uah.rsesc.aadlsimulator.agree.SimulationProgramBuilder) AGREESimulatorException(edu.uah.rsesc.aadlsimulator.agree.sim.AGREESimulatorException) AGREESimulatorException(edu.uah.rsesc.aadlsimulator.agree.sim.AGREESimulatorException)

Example 2 with AgreeLayout

use of com.rockwellcollins.atc.agree.analysis.AgreeLayout in project AGREE by loonwerks.

the class TcgLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    TcgRenaming renaming = new TcgRenaming(agreeRenaming, agreeRenaming.getRefMap());
    Node mainNode = lustreProgram.getMainNode();
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    JKindResult result;
    result = new JKindResult(resultName, properties, renaming);
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setAgreeProgram(result, agreeProgram);
    linker.setProgram(result, lustreProgram);
    linker.setComponent(result, compImpl);
    linker.setContract(result, getContract(compImpl));
    linker.setLayout(result, layout);
    // linker.setReferenceMap(result, renaming.getRefMap());
    linker.setLog(result, AgreeLogger.getLog());
    linker.setRenaming(result, renaming);
    // System.out.println(program);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) TcgRenaming(com.rockwellcollins.atc.tcg.obligations.ufc.TcgRenaming) JKindResult(jkind.api.results.JKindResult)

Example 3 with AgreeLayout

use of com.rockwellcollins.atc.agree.analysis.AgreeLayout in project AMASE by loonwerks.

the class SafetyLinkerFactory method createVerification.

protected AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram) {
    // Renaming: organizes things between jkind and agree results?
    AgreeRenaming agreeRenaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    RenamingVisitor.addRenamings(lustreProgram, agreeRenaming, compInst, layout);
    SafetyRenaming renaming = new SafetyRenaming(agreeRenaming, agreeRenaming.getRefMap());
    Node mainNode = lustreProgram.getMainNode();
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    JKindResult result;
    result = new JKindResult(resultName, properties, renaming);
    queue.add(result);
    // Set the program, component, contract, layout, log, and renaming
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setAgreeProgram(result, agreeProgram);
    linker.setProgram(result, lustreProgram);
    linker.setComponent(result, compImpl);
    linker.setContract(result, getContract(compImpl));
    linker.setLayout(result, layout);
    linker.setReferenceMap(result, renaming.getRefMap());
    linker.setLog(result, AgreeLogger.getLog());
    linker.setRenaming(result, renaming);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) JKindResult(jkind.api.results.JKindResult)

Example 4 with AgreeLayout

use of com.rockwellcollins.atc.agree.analysis.AgreeLayout in project AMASE by loonwerks.

the class FaultsVerifyAllHandler method createVerification.

private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
    List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
    AgreeRenaming renaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    Node mainNode = null;
    for (Node node : lustreProgram.nodes) {
        if (node.id.equals(lustreProgram.main)) {
            mainNode = node;
            break;
        }
    }
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    RenamingVisitor.addRenamings(lustreProgram, renaming, compInst, layout);
    addProperties(renaming, properties, mainNode, agreeProgram);
    for (AgreeAutomater aa : automaters) {
        renaming = aa.rename(renaming);
        layout = aa.transformLayout(layout);
    }
    JKindResult result;
    switch(analysisType) {
        case Consistency:
            result = new ConsistencyResult(resultName, mainNode.properties, Collections.singletonList(true), renaming);
            break;
        case Realizability:
            result = new JRealizabilityResult(resultName, renaming);
            break;
        case AssumeGuarantee:
            result = new SafetyJKindResult(resultName, properties, renaming);
            break;
        default:
            throw new AgreeException("Unhandled Analysis Type");
    }
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setProgram(result, lustreProgram);
    linker.setComponent(result, compImpl);
    linker.setContract(result, getContract(compImpl));
    linker.setLayout(result, layout);
    linker.setReferenceMap(result, renaming.getRefMap());
    linker.setLog(result, AgreeLogger.getLog());
    linker.setRenaming(result, renaming);
    // System.out.println(program);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) SafetyJKindResult(edu.umn.cs.crisys.safety.analysis.results.SafetyJKindResult) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Example 5 with AgreeLayout

use of com.rockwellcollins.atc.agree.analysis.AgreeLayout in project AMASE by loonwerks.

the class GenMCSHandler method createVerification.

/**
 * Copied from AGREE VerifyHandler - allows for min cut set Analysis Type in
 * param analysisType
 *
 * @param resultName
 * @param compInst
 * @param lustreProgram
 * @param agreeProgram
 * @param analysisType
 * @return
 */
private AnalysisResult createVerification(String resultName, ComponentInstance compInst, Program lustreProgram, AgreeProgram agreeProgram, AnalysisType analysisType) {
    AgreeAutomaterRegistry aAReg = (AgreeAutomaterRegistry) ExtensionRegistry.getRegistry(ExtensionRegistry.AGREE_AUTOMATER_EXT_ID);
    List<AgreeAutomater> automaters = aAReg.getAgreeAutomaters();
    AgreeRenaming renaming = new AgreeRenaming();
    AgreeLayout layout = new AgreeLayout();
    Node mainNode = null;
    for (Node node : lustreProgram.nodes) {
        if (node.id.equals(lustreProgram.main)) {
            mainNode = node;
            break;
        }
    }
    if (mainNode == null) {
        throw new AgreeException("Could not find main lustre node after translation");
    }
    List<String> properties = new ArrayList<>();
    RenamingVisitor.addRenamings(lustreProgram, renaming, compInst, layout);
    addProperties(renaming, properties, mainNode, agreeProgram);
    for (AgreeAutomater aa : automaters) {
        renaming = aa.rename(renaming);
        layout = aa.transformLayout(layout);
    }
    JKindResult result;
    switch(analysisType) {
        case Consistency:
            result = new ConsistencyResult(resultName, mainNode.properties, Collections.singletonList(true), renaming);
            break;
        case Realizability:
            result = new JRealizabilityResult(resultName, renaming);
            break;
        case AssumeGuarantee:
            result = new JKindResult(resultName, properties, renaming);
            break;
        default:
            throw new AgreeException("Unhandled Analysis Type");
    }
    queue.add(result);
    ComponentImplementation compImpl = AgreeUtils.getInstanceImplementation(compInst);
    linker.setProgram(result, lustreProgram);
    linker.setComponent(result, compImpl);
    linker.setContract(result, getContract(compImpl));
    linker.setLayout(result, layout);
    linker.setReferenceMap(result, renaming.getRefMap());
    linker.setLog(result, AgreeLogger.getLog());
    linker.setRenaming(result, renaming);
    return result;
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) JRealizabilityResult(jkind.api.results.JRealizabilityResult) AgreeRenaming(com.rockwellcollins.atc.agree.analysis.AgreeRenaming) Node(jkind.lustre.Node) ArrayList(java.util.ArrayList) JKindResult(jkind.api.results.JKindResult) AgreeAutomaterRegistry(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry) AgreeLayout(com.rockwellcollins.atc.agree.analysis.AgreeLayout) ConsistencyResult(com.rockwellcollins.atc.agree.analysis.ConsistencyResult) AgreeAutomater(com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException)

Aggregations

AgreeLayout (com.rockwellcollins.atc.agree.analysis.AgreeLayout)6 AgreeRenaming (com.rockwellcollins.atc.agree.analysis.AgreeRenaming)6 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)5 ArrayList (java.util.ArrayList)5 JKindResult (jkind.api.results.JKindResult)5 Node (jkind.lustre.Node)5 ComponentImplementation (org.osate.aadl2.ComponentImplementation)5 ConsistencyResult (com.rockwellcollins.atc.agree.analysis.ConsistencyResult)3 AgreeAutomater (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomater)3 AgreeAutomaterRegistry (com.rockwellcollins.atc.agree.analysis.extentions.AgreeAutomaterRegistry)3 JRealizabilityResult (jkind.api.results.JRealizabilityResult)3 AgreeProgram (com.rockwellcollins.atc.agree.analysis.ast.AgreeProgram)2 AgreeContractSubclause (com.rockwellcollins.atc.agree.agree.AgreeContractSubclause)1 AgreePackage (com.rockwellcollins.atc.agree.agree.AgreePackage)1 AgreeSubclause (com.rockwellcollins.atc.agree.agree.AgreeSubclause)1 Activator (com.rockwellcollins.atc.agree.analysis.Activator)1 AgreeLogger (com.rockwellcollins.atc.agree.analysis.AgreeLogger)1 AgreeUtils (com.rockwellcollins.atc.agree.analysis.AgreeUtils)1 EphemeralImplementationUtil (com.rockwellcollins.atc.agree.analysis.EphemeralImplementationUtil)1 AgreeASTBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeASTBuilder)1