Documentation

Cvc.Typed.Theory.Quant

Quantifiers, typed #

A quantified formula is a Term Bool whatever it binds, and so is its body. There are three spellings:

A quantifier binds at least one variable: neither spelling accepts none.

def Cvc.Typed.Term.mkForall [Ω] (bvs : BVars) (body : Term Bool) (_nonEmpty : bvs ≠ [] := by (try simp) <;> fail "failed to prove this quantifier binds at least one variable") :

Universal quantification of body over bvs.

Equations
Instances For
    def Cvc.Typed.Term.mkExists [Ω] (bvs : BVars) (body : Term Bool) (_nonEmpty : bvs ≠ [] := by (try simp) <;> fail "failed to prove this quantifier binds at least one variable") :

    Existential quantification of body over bvs.

    Equations
    Instances For

      Binding through Lean functions #

      Binder φ says that φ is the type of a quantifier's body written as a Lean function: one Term α argument per bound variable, ending in Env (Term Bool). The variable's sort is α's. There is no instance for a bare Env (Term Bool), so a body binding no variable does not typecheck.

      The arguments' types are what the sorts come from, so they must be known: write fun (x : Term Int) => … rather than fun x => … when nothing else in the body pins them down.

      φ is a quantifier body taking one Term α per bound variable.

      • bind : List String → Nat → φ → Env (Untyped.BVars × Term Bool)

        Creates one bound variable per argument of f and applies f to them.

        The i-th variable is named names[i], or x{i} when names has no such element.

      Instances
        @[reducible, inline]

        The name of the i-th bound variable: names[i], or x{i} when there is none.

        Equations
        Instances For
          @[instance_reducible]

          The binder for a body taking the last bound variable.

          Equations
          • One or more equations did not get rendered due to their size.
          @[instance_reducible]
          instance Cvc.Typed.Term.instBinderForallOfToTyp [Ω] {α ψ : Type} [ToTyp α] [Binder ψ] :
          Binder (Term α → ψ)

          The binder for a body taking a bound variable and more.

          Equations
          • One or more equations did not get rendered due to their size.
          def Cvc.Typed.Term.forallH [Ω] {φ : Type} [Binder φ] (body : φ) (names : List String := []) :

          Universal quantification of a body written as a Lean function of its variables.

          names names the variables in the order the function takes them; a variable without one is named x{i}, after its position.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For
            def Cvc.Typed.Term.existsH [Ω] {φ : Type} [Binder φ] (body : φ) (names : List String := []) :

            Existential quantification of a body written as a Lean function of its variables.

            names names the variables in the order the function takes them; a variable without one is named x{i}, after its position.

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

              Viewing a quantifier #

              The variables' sorts come as a list of Typs, as an application's arguments do, and the body mentions the variables: walking into it meets them as the aggregate's bvar leaf.

              A binder's variables, each a BVar σ.Denote at its sort σ, in order; never empty.

              Instances For
                def Cvc.Typed.View.Quant.Vars.toBVars [Ω] {doms : List Typ} (vars : Vars doms) :

                The same variables as a BVars list, so that a viewed binder can be rebuilt.

                Equations
                Instances For
                  theorem Cvc.Typed.View.Quant.Vars.toBVars_ne_nil [Ω] {doms : List Typ} (vars : Vars doms) :

                  A binder always has a variable, so its BVars are never empty: what mkForall asks for.

                  The variables as cvc5 prints them, x : Int.

                  Equations
                  Instances For
                    inductive Cvc.Typed.View.Quant [Ω] :
                    Typ → Type

                    A quantified formula taken apart one level; always of sort Bool.

                    forall and exists are Lean keywords, hence the primes. The instantiation patterns stay sort-erased, a pattern mixing sorts.

                    Instances For

                      Takes a quantified formula apart one level, none for any other term.

                      Also none when a variable's sort is one no Typ describes.

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

                        smt! #

                        A binder's type is the variable's index, so smt! ∀ (x : Int), x + 0 = x binds a Term Int.