Documentation

Strata.Languages.Core.Verifier

def Strata.SMT.Encoder.encodeCore (ctx : Core.SMT.Context) (prelude : SolverM Unit) (assumptionTerms : List Term) (obligationTerm : Term) (md : Imperative.MetaData Core.Expression) (satisfiabilityCheck validityCheck : Bool) :

Encode a verification condition into SMT-LIB format.

This function encodes the path conditions (P) and obligation (Q) into SMT, then emits check-sat commands to determine satisfiability and/or validity.

When both checks are requested, uses check-sat-assuming for efficiency:

  • Satisfiability: (check-sat-assuming (Q)) tests if P ∧ Q is satisfiable
  • Validity: (check-sat-assuming ((not Q))) tests if P ∧ ¬Q is satisfiable

When only one check is requested, uses assert + check-sat:

  • For satisfiability: (assert Q) (check-sat) tests P ∧ Q
  • For validity: (assert (not Q)) (check-sat) tests P ∧ ¬Q

Note: The obligation term Q is encoded without negation. Negation is applied when needed for the validity check (line 64 for check-sat-assuming, line 77 for assert).

Equations
  • One or more equations did not get rendered due to their size.
Instances For
    @[reducible, inline]
    Equations
    Instances For
      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def Core.SMT.dischargeObligation (options : VerifyOptions) (vars : List Expression.TypedIdent) (md : Imperative.MetaData Expression) (filename : String) (assumptionTerms : List Strata.SMT.Term) (obligationTerm : Strata.SMT.Term) (ctx : Context) (satisfiabilityCheck validityCheck : Bool) :
        Equations
        • One or more equations did not get rendered due to their size.
        Instances For
          structure Core.VCOutcome :

          Analysis outcome of a verification condition based on two SMT queries:

          • satisfiabilityProperty: result of checking P ∧ Q (is the property satisfiable given the path condition?)
          • validityProperty: result of checking P ∧ ¬Q (can the property be false given the path condition?)

          The 9 possible outcomes and their interpretations. For cover statements, any outcome where P ∧ Q is sat displays as ✅ (cover satisfied). Unreachable covers display as ❌ (error) instead of ⛔ (warning).

          Emoji Label P ∧ Q P ∧ ¬Q Reachable Deductive BugFinding BugFinding+Complete Meaning


          ✅ always true and is reachable sat unsat yes pass pass pass Property always true, reachable from declaration entry ❌ always false and is reachable unsat sat yes error error error Property always false, reachable from declaration entry 🔶 can be both true and false and is reachable sat sat yes error note error Reachable, solver found models for both the property and its negation ⛔ unreachable unsat unsat no warning warning warning Dead code, path unreachable ➕ can be true and is reachable sat unknown yes error note note Property can be true and is reachable, unknown if always true ✖️ always false if reached unsat unknown unknown error error error Property always false if reached, unknown if reachable ➖ can be false and is reachable unknown sat yes error note error Property can be false and is reachable, unknown if always false ✔️ always true if reached unknown unsat unknown pass pass pass Property always true if reached, unknown if reachable ❓ unknown unknown unknown unknown error note note Both checks inconclusive

          Instances For
            Equations
            • One or more equations did not get rendered due to their size.
            Instances For

              True when either SMT property is .err (solver returned an error on a specific check, as opposed to the outer VCResult.outcome being .error due to an encoding failure).

              Equations
              Instances For
                Equations
                Instances For
                  def Core.VCOutcome.label (o : VCOutcome) (property : Imperative.PropertyType) (checkLevel : CheckLevel) (checkMode : VerificationMode) :
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    def Core.VCOutcome.emoji (o : VCOutcome) (property : Imperative.PropertyType) (checkLevel : CheckLevel) (checkMode : VerificationMode) :
                    Equations
                    • One or more equations did not get rendered due to their size.
                    Instances For
                      @[reducible, inline]

                      A counterexample model with values lifted to LExpr for display purposes. This is used for formatting counterexamples in a human-readable way using Core's expression formatter and for future use as program metadata.

                      Equations
                      Instances For
                        Equations
                        Instances For
                          structure Core.VCResult :

                          A collection of all information relevant to a verification condition's analysis.

                          Instances For
                            def Core.maskOutcome (outcome : VCOutcome) (satisfiabilityCheck validityCheck : Bool) :

                            Mask outcome properties that were not requested. When PE (partial evaluation) resolves a check that wasn't requested by the check mode/level, we set it to .unknown so the label function displays the appropriate message for the checks that were actually requested. For example, in minimal deductive mode we only request validity, so if PE also determined satisfiability, we mask it to .unknown.

                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For
                              Equations
                              • One or more equations did not get rendered due to their size.

                              Compact single-line outcome string: emoji + label (e.g. "✅ pass", "❌ fail"). Uses the property, check level, and check mode stored in the result.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                Equations
                                Instances For
                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    Equations
                                    Instances For
                                      Equations
                                      Instances For
                                        Equations
                                        Instances For

                                          True when either SMT property inside a successful outcome is .err. Complements isImplementationError, which covers the outer .error case.

                                          Equations
                                          Instances For
                                            @[reducible, inline]
                                            Equations
                                            Instances For

                                              Preprocess a proof obligation using partial evaluation (PE). Returns PE-determined results for satisfiability and validity independently. Each result is some r if PE can determine it, none if the solver is needed.

                                              Equations
                                              • One or more equations did not get rendered due to their size.
                                              Instances For
                                                def Core.getObligationResult (assumptionTerms : List Strata.SMT.Term) (obligationTerm : Strata.SMT.Term) (ctx : SMT.Context) (obligation : Imperative.ProofObligation Expression) (p : Program) (options : VerifyOptions) (counter : IO.Ref Nat) (tempDir : System.FilePath) (satisfiabilityCheck validityCheck : Bool) :

                                                Invoke a backend engine and get the analysis result for a given proof obligation.

                                                Equations
                                                • One or more equations did not get rendered due to their size.
                                                Instances For
                                                  Equations
                                                  • One or more equations did not get rendered due to their size.
                                                  Instances For

                                                    Run the Strata Core verification pipeline on a program: transform, type-check, partially evaluate, and discharge proof obligations via SMT. All program-wide transformations that occur before any analyses (including type inference) should be placed here.

                                                    Equations
                                                    • One or more equations did not get rendered due to their size.
                                                    Instances For
                                                      Equations
                                                      • One or more equations did not get rendered due to their size.
                                                      Instances For
                                                        Equations
                                                        • One or more equations did not get rendered due to their size.
                                                        Instances For
                                                          Equations
                                                          • One or more equations did not get rendered due to their size.
                                                          Instances For
                                                            Instances For
                                                              Equations
                                                              • One or more equations did not get rendered due to their size.
                                                              Instances For
                                                                Equations
                                                                Instances For
                                                                  Equations
                                                                  • One or more equations did not get rendered due to their size.
                                                                  Instances For