While this submission is a draft, it cannot be used by other submissions.

The class FP, by quantitative first-order logic with least fixed points

Lax366625.QuantitativeLogic · concepts/Lax366625/QuantitativeLogic.lean · lax-366625

definition

Loading review…

Sign in with ORCID

Community review

Flags

Each flag is tied to a public ORCID identity and explains why this concept may be incorrect.

No flags have been submitted.

    Community review

    Flag this concept

    State precisely what appears incorrect. This explanation will be public under your ORCID name.

    No source line selected.

    Natural Language Statement

    Definition

    The terms of quantitative first-order logic QFO are built from first-order formulas, read as 11 or 00, and constants, by addition, multiplication, and sums and products over tuples of elements. A definition in QFO(LFP) over LL is a rule system defining a least fixed point, as in FO(LFP), and a closed QFO term over L∪{≤}L \cup \{\le\} expanded by the relation variables, read at the fixed point. A counting problem is in FP when some definition takes the value C(A)C(A) on every nonempty finite LL-structure AA, for every linear order on AA; this is the logic of polynomial-time computable functions of Arenas, Muñoz, and Riveros. FP is the counting class of these problems.

    A digit definition is a least fixed point together with relation variables of a common arity holding the binary digits of a number: the digit of weight 2r2^r is 11 when the tuple of rank rr in the lexicographic order is in its relation. A counting problem is digit-definable when its value is given by such a definition.

    Concept map
    11 concepts; 12 descendants hidden
    100%
    Proven claimDefinitionThis conceptRelated conceptA → B: B builds on A

    Lean source view on GitHub

    1import Mathlib.Algebra.BigOperators.Finprod
    2import Mathlib.Order.PiLex
    3import Mathlib.Data.Prod.Lex
    4import Mathlib.Data.Set.Card
    5import Mathlib.ModelTheory.Order
    6import Mathlib.ModelTheory.Semantics
    7import Mathlib.ModelTheory.Complexity
    8import Mathlib.Tactic.FinCases
    9import Mathlib.Order.Lattice.Nat
    10import Mathlib.Data.Fintype.EquivFin
    11import Mathlib.Logic.Equiv.Fin.Basic
    12import Mathlib.Data.Finite.Sigma
    13import Mathlib.Data.Fintype.Lattice
    14import Mathlib.Data.Fintype.Pigeonhole
    15import Mathlib.Dynamics.FixedPoints.Basic
    16import Mathlib.Algebra.Order.BigOperators.Group.Finset
    17import Mathlib.ModelTheory.Syntax
    18import Mathlib.Data.Fintype.Card
    19import Mathlib.SetTheory.Cardinal.Finite
    20import Lax366625.CountingProblems
    21import Lax535992.HornFragment
    22import Lax535992.LeastFixedPoint
    23import Lax895169.BitPredicate
    24import Lax904597.SecondOrder
    25import Lax366625.CountingClasses
    26
    27/-!
    28---
    29title: The class FP, by quantitative first-order logic with least fixed points
    30type: definition
    31---
    32The terms of quantitative first-order logic QFO are built from first-order
    33formulas, read as 11 or 00, and constants, by addition, multiplication,
    34and sums and products over tuples of elements. A definition in QFO(LFP)
    35over LL is a rule system defining a least fixed point, as in FO(LFP), and a
    36closed QFO term over L∪{≤}L \cup \{\le\} expanded by the relation variables,
    37read at the fixed point. A counting problem is in FP when some definition
    38takes the value C(A)C(A) on every nonempty finite LL-structure AA, for every
    39linear order on AA; this is the logic of polynomial-time computable
    40functions of Arenas, Muñoz, and Riveros. FP is the counting class of these
    41problems.
    42
    43A digit definition is a least fixed point together with relation variables
    44of a common arity holding the binary digits of a number: the digit of
    45weight 2r2^r is 11 when the tuple of rank rr in the lexicographic order is
    46in its relation. A counting problem is digit-definable when its value is
    47given by such a definition.
    48-/
    49
    50namespace Lax366625.QuantitativeLogic
    51
    52open Lax366625.CountingProblems Lax535992.HornFragment Lax535992.LeastFixedPoint
    53open Lax895169.BitPredicate Lax904597.SecondOrder
    54
    55open FirstOrder
    56
    57open Language Structure
    58
    59/-- A definition of a number by its binary digits: a least fixed point, as for
    60`LFPDef`, and the relation variables holding the
    61digits. -/
    62structure DigitLFPDef (L : Language.{0, 0}) : Type 1 where
    63 /-- The relation variables computed by the fixed point. -/
    64 B : SOBlock
    65 /-- The number of first-order variables shared by the rules. -/
    66 k : ℕ
    67 /-- The rules defining the variables. -/
    68 rules : List (HornClause (L.sum Language.order) B k)
    69 /-- The number of relation variables holding digits. -/
    70 c : ℕ
    71 /-- There is at least one. -/
    72 c_pos : 0 < c
    73 /-- Their common arity. -/
    74 ℓ : ℕ
    75 /-- The relation variables holding the digits, the least significant
    76 first. -/
    77 bit : Fin c → B.ι
    78 /-- They are distinct. -/
    79 bit_injective : Function.Injective bit
    80 /-- They have the same arity. -/
    81 arity_bit : ∀ τ, B.arity (bit τ) = ℓ
    82
    83namespace DigitLFPDef
    84
    85variable {L : Language.{0, 0}} (d : DigitLFPDef L) (A : Type) [L.Structure A] [LinearOrder A]
    86
    87/-- The digit at a position is `1`: the tuple is in the relation of its
    88group. -/
    89def Holds (q : Fin d.c ×ₗ Lex (Fin d.ℓ → A)) : Prop :=
    90 lfpAssign d.rules (d.bit (ofLex q).1)
    91 fun k => ofLex (ofLex q).2 (Fin.cast (d.arity_bit (ofLex q).1) k)
    92
    93open Classical in
    94/-- The value of a definition on an ordered structure: the number whose digit
    95of weight `2 ^ r` is `1` exactly when the position of rank `r` is in its
    96relation of the least fixed point. -/
    97noncomputable def value : ℕ :=
    98 ∑ᶠ q : Fin d.c ×ₗ Lex (Fin d.ℓ → A), if d.Holds A q then 2 ^ orank q else 0
    99
    100end DigitLFPDef
    101
    102/-- A counting problem is **digit-definable** when, on nonempty finite
    103structures, its binary digits are relations of a least fixed point, whatever
    104the linear order. -/
    105def DigitDefinable {L : Language.{0, 0}} [L.IsRelational] (C : CountingProblem L) : Prop :=
    106 ∃ d : DigitLFPDef L, ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A],
    107 C A = d.value A
    108
    109open FirstOrder
    110
    111open Language Structure
    112
    113/-- The terms of quantitative first-order logic over a Boolean layer of
    114first-order formulas, with free variables in `α`, after Arenas, Muñoz, and
    115Riveros, restricted to first-order quantifiers. A quantifier binds a block of
    116`n` variables at once, the variables `Sum.inr i` of `α ⊕ Fin n`; the
    117quantifiers `Σx` and `Πx` of their logic are the case `n = 1`. -/
    118inductive QTerm (L : Language.{0, 0}) : Type → Type 1
    119 /-- A formula: `1` when it holds, `0` when it does not. -/
    120 | ind {α : Type} (φ : L.Formula α) : QTerm L α
    121 /-- A constant. -/
    122 | const {α : Type} (s : ℕ) : QTerm L α
    123 /-- A sum. -/
    124 | add {α : Type} (s t : QTerm L α) : QTerm L α
    125 /-- A product. -/
    126 | mul {α : Type} (s t : QTerm L α) : QTerm L α
    127 /-- `Σx̄. t`: the sum over the `n`-tuples of elements of the structure. -/
    128 | sum {α : Type} (n : ℕ) (t : QTerm L (α ⊕ Fin n)) : QTerm L α
    129 /-- `Πx̄. t`: the product over the `n`-tuples of elements of the structure. -/
    130 | prod {α : Type} (n : ℕ) (t : QTerm L (α ⊕ Fin n)) : QTerm L α
    131
    132namespace QTerm
    133
    134variable {L L' : Language.{0, 0}}
    135
    136open Classical in
    137/-- The value of a term in a structure, under a valuation. -/
    138noncomputable def eval {A : Type} [L.Structure A] : ∀ {α : Type}, QTerm L α → (α → A) → ℕ
    139 | _, ind φ, v => if φ.Realize v then 1 else 0
    140 | _, const s, _ => s
    141 | _, add s t, v => s.eval v + t.eval v
    142 | _, mul s t, v => s.eval v * t.eval v
    143 | _, sum _ t, v => ∑ᶠ w : Fin _ → A, t.eval (Sum.elim v w)
    144 | _, prod _ t, v => ∏ᶠ w : Fin _ → A, t.eval (Sum.elim v w)
    145
    146/-- The value of a closed term. -/
    147noncomputable def value (t : QTerm L Empty) (A : Type) [L.Structure A] : ℕ :=
    148 t.eval (A := A) default
    149
    150end QTerm
    151
    152/-- A definition in QFO(LFP): a least fixed point, as for
    153`LFPDef`, and a quantitative term over the vocabulary
    154expanded by its relations, read at the fixed point. -/
    155structure QLFPDef (L : Language.{0, 0}) : Type 1 where
    156 /-- The relation variables computed by the fixed point. -/
    157 B : SOBlock
    158 /-- The number of first-order variables shared by the rules. -/
    159 k : ℕ
    160 /-- The rules defining the variables. -/
    161 rules : List (HornClause (L.sum Language.order) B k)
    162 /-- The quantitative output. -/
    163 out : QTerm ((L.sum Language.order).sum B.lang) Empty
    164
    165/-- The value of a definition on an ordered structure: the output, read at
    166the least fixed point of the rules. -/
    167noncomputable def QLFPDef.value {L : Language.{0, 0}} (d : QLFPDef L) (A : Type)
    168 [L.Structure A] [LinearOrder A] : ℕ :=
    169 @QTerm.value ((L.sum Language.order).sum d.B.lang) d.out A
    170 (@sumStructure _ _ A _ (d.B.structure (lfpAssign d.rules)))
    171
    172variable {L : Language.{0, 0}} [L.IsRelational]
    173
    174/-- A counting problem is **in FP** when, on nonempty finite structures, it is
    175the value of a definition in QFO(LFP), whatever the linear order. -/
    176def FPDefinable (C : CountingProblem L) : Prop :=
    177 ∃ d : QLFPDef L, ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A],
    178 C A = d.value A
    179
    180open Lax366625.CountingClasses
    181
    182/-- **FP**: the class of the counting problems definable in QFO(LFP). -/
    183def FP : CountingClass :=
    184 CountingClass.ofMem fun C => FPDefinable C
    185
    186end Lax366625.QuantitativeLogic
    187

    Discussion

    Ask a question or add context. Endorsements and structured flags are kept in the review panel above.

    Loading discussion…