コード例 #1
0
        public static void SetTypeEraserFactory(TypePremiseEraserFactory factory)
        {
            if (CommandLineOptions.Clo.GenerateIsaProgNoProofs)
            {
                return;
            }
            typePremiseEraserFactory = factory;
            var uniqueNamer = new IsaUniqueNamer();

            /* Hack: try to make sure unique namer uses names for Boogie functions and Boogie variables that are different
             * from the default name otherwise it clashes with the functions potentially fixed in the context of a locale
             */
            foreach (var fun in boogieGlobalData.Functions)
            {
                uniqueNamer.GetName(fun.Name, "o123_" + fun.Name);
            }

            foreach (var variable in finalProgData.AllVariables())
            {
                uniqueNamer.GetName(variable.Name, "o123_" + variable.Name);
            }

            //Hack: translate vc variable based on name, to ensure that applying erasure multiple times shares the same variables
            var translator = VCExprToIsaTranslator.CreateNameBasedTranslator(uniqueNamer);

            translator.SetFunctionNamer(uniqueNamer);
            translator.SetTryInstantiatingFunctions(true);
            vcHintManager = new VCHintManager(new VcRewriteLemmaGen(factory, translator));
        }
コード例 #2
0
 public ProgramVcProofData(
     IEnumerable <Function> vcFunctions,
     VcBoogieInfo vcBoogieInfo,
     VCHintManager vcHintManager,
     LocaleDecl vcLocale,
     IVCVarFunTranslator vcTranslator)
 {
     VcFunctions   = vcFunctions;
     VcBoogieInfo  = vcBoogieInfo;
     VcHintManager = vcHintManager;
     VcLocale      = vcLocale;
     VcTranslator  = vcTranslator;
 }
コード例 #3
0
        //assume that block identities in the two CFGs are the same (only edges may be different)
        private static IDictionary <Block, IList <OuterDecl> > GenerateVCLemmas(
            CFGRepr afterPassificationCfg,
            CFGRepr finalCfg,
            IDictionary <Block, Block> afterPassiveToFinalBlock,
            IDictionary <Block, Block> afterPassiveToOrigBlock,
            HashSet <Block> reachableBlocks,
            VcPhaseLemmaManager vcPhaseLemmaManager,
            VCHintManager vcHintManager,
            IsaUniqueNamer lemmaNamer)
        {
            var blockToLemmaDecls = new Dictionary <Block, IList <OuterDecl> >();

            foreach (var bAfterPassive in afterPassificationCfg.GetBlocksBackwards())
            {
                var result = new List <OuterDecl>();

                if (afterPassiveToFinalBlock.TryGetValue(bAfterPassive, out var bFinal))
                {
                    string vcHintsName = null;
                    if (vcHintManager.TryGetHints(afterPassiveToOrigBlock[bAfterPassive], out var hints,
                                                  out var requiredDecls))
                    {
                        //FIXME potential val name clash
                        vcHintsName = GetLemmaName(bAfterPassive, lemmaNamer) + "_hints";
                        var code = MLUtil.DefineVal(vcHintsName, MLUtil.MLList(hints));
                        //required declarations must be added first
                        result.AddRange(requiredDecls);
                        result.Add(new MLDecl(code));
                    }

                    result.Add(vcPhaseLemmaManager.GenerateBlockLemma(
                                   bAfterPassive, bFinal, finalCfg.GetSuccessorBlocks(bFinal), GetLemmaName(bFinal, lemmaNamer),
                                   vcHintsName));
                    //do not use identity of final CFG block to be consistent with other branches
                    blockToLemmaDecls.Add(bAfterPassive, result);
                }
                else if (reachableBlocks.Contains(bAfterPassive))
                {
                    //block was removed after peephole but is reachable before peephole
                    if (bAfterPassive.Cmds.Count == 0)
                    {
                        //find the successors of b in the final cfg (i.e., the first non-empty reachable blocks)
                        var nonEmptyReachableSuccessors =
                            GetNonEmptyReachableSuccessors(bAfterPassive, afterPassificationCfg, finalCfg,
                                                           afterPassiveToFinalBlock);
                        //add lemma
                        var decls = new List <OuterDecl>
                        {
                            vcPhaseLemmaManager.GenerateEmptyBlockLemma(
                                bAfterPassive,
                                nonEmptyReachableSuccessors.Select(b => afterPassiveToFinalBlock[b]),
                                GetLemmaName(bAfterPassive, lemmaNamer))
                        };
                        blockToLemmaDecls.Add(bAfterPassive, decls);
                    }
                    else
                    {
                        throw new ProofGenUnexpectedStateException(
                                  "Non-empty reachable block removed during peep-hole");
                    }
                }
            }

            return(blockToLemmaDecls);
        }