Documentation

DescriptiveComplexity.Syntax

A surface syntax for first-order formulas #

Mathlib's FirstOrder.Language.BoundedFormula is locally nameless: a variable bound by the k-th enclosing block is written Sum.inr i under k - 1 applications of Sum.inl. Writing a clause by hand therefore means counting blocks, and reading one means counting them back.

fo% removes the counting. It is a macro: it elaborates to exactly the DescriptiveComplexity.Formula.iAlls / Term.var (Sum.inr _) term one would have written, so a definition converted to it is unchanged, its equation lemma is unchanged, and every proof about it – simp only [myClause, Formula.realize_iAlls, …] – keeps working verbatim.

fo% ∀ x₀ x₁ x₂ x₃,
  (((patV(x₀) ∧ patV(x₁)) ∧ patE(x₀, x₁)) ∧ map(x₀, x₂)) ∧ map(x₁, x₃) →
    hostE(x₂, x₃)

The syntax #

Connectives are ∧ ∨ ¬ → ↔ (for ⊓ ⊔ ∼ .imp .iff), with ⊤ᶠ and ⊥ᶠ for the constants; and associate to the right, so a left-nested conjunction needs its parentheses. ∀ x y z, φ and ∃ x y z, φ each bind one block, so they produce a single iAlls (Fin 3) and Formula.realize_iAlls fires once, as it does today. ⋀ i : T, φ and ⋁ i : T, φ are the finite Formula.iInf and Formula.iSup over a Lean type; their binder is a Lean variable, not an object variable.

Atoms come in two forms, matching the two conventions of the library:

In both forms the symbol may be an applied term rather than a bare name, written in parentheses: (kcColorSym i)(x) for the i-th of a family of relation variables, (conflict positive)⟨x, y⟩ for a builder taking a parameter.

x ≐ y is Term.equal, and !e escapes to an arbitrary Lean term – as a whole formula, or (inside an atom's argument list) as a variable that the macro should pass through untouched. if c then φ else ψ chooses between two formulas by a Lean proposition, as the defining formula of an interpretation does by its tags.

Free variables #

The variables a formula does not bind have to be declared, since the macro must lift them under every block:

Both clauses may appear, the arguments first. An identifier that is neither bound nor declared is an error rather than a silently captured Lean constant.

What it does not do #

The macro is source-level only: goals, #print and the documentation still show the underlying iAlls term. Terms are out of scope, the library being relational throughout.

An object variable: a name bound by fo%, a coordinate of a declared interpretation argument, or !e for a verbatim Lean term.

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

        A first-order formula in surface syntax; see the module docstring.

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

                                              fo%⟨u, v⟩[t, t'] φ is the formula φ, written with named variables: u and v name the arguments of an interpretation's defining formula, t and t' the free variables of the ambient formula. See the module docstring.

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