1 / 92

Semantically Equivalent Formulas

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.

tibor
Télécharger la présentation

Semantically Equivalent Formulas

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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.

  2. Examples of equivalent formulas • p → q ≡ ¬p  q • p → q ≡ ¬q → ¬p • p  q → p ≡ r  ¬r • p  q → r ≡ p → (q →r)

  3. Lemma • Given propositional logic formulas Φ1, Φ2, …, Φn, ψ, we have Φ1, Φ2, …, Φn ╞ ψ iff ╞ Φ1 →(Φ2 → (Φ3 → … → (Φn → ψ)))

  4. Literal • A literal is either an atom p or the negation of an atom ¬p.

  5. 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.

  6. Examples for CNF formulas • (¬q  p  r)  (¬p  r)  q • (p  r)  (¬p  r)  (p  ¬r)

  7. Lemma • A 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.

  8. Satisfiable formulas • Given 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.

  9. Proposition • Let Φ be a formula of propositional logic. Then Φ is satisfiable iff ¬Φ is not valid.

  10. 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 case end function

  11. 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 case end function

  12. 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 case end function

  13. Φ = ¬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))

  14. 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))

  15. 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)

  16. 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.

  17. 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 → ┴)

  18. 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  ┴)

  19. 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 ‘satisfiable’ end function

  20. Theorem • The 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.

  21. Kripke structure Let AP be a set of atomic propositions. A Kripke structure M over AP is a four tuple M= (S, S0, R, L) where • S is a finite set of states • S0 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.

  22. First order representationof Kipke structures • We 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’ = {v’1, …, v’n}. We think of the variables in V as present state variables and the variables in V’ as next state variables.

  23. First order representationof Kipke structures Let 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 propositionS. 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 Rsuch 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.

  24. A simple example We 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.

  25. A simple example with transition x := (x +y) mod 2 • S = True • S0 (x, y) ≡ x = 1  y = 1 • R (x, y, x’, y’) ≡ x’ = (x +y) mod 2  y’ = y

  26. A simple example with transition x := (x +y) mod 2 The 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) ….

  27. 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.

  28. 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

  29. Modes of communication • We 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.

  30. A modulo 8 counter

  31. Synchronous circuitA modulo 8 counter The transitions of the circuit are given by • v’0 = v0 • v’1 = v0 v1 • v’2 = (v0 v1) v2 • R0 (v, v’) ≡ (v’0 ↔ v0) • R1 (v, v’) ≡ (v’1 ↔ v0 v1) • R2 (v, v’) ≡ (v’2 ↔ (v0  v1)v2) • R (v, v’) ≡ R0 (v, v’)  R1 (v, v’)  R2 (v, v’)

  32. Synchronous circuitGeneral case • Let V = {v0, …., vn-1} and V’ = {v’0, …., v’n-1} • Let v’i = fi (V), 1= 0, …, n-1. • Define Ri (v, v’) ≡ ( v’i ↔ fi (V)). • Then, the transition relation can be described as R (v, v’) ≡ R0 (v, v’)  …  Rn-1 (v, v’).

  33. Asynchronous circuitGeneral case • In this case, the transition relation can be described as R (v, v’) ≡ R0 (v, v’)  …  Rn-1 (v, v’), Where Ri (v, v’) ≡ ( v’i ↔ fi (V)) j ≠ i (v’j ↔ vj )).

  34. Example • Let V = {v0, v1}, v’0 = v0 v1 and v’1 = 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).

  35. 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 P1else P2end if, then PL = if b then l1 : P1Lelse l2 : P2Lend if. • If P = while b do P1 end while, then PL = while b do l1 : P1Lend while.

  36. Some assumptions • We assume that P is a labeled statement and that the entry and exit points of P are labeled by m and m’, respectively. • Let pc be a special variable called the program counter that ranges over the set of program labels and an additional value ┴ called the undefined value. • Let V denote the set of program variables, V’ the set of primed variables for V, and pc’ the primed variables for pc. • Let same (Y) = y ε Y (y’ = y).

  37. The set of initial states of P • Given some condition pre (V) on the initial variables for P, S0 (V, pc) ≡pre (V)  pc = m.

  38. The transition relation for P • C (l, P, l’) describes the set of transitions in P as a disjunction of all transitions in the set. • Assignment: C ( l, v ← e, l’) ≡ pc =l  pc’ = l’  v’ = e  same (V \ {v}) • Skip: C ( l, skip, l’) ≡ pc =l  pc’ = l’  same (V) • Sequential composition: C ( l, P1; l’’ : P2, l’) ≡ C ( l, P1, l’’)  C ( l’’, P2, l’)

  39. The transition relation for P (continued) • Conditional: C (l, if b then l1: P1else l2 : P2end if, l’) is the disjunction of the following formulas: • pc = l  pc’ = l1  b  same (V) • pc = l  pc’ = l2  b  same (V) • C (l1, P1, l’) • C (l2, P2, l’)

  40. The transition relation for P (continued) • While: C (l, while b do l1 : P1 end while, l’) is the disjunction of the following formulas: • pc = l  pc’ = l1  b  same (V) • pc = l  pc’ = l’  b  same (V) • C (l1, P1, l)

  41. Concurrent programs • A concurrent program consists of a set of processes that can be executed in parallel. A process is a sequential program. • Let Vi be the set of variables that can be changed by process Pi. V is the set of all program variables. • pci is the program counter of process Pi. PC is the set of all program counters. • A concurrent program has the form cobegin P1 || P2 … || Pncoend where P1, …, Pn are processes.

  42. Labeling transformation • We assume that no two labels are identical and that the entry and exit points of P are labeled m and m’, respectively. • If P = cobegin P1 || P2 … || Pncoend, then PL = cobegin l1 : P1L l’1 || l2 : P2L l’2 || … || ln : PnL l’ncoend.

  43. The set of initial states of P S0 (V, pc) ≡pre (V)  pc = m  i= 1, … n (pci = ┴ )

  44. The transition relation for P C (l, cobegin l1 : P1Ll’1 || … || ln : PnL l’ncoend,l’) Is the disjunction of three formulas: • pc = l  pc’1 = l1  …  pc’n = ln  pc’ = ┴ • pc = ┴  pc1 = l’1  …  pcn = l’n  pc’ = l’  i= 1, … n (pc’i = ┴) • i= 1, … n (C (li, Pi, l’i)  (same (V \ Vi)  same (PC \ {pci}))

  45. Shared variables • Wait: C (l, wait (b), l’) is a disjunction of the following two formulas: • (pci = l  pc’i = l  b  same (Vi)) • (pci = l  pc’i = l’  b  same (Vi)) • Lock (v) (= wait (v = 0)): C (l, lock (v), l’) is a disjunction of the following two formulas: • (pci = l  pc’i = l  v = 1  same (Vi)) • (pci = l  pc’i = l’  v = 0  v’ = 1  same (Vi \ {v})) • Unlock (v): C (l, unlock (v), l’) ≡ pci = l  pc’i = l’  v’ = 0  same (Vi \ {v})

  46. A simple mutual exclusion programP = m: cobegin P0 || P1 coend m’ P0 :: l0 : while Truedo NC0 : wait (turn = 0); CR0 : turn :=1; end while; l’0 P1 :: l1 : whileTrue do NC1 : wait (turn = 1); CR1 : turn := 0; end while; l’1

  47. Kripke structure • pc takes values in the set { m, m’, ┴ }. • pci takes values in the set { li, l’i, NCi, CRi, ┴ }. • V = V0 = V1 = {turn}. • PC = {pc, pc0, pc1}.

  48. The set of initial states of P • S0 (V, PC) ≡ pc = m  pc0 = ┴  pc1 = ┴.

  49. The transition relation for P • R (V, PC, V’, PC’) is the disjunction of the following four formulas: • pc = m  pc’0 = l0  pc’1 = l1  pc’ = ┴. • pc0 = l’0  pc1 = l’1  pc’ = m’  pc’0 = ┴  pc’1 = ┴. • C (l0, P0, l’0)  same (pc, pc1). • C (l1, P1, l’1)  same (pc, pc0).

  50. The transition relation of Pi For each process Pi, C (li, Pi, l’i) is the disjunction of: • pci = li pc’i = NCi  True  same (turn) • pci = NCi pc’i = CRi  turn = i same (turn) • pci = CRi pc’i = li  turn’ = (i+1) mod 2 • pci = NCi pc’i = NCi  turn ≠ i same (turn) • pci = li pc’i = l’i  False  same (turn)

More Related