Logic for Computer Scientists/Propositional Logic/Horn clauses

From testwiki
Jump to navigation Jump to search

Horn clauses

In this subsection we introduce a special class of formulae which are of particular interest for logic programming. Furthermore it turns out that these formulae admit an efficient test for satisfiability.

Definition 9

A formula is a Horn formula if it is in CNF and every disjunction contains at most one positive literal. Horn clauses are clauses, which contain at most one positive literal.

F=(A¬B)          (¬C¬AD)

(¬A¬B)          D¬E

F(BA)               (CAD)

(ABfalse)       (trueD)(Efalse)

where true is a tautology and false is an unsatisfiable formula.

In clause form this can be written as

{{A,¬B},{¬C,¬A,D},{¬A,¬B},{D},{¬E}}

and in the context of logic programming this is written as:

{AB

  DA,C
A,B
E

   D      }


For Horn formula there is an efficient algorithm to test satisfiability of a formula F :


Template:Box

Theorem 6

The above algorithm is correct and stops after n steps, where n is the number of atoms in the formula.

As an immediate consequence we see, that a Horn formula is satisfiable if there is no subformula of the form A1Anfalse.

Horn formulae admit unique least models, i.e. 𝒜 is a unique least model for F if for every model 𝒜 and for every atom B in F holds: if 𝒜(B)=true then 𝒜(B)=true . Note, that this unique least model property does not hold for non Horn formulae: as an example take AB which is obviously non Horn. 𝒜1(A)=true,𝒜1(B)=false is a least model and 𝒜2(A)=false,𝒜2(B)=true as well, hence we have two least models.

Problems

Problem 20 (Propositional)

Let F be a propositional logical formulae and S a subset atomic formula occurring in F. Let TS(F) be the formula which results from F by replacing all occurrences of an atomic formulae AS by ¬A. Example: T{A}(AB)=¬AB. Prove or disprove: There exists an S for

  1. F=AB or
  2. F=ABC, so that TS(F) is equivalent to a Horn formula H (i.e. TS(F)H).

Problem 21 (Propositional)

Apply the marking algorithm to the following formula F.

Which is a least model?

(A¬D¬E)(B¬C)(¬B¬D)D(¬DE)


  1. F=(¬A¬B¬C)¬D(¬EA)EB(¬FC)F
  2. F=(A¬D¬E)(B¬C)(¬B¬D)D(¬DE)



Problem 22 (Propositional)

Decide which one of the indicated CNFs are Horn formulae and transform then into a conjunction of implications:

  1. (ABC)(A¬C)(¬AB)¬B
  2. (S¬PQ)(S¬P¬R)
  3. (A¬A)
  4. A(¬AB)(¬B¬CD)(¬E)(¬A¬C)D



Template:BookCat