Esempio n. 1
0
        public Tuple <string, IEnumerable <LemmaDecl> > GenerateTactic(Expr e)
        {
            var varCollector = new VariableCollector();

            varCollector.Visit(e);

            var lookupTyThms = new List <string>();
            var funMemThms   = new List <string>();

            foreach (var v in varCollector.usedVars)
            {
                try
                {
                    lookupTyThms.Add(programAccessor.LookupVarTyLemma(v));
                }
                catch
                {
                    //variable not found, possible if, for example, v is bound
                }
            }

            var usedFuncs = functionCollector.UsedFunctions(e);

            foreach (var f in usedFuncs)
            {
                funMemThms.Add(programAccessor.MembershipLemma(f));
            }

            var hintLemmas = equalityHintGenerator.GetHints(e);

            var hintsML    = MLUtil.IsaToMLThms(hintLemmas.Select(lemma => lemma.Name));
            var lookupTyML = MLUtil.IsaToMLThms(lookupTyThms);
            var funMemML   = MLUtil.IsaToMLThms(funMemThms);

            var args = new List <string>
            {
                MLUtil.ContextAntiquotation(),
                hintsML,
                lookupTyML,
                funMemML
            };

            var tactic = ProofUtil.Apply(ProofUtil.MLTactic("typing_tac " + string.Join(" ", args), 1));

            return(Tuple.Create(tactic, hintLemmas));
        }
        public LemmaDecl AxiomVcLemma(string lemmaName, Axiom axiom, VCExpr vcAxiom, out IList <OuterDecl> requiredDecls)
        {
            var vc        = vcAxiomInst.GetVCObjInstantiation(vcAxiom, declToVCMapping);
            var axiomTerm = basicCmdIsaVisitor.Translate(axiom.Expr);

            requiredDecls = new List <OuterDecl>();

            vcRewriteLemmaGen.RequiredVcRewrite(axiom.Expr, true, out var vcRewriteLemmas);

            VCExprHint exprHint;

            if (vcRewriteLemmas != null && vcRewriteLemmas.Any())
            {
                exprHint = new VCExprHint(vcRewriteLemmas);
                requiredDecls.AddRange(vcRewriteLemmas);
            }
            else
            {
                exprHint = VCExprHint.EmptyExprHint();
            }

            var assumption =
                IsaBoogieTerm.RedExpr(boogieContext, axiomTerm, normalInitState, IsaBoogieTerm.BoolVal(true));
            var statement = vc;

            return
                (new LemmaDecl(lemmaName,
                               ContextElem.CreateWithAssumptions(assumption),
                               statement,
                               new Proof(new List <string>
            {
                "unfolding " + vcAxiomInst.GetVCObjNameRef(vcAxiom) + "_def",
                ProofUtil.By(
                    ProofUtil.MLTactic(
                        "prove_axiom_vc_tac @{context} (" + exprHint.GetMLString() + ") " +
                        MLUtil.IsaToMLThm("assms(1)") + " " + MLUtil.IsaToMLThms(globalAssmsName) +
                        " (@{thm forall_poly_thm}, @{thm exists_poly_thm}) []", 1)
                    )
            })
                               ));
        }