Documentation

CslibFrontier.Computability.RelationProgram.DNF

Universal DNF certificates for relation programs #

The certificate construction is original to this formalization. It dualizes the ground Horn closure implications: for every proposed set of ground facts, the matrix tests that the query holds or a closure implication is violated. Each violation uses at most three literals and each fact contributes at most two terms. The bounds count terms and encoded bits.

Main definitions #

Main results #

A DNF states that the query holds or the proposed set of facts is not closed.

theorem Cslib.RelationProgram.certificateMatrix_correct {r H : ℕ} (P : Program r H) (target : Fact r H) :
(∀ (σ : ℕ → Bool), Logic.PL.DNF.eval σ (certificateMatrix P target) = true) ↔ derives P target

Universally quantifying the DNF is equivalent to the query being derivable.

theorem Cslib.RelationProgram.certificateMatrix_name_lt {r H : ℕ} (P : Program r H) (target : Fact r H) {t : Logic.PL.Term ℕ} (ht : t ∈ certificateMatrix P target) {l : Logic.PL.Literal ℕ} (hl : l ∈ t) :
l.1 < r * 2 ^ H

Every literal in the matrix refers to one of the grounded facts.

theorem Cslib.RelationProgram.certificateMatrix_finite_correct {r H : ℕ} (P : Program r H) (target : Fact r H) :
(∀ (σ : Fin (r * 2 ^ H) → Bool), Logic.PL.DNF.eval (fun (v : ℕ) => if h : v < r * 2 ^ H then σ ⟨v, h⟩ else false) (certificateMatrix P target) = true) ↔ derives P target

Quantifying only the finite block of ground variables suffices for the universal DNF.

theorem Cslib.RelationProgram.matrix_terms {r H : ℕ} (P : Program r H) (target : Fact r H) :
List.length (certificateMatrix P target) ≤ 2 * (r * 2 ^ H) + 1

The universal DNF has at most two violation terms per fact plus the query.

theorem Cslib.RelationProgram.certificateMatrix_bits_upper {r H : ℕ} (P : Program r H) (target : Fact r H) :
have F := r * 2 ^ H; have B := F.log2 + 1; ((Logic.PL.encDNFOver Turing.MultiTapeTM.encNat) (certificateMatrix P target)).length ≤ (2 * F + 1) * (24 * B + 31)

The encoded matrix has an explicit bit bound in the number of ground facts.