# Semantically Equivalent Formulas

• View
19

0

Embed Size (px)

DESCRIPTION

Semantically Equivalent Formulas. Let and be formulas of propositional logic. We say that and are semantically equivalent iff hold. In that case we write . Further, we call valid if holds. - PowerPoint PPT Presentation

Transcript

• Semantically Equivalent FormulasLet and be formulas of propositional logic. We say that and are semantically equivalent iff hold. In that case we write . Further, we call valid if holds.

• Examples of equivalent formulas p q p qp q q pp q p r rp q r p (q r)

• LemmaGiven propositional logic formulas 1, 2, , n, , we have 1, 2, , n iff 1 (2 (3 (n )))

• LiteralA literal is either an atom p or the negation of an atom p.

• Conjunctive Normal Form (CNF)A formula is in conjunctive normal form (CNF) if it is of the form 1 2 . n for some n 1, such that i is a literal, or a disjunction of literal, for all 1 i n.

• Examples for CNF formulas(q p r) (p r) q(p r) (p r) (p r)

• LemmaA disjunction of literals L1 L2 . Lm is valid (i.e., L1 L2 . Lm) iff there are 1 i, j m such that Li is Lj.

• Satisfiable formulasGiven a formula in a propositional logic, we say that is satisfiable if there exists an assignment of truth values to its propositional atoms such that is true.

• PropositionLet be a formula of propositional logic. Then is satisfiable iff is not valid.

• function CNF()/* pre-condition: implication free and in NNF*//* post-condition: CNF() computes an equivalent CNF for */begin function case is a literal : return is 1 2: return CNF(1) CNF(2) is 1 2: return DISTR(CNF(1), CNF(2) ) end caseend function

• function DISTR(1, 2):/* pre-condition: 1 and 2 are in CNF */ /* post-condition: DISTR(1, 2) computes a CNF for 1 2 */

begin function case 1 is 11 12 : return DISTR(11 , 2) DISTR(12 , 2) 2 is 21 22 : return DISTR(1 , 21) DISTR(1 , 22) otherwise (= no conjunction): return 1 2

end caseend function

• function NNF()/* pre-condition: is implication free *//* post-condition: NNF() computes a NNF for */begin function case is a literal : return is 1 : return NNF(1) is 1 2 : return NNF(1) NNF(2) is 1 2 : return NNF(1) NNF(2) is (1 2) : return NNF(1 2) is (1 2) : return NNF(1 2)

end caseend function

• = p q p (r q)IMPL_FREE = IMPL_FREE (p q ) IMPL_FREE (p (r q))= ((IMPL_FREE p ) (IMPL_FREE q )) IMPL_FREE (p (r q))= ((p ) IMPL_FREE q ) IMPL_FREE (p (r q))= (p q ) IMPL_FREE (p (r q))= (p q ) ((IMPL_FREE (p) IMPL_FREE (r q))= (p q ) (p IMPL_FREE (r q))= (p q ) (p ( (IMPL_FREE r) IMPL_FREE (q)))= (p q ) (p ( r IMPL_FREE (q)))= (p q ) (p ( r q))

• IMPL_FREE = (p q ) (p ( r q)) NNF (IMPL_FREE )= NNF ( (p q )) NNF (p ( r q))= NNF ( (p ) q )) NNF (p ( r q))= (NNF (p )) (NNF (q )) NNF (p ( r q))= (p (NNF (q ))) NNF (p ( r q))= (p q ) NNF (p ( r q))= (p q ) ((NNF p) (NNF ( r q)))= (p q ) ( p (NNF ( r q)))= (p q ) ( p ((NNF ( r)) (NNF q)))= (p q ) ( p ( r (NNF q)))= (p q ) ( p ( r q))

• NNF (IMPL_FREE ) = (p q ) ( p ( r q))CNF(NNF (IMPL_FREE ))= CNF ((p q ) ( p (r q)))= DISTR ( CNF (p q ), CNF (p ( r q)))= DISTR (p q , CNF (p ( r q)))= DISTR (p q , p ( r q))= DISTR (p q , p) DISTR (p q , r q)= (p q p) DISTR (p q , r q)= (p q p) (p q r q)

• Horn Formula is a formula of propositional logic if it is of the form 1 2 ... n for some n 1 such that i is of the form p1 p2 ... pki qi

for some ki 1, where p1, p1, , pki, qi are atoms, or T. We call such i a Horn clause.

• Examples of Horn formulas(p q s p) (q r p) (p s s)(p q s ) (q r p) (T s)(p2 p3 p5 p13) (T p2) (p5 p11 )

• Examples of non-Horn formulas(p q s p) (q r p) (p s s)(p q s ) (q r p) (T s)(p2 p3 p5 p13 p27) (T p2) (p5 p11 )(p2 p3 p5 p13 ) (T p2) (p5 p11 )

• function HORN()/* Pre-condition : is a Horn formula*//* Post-condition : HORN() decides the satisfiability for */begin function mark all atoms p where T p is a sub-formula of ; while there is a sub-formula p1 p2 ... pki qi of such that all pj are marked but qi is not do if qi then return unsatisfiable else mark qi for all such subformulas end while return satisfiableend function

• TheoremThe algorithm HORN is correct for the satisfiability decision problem of Horn formulas and has no more than n cycles in its while-loop if n is the number of atoms in . HORN always terminates on correct input.

• Kripke structureLet AP be a set of atomic propositions. A Kripke structure M over AP is a four tuple M= (S, S0, R, L) whereS is a finite set of statesS0 S is the set of initial states.R S S is a transition relation that must be total, that is for every state s S there is a state s S such that R (s, s).L: S 2 AP is a function that labels each state with the set of atomic proposition in that state.

A path in the structure M from a state s is an infinite sequence of states = s0 s1 s2 such that s0 = s and R (si, si+1) holds for all i 0.

• First order representationof Kipke structuresWe use interpreted first order formulas to describe concurrent systems.We use usual logical connectives (and , or , implies , not , and so on) and universal ( ) and existential ( ) quantifications.Let V = {v1, , vn} be the set of system variables. We assume that the variables in V range over a finite set D. A valuation for V is a function that associated a value in D with each variable v in V. Thus, s is a valuation for V when s: V D.A state of a concurrent system can be viewed as a valuation for the set of its variables V. Let V = {v1, , vn}. We think of the variables in V as present state variables and the variables in V as next state variables.

• First order representationof Kipke structuresLet M = (S, S0, R, L) be a Kripke structure.S is the set of all valuations for all variables of the system which can be described by a proposition S. Usually, S = True.The set of initial states S0 can be described by a proposition (on the set of variables) S0.R can be described by a proposition R such that for any two states s and s, R(s, s) holds if R evaluates to True when each variable v is assigned the value s(v) and each variable v is assigned the value s(v).The labeling function L:S 2AP is defined so that L(s) is the subset of all atomic propositions true in s which can be described by some appropriate proposition.

• A simple exampleWe consider a simple system with variables x and y that range over D = {0, 1}. Thus, a valuation for the variables x and y is just a pair (d1, d2) D D where d1 is the value for x and d2 is the value for y. The system consists of one transition

x := (x +y) mod 2,

Which starts from the state in which x = 1 and y = 1.

• A simple example with transition x := (x +y) mod 2S = TrueS0 (x, y) x = 1 y = 1R (x, y, x, y) x = (x +y) mod 2 y = y

• A simple example with transition x := (x +y) mod 2The Kripke structure M = (S, S0, R, L) for this system is simply:S = D D.S0 = {(1,1)}R = {((1,1), (0,1)), ((0,1), (1,1)), ((1,0), (1,0)), ((0,0), (0,0))}.L(1,1) = {x =1, y = 1}, L(0,1) = {x =0, y = 1}, L(1,0) = {x =1, y = 0}, L(0,0) = {x =0, y = 0}.

The only path in the Kripke structure that starts in the initial state is (1,1) (0,1) (1,1) (0,1) .

• Concurrent systems A concurrent system consists of a set of components that execute together. Normally, the components have some means of communicating with each other.

• Modes of execution We will consider two modes of execution: Asynchronous or interleaved execution, in which only one component makes a step at a time, and synchronous execution, in which all of the components make a step at the same time

• Modes of communicationWe will also distinguish three modes of communication. Components can either communicate by changing the value of shared variables or by exchanging messages using queues or some handshaking protocols.

• A modulo 8 counter

SHAPE \* MERGEFORMAT

SHAPE \* MERGEFORMAT

v2

v1

v0

• Synchronous circuitA modulo 8 counterThe transitions of the circuit are given byv0 = v0 v1 = v0 v1v2 = (v0 v1) v2R0 (v, v) (v0 v0)R1 (v, v) (v1 v0 v1) R2 (v, v) (v2 (v0 v1) v2) R (v, v) R0 (v, v) R1 (v, v) R2 (v, v)

• Synchronous circuitGeneral caseLet V = {v0, ., vn-1} and V = {v0, ., vn-1}Let vi = fi (V), 1= 0, , n-1.Define Ri (v, v) ( vi fi (V)).Then, the transition relation can be described as R (v, v) R0 (v, v) Rn-1 (v, v).

• Asynchronous circuitGeneral caseIn this case, the transition relation can be described as R (v, v) R0 (v, v) Rn-1 (v, v),Where Ri (v, v) ( vi fi (V)) j i (vj vj )).

• ExampleLet V = {v0, v1}, v0 = v0 v1 and v1 = v0 v1.Let s be a state with v0 = 1 v1 = 1.For the synchronous model, the only successor of s is the state v0 = 0 v1 = 0.For the asynchronous model, the state s has two successors:1. v0 = 0 v1 = 1 ( the assignment to v0 is taken first).2. v0 = 1 v1 = 0 ( the assignment to v1 is taken first).

• Labeled program Given a statement P, the labeled statement PL is defined as follows:If P is not a composite statement then P = PL. .If P = P1; P2 then PL = P1L ; l : P2L.If P = if b then P1 else P2 end if, then PL = if b then l1 : P1L else l2 : P2L end if.If P = while b do P1 end while, then PL = while b do l1 : P1L e