First-order logic with order, addition and BIT
Lax895169.BitLogic · concepts/Lax895169/BitLogic.lean · lax-895169
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Definition
The atoms of the bit-level logic over a vocabulary are , the addition of ranks , BIT, and the atoms of . A kernel is a Boolean combination of atoms, and a sentence is in prenex form: a quantifier prefix over finitely many variables followed by a kernel. It holds on a finite linearly ordered -structure when the prefix holds of the kernel.
A decision problem over is bit-definable when some sentence holds, for every nonempty finite -structure and every linear order on , exactly when is a yes-instance of . This is the logic FO(, BIT), in prenex form.
Concept map
Lean source view on GitHub
| 1 | import Mathlib.ModelTheory.Order |
| 2 | import Mathlib.ModelTheory.Semantics |
| 3 | import Lax904597.Problems |
| 4 | import Lax895169.BitPredicate |
| 5 | |
| 6 | /-! |
| 7 | --- |
| 8 | title: First-order logic with order, addition and BIT |
| 9 | type: definition |
| 10 | --- |
| 11 | The atoms of the bit-level logic over a vocabulary are , the |
| 12 | addition of ranks , BIT, and the atoms of . |
| 13 | A kernel is a Boolean combination of atoms, and a sentence is in prenex |
| 14 | form: a quantifier prefix over finitely many variables followed by a kernel. |
| 15 | It holds on a finite linearly ordered -structure when the prefix holds of |
| 16 | the kernel. |
| 17 | |
| 18 | A decision problem over is bit-definable when some sentence holds, |
| 19 | for every nonempty finite -structure and every linear order on , |
| 20 | exactly when is a yes-instance of . This is the logic |
| 21 | FO(, BIT), in prenex form. |
| 22 | -/ |
| 23 | |
| 24 | namespace Lax895169.BitLogic |
| 25 | |
| 26 | open Lax895169.BitPredicate Lax904597.Problems |
| 27 | |
| 28 | open FirstOrder |
| 29 | |
| 30 | open Language Structure |
| 31 | |
| 32 | /-- The atoms of the bit-level logic: the order, the addition of ranks, the bit |
| 33 | of an element at an index, and an input relation at a tuple of variables. -/ |
| 34 | inductive BitAtom (L : Language.{0, 0}) (γ : Type) where |
| 35 | /-- `x ≤ y`. -/ |
| 36 | | le (x y : γ) : BitAtom L γ |
| 37 | /-- `orank x + orank y = orank z`. -/ |
| 38 | | plus (x y z : γ) : BitAtom L γ |
| 39 | /-- The bit of `x` at the index `i` is set. -/ |
| 40 | | bit (i x : γ) : BitAtom L γ |
| 41 | /-- An input relation at a tuple of variables. -/ |
| 42 | | rel {a : ℕ} (R : L.Relations a) (arg : Fin a → γ) : BitAtom L γ |
| 43 | |
| 44 | /-- A quantifier-free kernel over the bit-level atoms. -/ |
| 45 | inductive BitKernel (L : Language.{0, 0}) (γ : Type) where |
| 46 | /-- An atom. -/ |
| 47 | | atom (a : BitAtom L γ) : BitKernel L γ |
| 48 | /-- The constant `true`, so that a trivial relation needs no dummy variable. -/ |
| 49 | | tt : BitKernel L γ |
| 50 | /-- Negation. -/ |
| 51 | | not (k : BitKernel L γ) : BitKernel L γ |
| 52 | /-- Conjunction. -/ |
| 53 | | and (k k' : BitKernel L γ) : BitKernel L γ |
| 54 | /-- Disjunction. -/ |
| 55 | | or (k k' : BitKernel L γ) : BitKernel L γ |
| 56 | |
| 57 | /-- **A sentence of the bit-level logic, in prenex form**: a polarity per |
| 58 | variable and a quantifier-free kernel. -/ |
| 59 | structure BitSentence (L : Language.{0, 0}) where |
| 60 | /-- The number of quantified variables. -/ |
| 61 | vars : ℕ |
| 62 | /-- The quantifier at each variable: `true` existential, `false` universal. -/ |
| 63 | pol : Fin vars → Bool |
| 64 | /-- The quantifier-free kernel. -/ |
| 65 | kernel : BitKernel L (Fin vars) |
| 66 | |
| 67 | namespace BitAtom |
| 68 | |
| 69 | variable {L : Language.{0, 0}} {γ : Type} |
| 70 | |
| 71 | /-- What an atom says of a valuation. -/ |
| 72 | def Holds {A : Type} [L.Structure A] [LinearOrder A] [Finite A] : |
| 73 | BitAtom L γ → (γ → A) → Prop |
| 74 | | .le x y, v => v x ≤ v y |
| 75 | | .plus x y z, v => orank (v x) + orank (v y) = orank (v z) |
| 76 | | .bit i x, v => BitIx (v i) (v x) |
| 77 | | .rel R arg, v => RelMap R fun t => v (arg t) |
| 78 | |
| 79 | end BitAtom |
| 80 | |
| 81 | namespace BitKernel |
| 82 | |
| 83 | variable {L : Language.{0, 0}} {γ : Type} |
| 84 | |
| 85 | /-- What a kernel says of a valuation. -/ |
| 86 | def Holds {A : Type} [L.Structure A] [LinearOrder A] [Finite A] : |
| 87 | BitKernel L γ → (γ → A) → Prop |
| 88 | | .atom a, v => a.Holds v |
| 89 | | .tt, _ => True |
| 90 | | .not k, v => ¬ k.Holds v |
| 91 | | .and k k', v => k.Holds v ∧ k'.Holds v |
| 92 | | .or k k', v => k.Holds v ∨ k'.Holds v |
| 93 | |
| 94 | end BitKernel |
| 95 | |
| 96 | namespace BitSentence |
| 97 | |
| 98 | /-- What a sentence says of an instance: the prefix, played over the kernel. -/ |
| 99 | def Holds {L : Language.{0, 0}} (φ : BitSentence L) (A : Type) [L.Structure A] [LinearOrder A] |
| 100 | [Finite A] : Prop := |
| 101 | prefixHolds (A := A) φ.vars φ.pol fun v => φ.kernel.Holds v |
| 102 | |
| 103 | end BitSentence |
| 104 | |
| 105 | /-- A decision problem is **bit-definable** when a prenex sentence over the |
| 106 | order, the addition and the bit at an index – `FO(≤, +, BIT)` – decides it on |
| 107 | every nonempty finite ordered structure. -/ |
| 108 | def BitDefinable {L : Language.{0, 0}} [L.IsRelational] (P : DecisionProblem L) : Prop := |
| 109 | ∃ φ : BitSentence L, ∀ (A : Type) [L.Structure A] [LinearOrder A] [Finite A] [Nonempty A], |
| 110 | P A ↔ φ.Holds A |
| 111 | |
| 112 | end Lax895169.BitLogic |
| 113 |
Used by
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments