LCOV - code coverage report
Current view: top level - buildbot/coverage/build/src/smt - witness_form.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2026-07-06 10:35:16 Functions: 1 2 50.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /******************************************************************************
       2                 :            :  * This file is part of the cvc5 project.
       3                 :            :  *
       4                 :            :  * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS
       5                 :            :  * in the top-level source directory and their institutional affiliations.
       6                 :            :  * All rights reserved.  See the file COPYING in the top-level source
       7                 :            :  * directory for licensing information.
       8                 :            :  * ****************************************************************************
       9                 :            :  *
      10                 :            :  * The module for managing witness form conversion in proofs.
      11                 :            :  */
      12                 :            : 
      13                 :            : #include "cvc5_private.h"
      14                 :            : 
      15                 :            : #ifndef CVC5__SMT__WITNESS_FORM_H
      16                 :            : #define CVC5__SMT__WITNESS_FORM_H
      17                 :            : 
      18                 :            : #include <unordered_set>
      19                 :            : 
      20                 :            : #include "proof/conv_proof_generator.h"
      21                 :            : #include "proof/method_id.h"
      22                 :            : #include "proof/proof.h"
      23                 :            : #include "proof/proof_generator.h"
      24                 :            : #include "smt/env_obj.h"
      25                 :            : 
      26                 :            : namespace cvc5::internal {
      27                 :            : 
      28                 :            : namespace theory {
      29                 :            : class Rewriter;
      30                 :            : }
      31                 :            : 
      32                 :            : namespace smt {
      33                 :            : 
      34                 :            : /** A response to requiresWitnessFormTransform/requiresWitnessFormIntro */
      35                 :            : enum WitnessReq
      36                 :            : {
      37                 :            :   // we require converting to witness form and rewriting again
      38                 :            :   WITNESS_AND_REWRITE,
      39                 :            :   // we require converting to witness form
      40                 :            :   WITNESS,
      41                 :            :   // we require rewriting again
      42                 :            :   REWRITE,
      43                 :            :   // we don't require anything
      44                 :            :   NONE
      45                 :            : };
      46                 :            : /** Print method */
      47                 :            : std::ostream& operator<<(std::ostream& out, WitnessReq wr);
      48                 :            : 
      49                 :            : /**
      50                 :            :  * The witness form proof generator, which acts as a wrapper around a
      51                 :            :  * TConvProofGenerator for adding rewrite steps for witness introduction.
      52                 :            :  *
      53                 :            :  * The proof steps managed by this class are stored in a context-independent
      54                 :            :  * manager, which matches how witness forms are managed in SkolemManager.
      55                 :            :  */
      56                 :            : class WitnessFormGenerator : protected EnvObj, public ProofGenerator
      57                 :            : {
      58                 :            :  public:
      59                 :            :   WitnessFormGenerator(Env& env);
      60                 :      20016 :   ~WitnessFormGenerator() {}
      61                 :            :   /**
      62                 :            :    * Get proof for, which expects an equality of the form t = toWitness(t).
      63                 :            :    * This returns a proof based on the term conversion proof generator utility.
      64                 :            :    * This proof may contain open assumptions of the form:
      65                 :            :    *   k = toWitness(k)
      66                 :            :    * Each of these assumptions are included in the set getWitnessFormEqs()
      67                 :            :    * below after returning this call.
      68                 :            :    */
      69                 :            :   std::shared_ptr<ProofNode> getProofFor(Node eq) override;
      70                 :            :   /** Identify */
      71                 :            :   std::string identify() const override;
      72                 :            :   /**
      73                 :            :    * Does the rewrite require witness form conversion?
      74                 :            :    * When calling this method, it should be the case that:
      75                 :            :    *   Rewriter::rewrite(toWitness(t)) == Rewriter::rewrite(toWitness(s))
      76                 :            :    * The rule MACRO_SR_PRED_TRANSFORM concludes t == s if the above holds.
      77                 :            :    * This method returns false if:
      78                 :            :    *   rewriteViaMethod(t, idr) == rewriteViaMethod(s, idr)
      79                 :            :    * which means that the proof of the above fact does not need to do
      80                 :            :    * witness form conversion to prove conclusions of MACRO_SR_PRED_TRANSFORM.
      81                 :            :    */
      82                 :            :   WitnessReq requiresWitnessFormTransform(Node t, Node s, MethodId idr) const;
      83                 :            :   /**
      84                 :            :    * Same as above, with s = true. This is intended for use with
      85                 :            :    * MACRO_SR_PRED_INTRO.
      86                 :            :    */
      87                 :            :   WitnessReq requiresWitnessFormIntro(Node t, MethodId idr) const;
      88                 :            :   /**
      89                 :            :    * Get witness form equalities. This returns a set of equalities of the form:
      90                 :            :    *   k = toWitness(k)
      91                 :            :    * where k is a skolem, containing all rewrite steps used in calls to
      92                 :            :    * getProofFor during the entire lifetime of this generator.
      93                 :            :    */
      94                 :            :   const std::unordered_set<Node>& getWitnessFormEqs() const;
      95                 :            : 
      96                 :            :  private:
      97                 :            :   /**
      98                 :            :    * Convert to witness form. This internally constructs rewrite steps that
      99                 :            :    * suffice to show t = toWitness(t) using the term conversion proof generator
     100                 :            :    * of this class (d_tcpg).
     101                 :            :    */
     102                 :            :   Node convertToWitnessForm(Node t);
     103                 :            :   /** The true node */
     104                 :            :   Node d_true;
     105                 :            :   /** The rewriter we are using */
     106                 :            :   theory::Rewriter* d_rewriter;
     107                 :            :   /** The term conversion proof generator */
     108                 :            :   TConvProofGenerator d_tcpg;
     109                 :            :   /** The nodes we have already added rewrite steps for in d_tcpg */
     110                 :            :   std::unordered_set<Node> d_visited;
     111                 :            :   /** The set of equalities added as proof steps */
     112                 :            :   std::unordered_set<Node> d_eqs;
     113                 :            :   /** Lazy proof storing witness intro steps */
     114                 :            :   LazyCDProof d_wintroPf;
     115                 :            :   /** CDProof for justifying purification existentials */
     116                 :            :   CDProof d_pskPf;
     117                 :            : };
     118                 :            : 
     119                 :            : }  // namespace smt
     120                 :            : }  // namespace cvc5::internal
     121                 :            : 
     122                 :            : #endif

Generated by: LCOV version 1.14