Search in sources :

Example 21 with AgreeVar

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

the class AgreePatternTranslator method getTimeFall.

private AgreeVar getTimeFall(String varName, AgreeNodeBuilder builder, EObject reference) {
    Map<String, AgreeVar> timeFallMap = builder.build().timeFallMap;
    if (timeFallMap.containsKey(varName)) {
        return timeFallMap.get(varName);
    }
    AgreeVar timeFall = new AgreeVar(varName + FALL_SUFFIX, NamedType.REAL, reference);
    builder.addOutput(timeFall);
    Expr Fall = new NodeCallExpr(AgreeRealtimeCalendarBuilder.FALL_NODE_NAME, new IdExpr(varName));
    Expr timeVarExpr = expr("timeFall = (if Fall then time else (-1.0 -> pre timeFall))", to("timeFall", timeFall), to("Fall", Fall), to("time", timeExpr));
    builder.addAssertion(new AgreeStatement(null, timeVarExpr, reference));
    Expr lemmaExpr = expr("timeFall <= time and timeFall >= -1.0", to("timeFall", timeFall), to("time", timeExpr));
    // add this assertion to help with proofs (it should always be true)
    builder.addAssertion(new AgreeStatement("", lemmaExpr, reference));
    builder.addTimeFall(varName, timeFall);
    return timeFall;
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 22 with AgreeVar

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

the class AgreePatternTranslator method translatePatternProperty.

private Expr translatePatternProperty(AgreeSporadicPattern pattern, AgreeNodeBuilder builder, EObject varReference) {
    if (!((RealExpr) pattern.jitter).value.equals(BigDecimal.ZERO)) {
        throw new AgreeException("We currently do not handle non-zero jitter values correctly for sporadic patterns");
    }
    AgreeVar timeofEvent = getTimeOf(pattern.event.id, builder, null);
    Expr propExpr = expr("(true -> (not ((pre laste) = -1.0) => event => time - (pre laste) >= period))", to("laste", timeofEvent), to("event", pattern.event), to("time", timeExpr), to("period", pattern.period));
    return propExpr;
}
Also used : BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) AgreeException(com.rockwellcollins.atc.agree.analysis.AgreeException) RealExpr(jkind.lustre.RealExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 23 with AgreeVar

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

the class AgreePatternTranslator method translatePatternConstraint.

private Expr translatePatternConstraint(AgreeSporadicPattern pattern, AgreeNodeBuilder builder, EObject varReference) {
    AgreeVar jitterVar = new AgreeVar(JITTER_PREFIX + patternIndex, NamedType.REAL, varReference);
    AgreeVar periodVar = new AgreeVar(PERIOD_PREFIX + patternIndex, NamedType.REAL, varReference);
    AgreeVar timeoutVar = new AgreeVar(TIMEOUT_PREFIX + patternIndex, NamedType.REAL, varReference);
    builder.addOutput(jitterVar);
    builder.addOutput(periodVar);
    builder.addOutput(timeoutVar);
    IdExpr jitterId = new IdExpr(jitterVar.id);
    IdExpr periodId = new IdExpr(periodVar.id);
    IdExpr timeoutId = new IdExpr(timeoutVar.id);
    builder.addEventTime(timeoutVar);
    // -j <= jitter <= j
    Expr jitterLow = new BinaryExpr(new UnaryExpr(UnaryOp.NEGATIVE, pattern.jitter), BinaryOp.LESSEQUAL, jitterId);
    Expr jitterHigh = new BinaryExpr(jitterId, BinaryOp.LESSEQUAL, pattern.jitter);
    builder.addAssertion(new AgreeStatement(null, new BinaryExpr(jitterLow, BinaryOp.AND, jitterHigh), pattern.reference));
    // pnext >= 0 -> if pre ((pnext + jitter) = t) then pnext >= p +
    // pre(pnext) else pre(pnext)
    Expr prePNext = new UnaryExpr(UnaryOp.PRE, periodId);
    Expr pNextInit = new BinaryExpr(periodId, BinaryOp.GREATEREQUAL, new RealExpr(BigDecimal.ZERO));
    Expr pNextCond = new BinaryExpr(periodId, BinaryOp.PLUS, jitterId);
    pNextCond = new BinaryExpr(pNextCond, BinaryOp.EQUAL, timeExpr);
    pNextCond = new UnaryExpr(UnaryOp.PRE, pNextCond);
    Expr pNextThen = new BinaryExpr(pattern.period, BinaryOp.PLUS, prePNext);
    pNextThen = new BinaryExpr(periodId, BinaryOp.GREATEREQUAL, pNextThen);
    Expr pNextHold = new BinaryExpr(periodId, BinaryOp.EQUAL, prePNext);
    Expr pNextIf = new IfThenElseExpr(pNextCond, pNextThen, pNextHold);
    Expr pNext = new BinaryExpr(pNextInit, BinaryOp.ARROW, pNextIf);
    builder.addAssertion(new AgreeStatement(null, pNext, pattern.reference));
    // timeout = pnext + jitter
    Expr timeoutExpr = new BinaryExpr(periodId, BinaryOp.PLUS, jitterId);
    timeoutExpr = new BinaryExpr(timeoutId, BinaryOp.EQUAL, timeoutExpr);
    builder.addAssertion(new AgreeStatement(null, timeoutExpr, pattern.reference));
    // event = (t = timeout)
    Expr eventExpr = new BinaryExpr(timeExpr, BinaryOp.EQUAL, timeoutId);
    eventExpr = new BinaryExpr(pattern.event, BinaryOp.EQUAL, eventExpr);
    return eventExpr;
}
Also used : AgreeStatement(com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement) IdExpr(jkind.lustre.IdExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) UnaryExpr(jkind.lustre.UnaryExpr) Expr(jkind.lustre.Expr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) BinaryExpr(jkind.lustre.BinaryExpr) UnaryExpr(jkind.lustre.UnaryExpr) RealExpr(jkind.lustre.RealExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar) IfThenElseExpr(jkind.lustre.IfThenElseExpr)

Example 24 with AgreeVar

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

the class AgreeRealtimeCalendarBuilder method getTimeConstraint.

public static Expr getTimeConstraint(Set<AgreeVar> events) {
    IdExpr timeId = AgreePatternTranslator.timeExpr;
    Expr preTime = new UnaryExpr(UnaryOp.PRE, timeId);
    Expr nodeCall = new BinaryExpr(timeId, BinaryOp.MINUS, preTime);
    for (AgreeVar eventVar : events) {
        Expr event = new IdExpr(eventVar.id);
        BinaryExpr timeChange = new BinaryExpr(event, BinaryOp.MINUS, timeId);
        Expr preTimeChange = new UnaryExpr(UnaryOp.PRE, timeChange);
        nodeCall = new NodeCallExpr(MIN_POS_NODE_NAME, preTimeChange, nodeCall);
    }
    nodeCall = new BinaryExpr(preTime, BinaryOp.PLUS, nodeCall);
    Expr timeExpr = new BinaryExpr(timeId, BinaryOp.EQUAL, nodeCall);
    timeExpr = new BinaryExpr(new BoolExpr(true), BinaryOp.ARROW, timeExpr);
    Expr timeGrtPreTime = new BinaryExpr(timeId, BinaryOp.GREATER, preTime);
    Expr timeInitZero = new BinaryExpr(timeId, BinaryOp.EQUAL, new RealExpr(BigDecimal.ZERO));
    timeInitZero = new BinaryExpr(timeInitZero, BinaryOp.ARROW, timeGrtPreTime);
    return new BinaryExpr(timeInitZero, BinaryOp.AND, timeExpr);
}
Also used : BoolExpr(jkind.lustre.BoolExpr) IdExpr(jkind.lustre.IdExpr) BoolExpr(jkind.lustre.BoolExpr) BinaryExpr(jkind.lustre.BinaryExpr) RealExpr(jkind.lustre.RealExpr) UnaryExpr(jkind.lustre.UnaryExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) Expr(jkind.lustre.Expr) IfThenElseExpr(jkind.lustre.IfThenElseExpr) IdExpr(jkind.lustre.IdExpr) NodeCallExpr(jkind.lustre.NodeCallExpr) BinaryExpr(jkind.lustre.BinaryExpr) UnaryExpr(jkind.lustre.UnaryExpr) RealExpr(jkind.lustre.RealExpr) AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Example 25 with AgreeVar

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

the class LustreCondactNodeVisitor method addTickedEq.

private static void addTickedEq(NodeBuilder builder) {
    builder.addLocal(new AgreeVar(tickedVarName, NamedType.BOOL, null));
    builder.addEquation(equation("ticked = clk -> clk or pre(ticked);", to("ticked", tickedVarName), to("clk", clockVarName)));
}
Also used : AgreeVar(com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)

Aggregations

AgreeVar (com.rockwellcollins.atc.agree.analysis.ast.AgreeVar)69 IdExpr (jkind.lustre.IdExpr)49 Expr (jkind.lustre.Expr)45 NodeCallExpr (jkind.lustre.NodeCallExpr)42 BinaryExpr (jkind.lustre.BinaryExpr)41 AgreeStatement (com.rockwellcollins.atc.agree.analysis.ast.AgreeStatement)39 BoolExpr (jkind.lustre.BoolExpr)38 UnaryExpr (jkind.lustre.UnaryExpr)37 ArrayList (java.util.ArrayList)28 IfThenElseExpr (jkind.lustre.IfThenElseExpr)25 VarDecl (jkind.lustre.VarDecl)19 Equation (jkind.lustre.Equation)15 RealExpr (jkind.lustre.RealExpr)15 AgreeEquation (com.rockwellcollins.atc.agree.analysis.ast.AgreeEquation)14 AgreeNode (com.rockwellcollins.atc.agree.analysis.ast.AgreeNode)13 IntExpr (jkind.lustre.IntExpr)13 AgreeException (com.rockwellcollins.atc.agree.analysis.AgreeException)12 AgreeNodeBuilder (com.rockwellcollins.atc.agree.analysis.ast.AgreeNodeBuilder)12 NodeBuilder (jkind.lustre.builders.NodeBuilder)11 SafetyException (edu.umn.cs.crisys.safety.analysis.SafetyException)9