cs156 the calculus of computation
play

CS156: The Calculus of Computation Zohar Manna Winter 2010 - PowerPoint PPT Presentation

CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 9: Quantifier-free Equality and Data Structures Page 1 of 48 The Theory of Equality T E E : { = , a , b , c , . . . , f , g , h , . . . , p , q , r , . . . } uninterpreted


  1. CS156: The Calculus of Computation Zohar Manna Winter 2010 Chapter 9: Quantifier-free Equality and Data Structures Page 1 of 48

  2. The Theory of Equality T E Σ E : { = , a , b , c , . . . , f , g , h , . . . , p , q , r , . . . } uninterpreted symbols: • constants a , b , c , . . . • functions f , g , h , . . . • predicates p , q , r , . . . Example: x = y ∧ f ( x ) � = f ( y ) T E -unsatisfiable f ( x ) = f ( y ) ∧ x � = y T E -satisfiable f ( f ( f ( a ))) = a ∧ f ( f ( f ( f ( f ( a ))))) = a ∧ f ( a ) � = a T E -unsatisfiable x = g ( y , z ) → f ( x ) = f ( g ( y , z )) T E -valid Page 2 of 48

  3. Axioms of T E 1. ∀ x . x = x (reflexivity) 2. ∀ x , y . x = y → y = x (symmetry) 3. ∀ x , y , z . x = y ∧ y = z → x = z (transitivity) define = to be an equivalence relation. Axiom schema 4. for each positive integer n and n -ary function symbol f , � n � � ∀ ¯ → f (¯ x , ¯ y . x i = y i x ) = f (¯ y ) i =1 (function) For example, for unary f , the axiom is ∀ x ′ , y ′ . x ′ = y ′ → f ( x ′ ) = f ( y ′ ) Therefore, x = g ( y , z ) → f ( x ) = f ( g ( y , z )) is T E -valid. ( x ′ → x , y ′ → g ( y , z )). Page 3 of 48

  4. Axiom schema 5. for each positive integer n and n -ary predicate symbol p , � n � � ∀ ¯ x , ¯ y . x i = y i → ( p (¯ x ) ↔ p (¯ y )) i =1 (predicate) Thus, for unary p , the axiom is ∀ x ′ , y ′ . x ′ = y ′ → ( p ( x ′ ) ↔ p ( y ′ )) Therefore, a = b → ( p ( a ) ↔ p ( b )) is T E -valid. ( x ′ → a , y ′ → b ). Page 4 of 48

  5. We discuss T E -formulae without predicates For example, for Σ E -formula F : p ( x ) ∧ q ( x , y ) ∧ q ( y , z ) → ¬ q ( x , z ) introduce fresh constant • and fresh functions f p and f q , and transform F to G : f p ( x ) = • ∧ f q ( x , y ) = • ∧ f q ( y , z ) = • → f q ( x , z ) � = • . Page 5 of 48

  6. Equivalence and Congruence Relations: Basics Binary relation R over set S • is an equivalence relation if ◮ reflexive: ∀ s ∈ S . s R s ; ◮ symmetric: ∀ s 1 , s 2 ∈ S . s 1 R s 2 → s 2 R s 1 ; ◮ transitive: ∀ s 1 , s 2 , s 3 ∈ S . s 1 R s 2 ∧ s 2 R s 3 → s 1 R s 3 . Example: Define the binary relation ≡ 2 over the set Z of integers m ≡ 2 n iff ( m mod 2) = ( n mod 2) That is, m , n ∈ Z are related iff they are both even or both odd. ≡ 2 is an equivalence relation • is a congruence relation if in addition n � ∀ s , t . s i R t i → f ( s ) R f ( t ) . i =1 Page 6 of 48

  7. Classes � equivalence � For relation R over set S , congruence � equivalence � class of s ∈ S under R is the congruence = { s ′ ∈ S : sRs ′ } . def [ s ] R Example: The equivalence class of 3 under ≡ 2 over Z is [3] ≡ 2 = { n ∈ Z : n is odd } . Partitions A partition P of S is a set of subsets of S that is � � � ◮ total S ′ = S S ′ ∈ P ◮ disjoint ∀ S 1 , S 2 ∈ P . S 1 � = S 2 → S 1 ∩ S 2 = ∅ Page 7 of 48

  8. Quotient � equivalence � The quotient S / R of S by relation R is the congruence � equivalence � partition of S into classes congruence S / R = { [ s ] R : s ∈ S } . It satisfies total and disjoint conditions. Example: The quotient Z / ≡ 2 is a partition of Z . The set of equivalence classes {{ n ∈ Z : n is odd } , { n ∈ Z : n is even }} Note duality between relations and classes Page 8 of 48

  9. Refinements Two binary relations R 1 and R 2 over set S . R 1 is a refinement of R 2 , R 1 ≺ R 2 , if ∀ s 1 , s 2 ∈ S . s 1 R 1 s 2 → s 1 R 2 s 2 . R 1 refines R 2 . Examples: ◮ For S = { a , b } , R 1 : { aR 1 b } R 2 : { aR 2 b , bR 2 b } Then R 1 ≺ R 2 ◮ For set Z R 1 : { xR 1 y : x mod 2 = y mod 2 } R 2 : { xR 2 y : x mod 4 = y mod 4 } Then R 2 ≺ R 1 . Page 9 of 48

  10. Closures Given binary relation R over S . The equivalence closure R E of R is the equivalence relation s.t. ◮ R refines R E , i.e. R ≺ R E ; ◮ for all other equivalence relations R ′ s.t. R ≺ R ′ , either R ′ = R E or R E ≺ R ′ That is, R E is the “smallest” equivalence relation that “covers” R . Example: If S = { a , b , c , d } and R = { aRb , bRc , dRd } , then • aR E b , bR E c , dR E d since R ⊆ R E ; • aR E a , bR E b , cR E c by reflexivity; • bR E a , cR E b by symmetry; • aR E c by transitivity; • cR E a by symmetry. Similarly, the congruence closure R C of R is the “smallest” congruence relation that “covers” R . Page 10 of 48

  11. T E -satisfiability and Congruence Classes I Definition: For Σ E -formula F : s 1 = t 1 ∧ · · · ∧ s m = t m ∧ s m +1 � = t m +1 ∧ · · · ∧ s n � = t n the subterm set S F of F is the set that contains precisely the subterms of F . Example: The subterm set of F : f ( a , b ) = a ∧ f ( f ( a , b ) , b ) � = a is S F = { a , b , f ( a , b ) , f ( f ( a , b ) , b ) } . Note: we consider only quantifier-free conjunctive Σ E -formulae. Convert non-conjunctive formula F to DNF � i F i , where each disjunct F i is a conjunction of =, � =. Check each disjunct F i . F is T E -satisfiable iff at least one disjunct F i is T E -satisfiable. Page 11 of 48

  12. T E -satisfiability and Congruence Classes II Given Σ E -formula F F : s 1 = t 1 ∧ · · · ∧ s m = t m ∧ s m +1 � = t m +1 ∧ · · · ∧ s n � = t n with subterm set S F , F is T E -satisfiable iff there exists a congruence relation ∼ over S F such that ◮ for each i ∈ { 1 , . . . , m } , s i ∼ t i ; ◮ for each i ∈ { m + 1 , . . . , n } , s i �∼ t i . Such congruence relation ∼ defines T E -interpretation I : ( D I , α I ) of F . D I consists of | S F / ∼ | elements, one for each congruence class of S F under ∼ . Instead of writing I | = F for this T E -interpretation, we abbreviate ∼ | = F The goal of the algorithm is to construct the congruence relation over S F , or to prove that no congruence relation exists. Page 12 of 48

  13. Congruence Closure Algorithm F : s 1 = t 1 ∧ · · · ∧ s m = t m ∧ s m +1 � = t m +1 ∧ · · · ∧ s n � = t n � �� � � �� � generate congruence closure search for contradiction Decide if F is T E -satisfiable. The algorithm performs the following steps: 1. Construct the congruence closure ∼ of { s 1 = t 1 , . . . , s m = t m } over the subterm set S F . Then ∼ | = s 1 = t 1 ∧ · · · ∧ s m = t m . 2. If for any i ∈ { m + 1 , . . . , n } , s i ∼ t i , return unsatisfiable. 3. Otherwise, ∼| = F , so return satisfiable. How do we actually construct the congruence closure in Step 1? Page 13 of 48

  14. Congruence Closure Algorithm (Details) Initially, begin with the finest congruence relation ∼ 0 given by the partition {{ s } : s ∈ S F } . That is, let each term over S F be its own congruence class. Then, for each i ∈ { 1 , . . . , m } , impose s i = t i by merging the congruence classes [ s i ] ∼ i − 1 and [ t i ] ∼ i − 1 to form a new congruence relation ∼ i . To accomplish this merging, ◮ form the union of [ s i ] ∼ i − 1 and [ t i ] ∼ i − 1 ◮ propagate any new congruences that arise within this union. The new relation ∼ i is a congruence relation in which s i ∼ t i . Page 14 of 48

  15. Congruence Closure Algorithm: Example 1 I Given Σ E -formula F : f ( a , b ) = a ∧ f ( f ( a , b ) , b ) � = a Construct initial partition by letting each member of the subterm set S F be its own class: 1. {{ a } , { b } , { f ( a , b ) } , { f ( f ( a , b ) , b ) }} According to the first literal f ( a , b ) = a , merge { f ( a , b ) } { a } and to form partition 2. {{ a , f ( a , b ) } , { b } , { f ( f ( a , b ) , b ) }} According to the (function) congruence axiom, f ( a , b ) ∼ a , b ∼ b f ( f ( a , b ) , b ) ∼ f ( a , b ) , implies resulting in the new partition 3. {{ a , f ( a , b ) , f ( f ( a , b ) , b ) } , { b }} Page 15 of 48

  16. Congruence Closure Algorithm: Example 1 II This partition represents the congruence closure of S F . Is it the case that {{ a , f ( a , b ) , f ( f ( a , b ) , b ) } , { b }} | = F ? No, as f ( f ( a , b ) , b ) ∼ a but F asserts that f ( f ( a , b ) , b ) � = a . Hence, F is T E -unsatisfiable. Page 16 of 48

  17. Congruence Closure Algorithm: Example 2 I Example: Given Σ E -formula F : f ( f ( f ( a ))) = a ∧ f ( f ( f ( f ( f ( a ))))) = a ∧ f ( a ) � = a From the subterm set S F , the initial partition is 1. {{ a } , { f ( a ) } , { f 2 ( a ) } , { f 3 ( a ) } , { f 4 ( a ) } , { f 5 ( a ) }} where, for example, f 3 ( a ) abbreviates f ( f ( f ( a ))). According to the literal f 3 ( a ) = a , merge { f 3 ( a ) } and { a } . From the union, 2. {{ a , f 3 ( a ) } , { f ( a ) } , { f 2 ( a ) } , { f 4 ( a ) } , { f 5 ( a ) }} deduce the following congruence propagations: f 3 ( a ) ∼ a ⇒ f ( f 3 ( a )) ∼ f ( a ) f 4 ( a ) ∼ f ( a ) i.e. and f 4 ( a ) ∼ f ( a ) ⇒ f ( f 4 ( a )) ∼ f ( f ( a )) i.e. f 5 ( a ) ∼ f 2 ( a ) Thus, the final partition for this iteration is the following: 3. {{ a , f 3 ( a ) } , { f ( a ) , f 4 ( a ) } , { f 2 ( a ) , f 5 ( a ) }} . Page 17 of 48

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend