Documentation

CslibFrontier.Computability.RelationProgram

Finite Boolean relation programs #

This formalizes the six positive equation forms on bit-vector addresses from Section 4.1 of Balasubramanian and Majumdar. The ground facts form a finite space. The least closed set is obtained by iterating the consequence operator from the empty set for at most r * 2 ^ H steps. This module gives a semantics and a finite decision procedure. The construction here does not include the paper's pushdown simulation.

Main definitions #

Main results #

References #

The six positive equation forms in Balasubramanian and Majumdar's relation programs. Assignment modifies the queried address, not the program.

@[reducible, inline]

One positive equation for each predicate.

An application of a predicate to a Boolean address.

  • predicate : Fin r

    Predicate applied by this fact.

  • address : BitVec H

    Its Boolean address.

Instances For
    def Cslib.RelationProgram.instDecidableEqFact.decEq {r✝ H✝ : ℕ} (x✝ x✝¹ : Fact r✝ H✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]

    Number the ground facts in predicate and address order.

    @[instance_reducible]
    def Cslib.RelationProgram.overwrite {H : ℕ} (u : BitVec H) (p : Fin H) (b : Bool) :

    Set one bit of an address, preserving the other bits.

    theorem Cslib.RelationProgram.overwrite_bit {H : ℕ} (u : BitVec H) (p q : Fin H) (b : Bool) :
    (overwrite u p b).getLsbD ↑q = if ↑p = ↑q then b else u.getLsbD ↑q

    Reading an overwritten bit returns the new value. Other bits are unchanged.

    def Cslib.RelationProgram.step {r H : ℕ} (P : Program r H) (X : Fact r H → Prop) (f : Fact r H) :

    Apply all positive equations once to a candidate set of facts.

    theorem Cslib.RelationProgram.step_mono {r H : ℕ} (P : Program r H) {X Y : Fact r H → Prop} (h : ∀ (f : Fact r H), X f → Y f) (f : Fact r H) :
    step P X f → step P Y f

    The consequence operator is monotone.

    def Cslib.RelationProgram.stage {r H : ℕ} (P : Program r H) :
    ℕ → Fact r H → Prop

    Iterate the consequence operator starting with no facts.

    theorem Cslib.RelationProgram.stage_le {r H : ℕ} (P : Program r H) {i j : ℕ} (h : i ≤ j) (f : Fact r H) :
    stage P i f → stage P j f

    Later stages contain every fact from earlier stages.

    def Cslib.RelationProgram.derives {r H : ℕ} (P : Program r H) (f : Fact r H) :

    A fact is derivable if it occurs at a finite stage.

    def Cslib.RelationProgram.Closed {r H : ℕ} (P : Program r H) (X : Fact r H → Prop) :

    A set is closed when it contains all of its immediate consequences.

    The set of derivable facts is closed.

    theorem Cslib.RelationProgram.derives_iff_all_closed {r H : ℕ} (P : Program r H) (f : Fact r H) :
    derives P f ↔ ∀ (X : Fact r H → Prop), Closed P X → X f

    A fact is derivable exactly when every closed set contains it.

    theorem Cslib.RelationProgram.derives_fixed {r H : ℕ} (P : Program r H) (f : Fact r H) :
    step P (derives P) f ↔ derives P f

    One consequence step preserves the derivable facts.

    Enumerate all ground facts in predicate and address order.

    theorem Cslib.RelationProgram.mem_facts {r H : ℕ} (f : Fact r H) :
    f ∈ facts r H

    The finite enumeration contains every ground fact.

    theorem Cslib.RelationProgram.facts_length (r H : ℕ) :
    (facts r H).length = r * 2 ^ H

    There are r * 2 ^ H ground facts.

    def Cslib.RelationProgram.consequence {r H : ℕ} (P : Program r H) :
    Set (Fact r H) →o Set (Fact r H)

    The order homomorphism on sets of ground facts induced by a relation program.

    The least fixed point of the consequence operator is the set of derivable facts.

    theorem Cslib.RelationProgram.derives_iff_stage_card {r H : ℕ} (P : Program r H) (f : Fact r H) :
    derives P f ↔ stage P (r * 2 ^ H) f

    Iteration over the grounded facts reaches the least model in at most one stage per fact.

    def Cslib.RelationProgram.next {r H : ℕ} (P : Program r H) (X : Fact r H → Bool) (f : Fact r H) :

    One executable round of the positive equations.

    def Cslib.RelationProgram.evaluate {r H : ℕ} (P : Program r H) (f : Fact r H) :

    Decide derivability by iterating over the finite address space.

    theorem Cslib.RelationProgram.evaluate_eq_true_iff {r H : ℕ} (P : Program r H) (f : Fact r H) :

    The executable iteration returns true exactly on derivable facts.