예제 #1
0
 public StackVarHidingProofGenerator(ProofGenerationParams i_pgp, StackVariableHidingStrategyDecl i_strategy)
     : base(i_pgp)
 {
     strategy = i_strategy;
     hiddenVariablesMethodName = strategy.MethodName;
     hiddenVariables           = new HashSet <string>(strategy.Variables);
     suppressedPCs             = new HashSet <ArmadaPC>();
 }
예제 #2
0
        public void GenerateProof()
        {
            if (!GetLevelsAndStrategy())
            {
                return;
            }

            ProofGenerationParams  pgp = new ProofGenerationParams(prog, mProof, mLow, mHigh);
            AbstractProofGenerator pg  = null;

            if (strategy is StackVariableHidingStrategyDecl)
            {
                pg = new StackVarHidingProofGenerator(pgp, (StackVariableHidingStrategyDecl)strategy);
            }
            else if (strategy is VariableHidingStrategyDecl)
            {
                pg = new VarHidingProofGenerator(pgp, (VariableHidingStrategyDecl)strategy);
            }
            else if (strategy is StackVariableIntroStrategyDecl)
            {
                pg = new StackVarIntroProofGenerator(pgp, (StackVariableIntroStrategyDecl)strategy);
            }
            else if (strategy is VariableIntroStrategyDecl)
            {
                pg = new VarIntroProofGenerator(pgp, (VariableIntroStrategyDecl)strategy);
            }
            else if (strategy is AssumeIntroStrategyDecl)
            {
                pg = new AssumeIntroProofGenerator(pgp, (AssumeIntroStrategyDecl)strategy);
            }
            else if (strategy is TSOEliminationStrategyDecl)
            {
                pg = new TSOEliminationProofGenerator(pgp, (TSOEliminationStrategyDecl)strategy);
            }
            else if (strategy is ReductionStrategyDecl)
            {
                pg = new ReductionProofGenerator(pgp, (ReductionStrategyDecl)strategy);
            }
            else if (strategy is WeakeningStrategyDecl)
            {
                pg = new WeakeningProofGenerator(pgp, (WeakeningStrategyDecl)strategy);
            }
            else if (strategy is StarWeakeningStrategyDecl)
            {
                pg = new StarWeakeningProofGenerator(pgp, (StarWeakeningStrategyDecl)strategy);
            }
            else if (strategy is CombiningStrategyDecl)
            {
                pg = new CombiningProofGenerator(pgp, (CombiningStrategyDecl)strategy);
            }

            if (pg != null)
            {
                pg.GenerateProof();
                pgp.proofFiles.Print();
            }
        }
예제 #3
0
 public GlobalVarHidingProofGenerator(ProofGenerationParams i_pgp, GlobalVariableHidingStrategyDecl i_strategy) : base(i_pgp, true)
 {
     strategy        = i_strategy;
     hiddenVariables = new HashSet <string>(strategy.Variables);
     if (hiddenVariables.All(varName => pgp.symbolsLow.Globals.Lookup(varName).varType == ArmadaVarType.Ghost))
     {
         canHideTau = false;
     }
 }
예제 #4
0
        public void GenerateProof()
        {
            if (!GetLevelsAndStrategy())
            {
                return;
            }

            ProofGenerationParams  pgp = new ProofGenerationParams(prog, mProof, mLow, mHigh);
            AbstractProofGenerator pg  = null;

            if (strategy is GlobalVariableHidingStrategyDecl gvhsd)
            {
                pg = new GlobalVarHidingProofGenerator(pgp, gvhsd);
            }
            else if (strategy is StackVariableHidingStrategyDecl svhsd)
            {
                pg = new StackVarHidingProofGenerator(pgp, svhsd);
            }
            else if (strategy is GlobalVariableIntroStrategyDecl gvisd)
            {
                pg = new GlobalVarIntroProofGenerator(pgp, gvisd);
            }
            else if (strategy is StackVariableIntroStrategyDecl svisd)
            {
                pg = new StackVarIntroProofGenerator(pgp, svisd);
            }
            else if (strategy is AssumeIntroStrategyDecl aisd)
            {
                pg = new AssumeIntroProofGenerator(pgp, aisd);
            }
            else if (strategy is TSOEliminationStrategyDecl tesd)
            {
                pg = new TSOEliminationProofGenerator(pgp, tesd);
            }
            else if (strategy is ReductionStrategyDecl rsd)
            {
                pg = new ReductionProofGenerator(pgp, rsd);
            }
            else if (strategy is WeakeningStrategyDecl wsd)
            {
                pg = new WeakeningProofGenerator(pgp, wsd);
            }
            else if (strategy is StarWeakeningStrategyDecl swsd)
            {
                pg = new StarWeakeningProofGenerator(pgp, swsd);
            }
            else if (strategy is CombiningStrategyDecl csd)
            {
                pg = new CombiningProofGenerator(pgp, csd);
            }

            if (pg != null)
            {
                pg.GenerateProof();
                pgp.proofFiles.Print();
            }
        }
예제 #5
0
        public StackVarIntroProofGenerator(ProofGenerationParams i_pgp, StackVariableIntroStrategyDecl i_strategy)
            : base(i_pgp, false)
        {
            strategy = i_strategy;
            var v = pgp.symbolsHigh.Lookup(strategy.MethodName, strategy.VariableName);

            if (!(v is MethodStackFrameUnaddressableLocalArmadaVariable))
            {
                AH.PrintError(pgp.prog, $"Variable {strategy.MethodName}.{strategy.VariableName} isn't a noaddr stack variable, but stack_var_intro can only introduce noaddr stack variables");
            }
        }
예제 #6
0
 public GlobalVarIntroProofGenerator(ProofGenerationParams i_pgp, GlobalVariableIntroStrategyDecl i_strategy)
     : base(i_pgp, true /* can introduce tau */)
 {
     strategy            = i_strategy;
     introducedVariables = new HashSet <string>();
     foreach (var tok in strategy.Variables)
     {
         introducedVariables.Add(tok.val);
     }
     if (introducedVariables.All(varName => pgp.symbolsHigh.Globals.Lookup(varName).varType == ArmadaVarType.Ghost))
     {
         canIntroduceTau = false;
     }
 }
예제 #7
0
 public AtomicSpec(ProofGenerationParams i_pgp, ArmadaSymbolTable i_symbols, string i_auxName, string i_prefix, bool i_low,
                   string i_moduleName, string i_typeState, string i_specFunctions, string i_spec,
                   string i_validStep, string i_getNextState)
 {
     pgp           = i_pgp;
     symbols       = i_symbols;
     auxName       = i_auxName;
     prefix        = i_prefix;
     low           = i_low;
     moduleName    = i_moduleName;
     typeState     = i_typeState;
     specFunctions = i_specFunctions;
     spec          = i_spec;
     validStep     = i_validStep;
     getNextState  = i_getNextState;
 }
예제 #8
0
        public StackVarHidingProofGenerator(ProofGenerationParams i_pgp, StackVariableHidingStrategyDecl i_strategy)
            : base(i_pgp, false)
        {
            strategy = i_strategy;
            hiddenVariablesMethodName = strategy.MethodName;
            hiddenVariables           = new HashSet <string>(strategy.Variables);

            foreach (var varName in strategy.Variables)
            {
                var v = pgp.symbolsLow.Lookup(hiddenVariablesMethodName, varName);
                if (!(v is MethodStackFrameUnaddressableLocalArmadaVariable))
                {
                    AH.PrintError(pgp.prog, $"Variable {hiddenVariablesMethodName}.{varName} isn't a noaddr stack variable, but stack_var_hiding can only hide noaddr stack variables");
                }
            }
        }
예제 #9
0
 public WeakeningProofGenerator(ProofGenerationParams i_pgp, WeakeningStrategyDecl i_strategy)
     : base(i_pgp)
 {
     strategy = i_strategy;
 }
예제 #10
0
 public StarWeakeningProofGenerator(ProofGenerationParams i_pgp, StarWeakeningStrategyDecl i_strategy)
     : base(i_pgp)
 {
     strategy    = i_strategy;
     weakenedPCs = new HashSet <ArmadaPC>();
 }
예제 #11
0
 public StackVarIntroProofGenerator(ProofGenerationParams i_pgp, StackVariableIntroStrategyDecl i_strategy)
     : base(i_pgp, i_strategy)
 {
     strategy = i_strategy;
 }
예제 #12
0
 public VarHidingProofGenerator(ProofGenerationParams i_pgp, bool i_canHideTau)
     : base(i_pgp, true)
 {
     canHideTau = i_canHideTau;
 }