Deciding Equality with Uninterpreted Functions using Congruence Closure Constantinos Bartzis.

Slides:



Advertisements
Similar presentations
Model Checking Lecture 4. Outline 1 Specifications: logic vs. automata, linear vs. branching, safety vs. liveness 2 Graph algorithms for model checking.
Advertisements

Introduction to Graphs
NP-Completeness: Reductions
1 Minimum Spanning Tree Prim-Jarnik algorithm Kruskal algorithm.
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
3 -1 Chapter 3 The Greedy Method 3 -2 The greedy method Suppose that a problem can be solved by a sequence of decisions. The greedy method has that each.
Automated Theorem Proving Lecture 4.   Formula := A |  |    A  Atom := b | t = 0 | t < 0 | t  0 t  Term := c | x | t + t | t – t | ct | Select(m,t)
NP-Complete Problems Reading Material: Chapter 10 Sections 1, 2, 3, and 4 only.
Greedy Algorithms Reading Material: Chapter 8 (Except Section 8.5)
Validating Streaming XML Documents Luc Segoufin & Victor Vianu Presented by Harel Paz.
NP-Complete Problems Problems in Computer Science are classified into
Technion 1 Generating minimum transitivity constraints in P-time for deciding Equality Logic Ofer Strichman and Mirron Rozanov Technion, Haifa, Israel.
Search in the semantic domain. Some definitions atomic formula: smallest formula possible (no sub- formulas) literal: atomic formula or negation of an.
Technion 1 (Yet another) decision procedure for Equality Logic Ofer Strichman and Orly Meir Technion.
Last time Proof-system search ( ` ) Interpretation search ( ² ) Quantifiers Equality Decision procedures Induction Cross-cutting aspectsMain search strategy.
Decision Procedures Mooly Sagiv. Bibliography Nelson & Oppen Fast Decision Procedures Based on Congruence Closure JACM 1979 Stump, Dill, Barrett, Levitt.
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
CSE 373, Copyright S. Tanimoto, 2002 Up-trees - 1 Up-Trees Review of the UNION-FIND ADT Straight implementation with Up-Trees Path compression Worst-case.
1 The Theory of NP-Completeness 2 NP P NPC NP: Non-deterministic Polynomial P: Polynomial NPC: Non-deterministic Polynomial Complete P=NP? X = P.
Ofer Strichman, Technion Deciding Combined Theories.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
Deciding a Combination of Theories - Decision Procedure - Changki pswlab Combination of Theories Daniel Kroening, Ofer Strichman Presented by Changki.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
The Theory of NP-Completeness 1. What is NP-completeness? Consider the circuit satisfiability problem Difficult to answer the decision problem in polynomial.
© The McGraw-Hill Companies, Inc., Chapter 3 The Greedy Method.
Binary Decision Diagrams (BDDs)
Chapter 2 Graph Algorithms.
SAT and SMT solvers Ayrat Khalimov (based on Georg Hofferek‘s slides) AKDV 2014.
Spring 2015 Lecture 11: Minimum Spanning Trees
The Complexity of Optimization Problems. Summary -Complexity of algorithms and problems -Complexity classes: P and NP -Reducibility -Karp reducibility.
Solvers for the Problem of Boolean Satisfiability (SAT) Will Klieber Aug 31, 2011 TexPoint fonts used in EMF. Read the TexPoint manual before you.
Leonardo de Moura Microsoft Research. Is formula F satisfiable modulo theory T ? SMT solvers have specialized algorithms for T.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Relations, Functions, and Matrices Mathematical Structures for Computer Science Chapter 4 Copyright © 2006 W.H. Freeman & Co.MSCS Slides Relations, Functions.
NP-Complete Problems. Running Time v.s. Input Size Concern with problems whose complexity may be described by exponential functions. Tractable problems.
NP-COMPLETE PROBLEMS. Admin  Two more assignments…  No office hours on tomorrow.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View BDDs.
Mathematical Preliminaries
NP-Complete problems.
Problem Statement How do we represent relationship between two related elements ?
NP-completeness Section 7.4 Giorgi Japaridze Theory of Computability.
Nikolaj Bjørner Microsoft Research DTU Winter course January 2 nd 2012 Organized by Flemming Nielson & Hanne Riis Nielson.
Strings Basic data type in computational biology A string is an ordered succession of characters or symbols from a finite set called an alphabet Sequence.
Chapter 8: Relations. 8.1 Relations and Their Properties Binary relations: Let A and B be any two sets. A binary relation R from A to B, written R : A.
Daniel Kroening and Ofer Strichman Decision Procedures An Algorithmic Point of View Deciding Combined Theories.
NPC.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
TU/e Algorithms (2IL15) – Lecture 12 1 Linear Programming.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
Computer Systems Laboratory Stanford University Clark W. Barrett David L. Dill Aaron Stump A Framework for Cooperating Decision Procedures.
Daniel Kroening and Ofer Strichman 1 Decision Procedures in First Order Logic Decision Procedures for Equality Logic.
CSE 373, Copyright S. Tanimoto, 2001 Up-trees - 1 Up-Trees Review of the UNION-FIND ADT Straight implementation with Up-Trees Path compression Worst-case.
Satisfiability Modulo Theories and DPLL(T) Andrew Reynolds March 18, 2015.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Decision Procedures in First Order Logic
The Theory of NP-Completeness
P & NP.
CSE 373, Copyright S. Tanimoto, 2001 Up-trees -
ICS 353: Design and Analysis of Algorithms
CSE 373 Data Structures and Algorithms
CS 583 Analysis of Algorithms
The Theory of NP-Completeness
CSE 589 Applied Algorithms Spring 1999
The Greedy Approach Young CS 530 Adv. Algo. Greedy.
Dichotomies in CSP Karl Lieberherr inspired by the paper:
Instructor: Aaron Roth
Lecture 23 NP-Hard Problems
Presentation transcript:

Deciding Equality with Uninterpreted Functions using Congruence Closure Constantinos Bartzis

The problem Determine the validity of formulas like f(a,b)=a  f(f(a, b), b)=a or, equivalently, satisfiability of f(a,b)=a  f(f(a, b), b)  a In 1954 Ackermann showed it is decidable. In 1976 Nelson and Oppen implemented an O(m 2 ) algorithm based on congruence closure computation.

The algorithm of Nelson and Oppen G. Nelson and D. Oppen, “Fast Decision Procedures Based on Congruence Closure”, JACM 1980

Quantifier Free Theory of Equality with Uninterpreted Function Symbols Also known as QFEUF The language consists of  Variables a, b, c, … (also called constants)  Uninterpreted function symbols f, g, …  Predicate “=“  Boolean connectives Example theorem a=b  f(a)=f(b)

Congruence Closure Let G=(V, E) be a directed graph with n labeled vertices and m edges For vertex v, let (v) denote its label and  (v) denote its outdegree Let v[i] denote the ith successor of v Let R be a relation on V Two vertices u and v are congruent under R, if (u)= (v),  (u)=  (v), and for all 1  i  (u), (u[i], v[i])  R.

Congruence Closure R is closed under congruences, if for all vertices u and v that are congruent under R, (u, v)  R. The congruence closure of R is the unique minimal extension R’ of R that is an equivalence relation and is closed under congruences.

Example f f ab v1v1 v2v2 v3v3 v4v4 Let R={(v 4, v 4 ), (v 2, v 3 )}. Then v 1 and v 2 are congruent under R. The equivalence relation associated with the partition {{v 1, v 2, v 3 }, {v 4 }} is closed under congruences. Note that the nodes represent the (sub)terms of the formula: f(a,b)=a  f(f(a, b), b)=a Deducing that v 1 is equivalent to v 3 is analogous to deducing f(f(a, b), b)=a from f(a,b)=a f

Example 2 f v1v1 f v2v2 f v3v3 f v4v4 f v5v5 a v6v6 Let R={(v 1, v 6 ), (v 3, v 6 )}. Then v 2 and v 5 are congruent under R. The congruence closure should also include (v 1, v 4 ). From transitivity, v 4 is equivalent to v 6 Now v 3 is congruent to v 5 All six vertices are equivalent in the congruence closure. We proved that f(f(f(a)))=a  f(f(f(f(f(a)=a  f(a)=a

Computing the Congruence Closure An equivalence relation is represented by its corresponding partition UNION(u, v) combines the equivalence classes of vertices u and v FIND(u) returns the unique name of the class of vertex u Given a relation R that is closed under congruences, the following procedure MERGE(u, v) constructs the congruence closure of R  {(u,v)}

Merge Procedure MERGE(u, v) 1. If FIND(u) = FIND(v) then return 2. Let P u and P v be the set of predecessors of all nodes in the class of u and v, respectively 3. Call UNION(u, v) 4. For each (x,y) s.t. x  P u and y  P v, if FIND(x)  FIND(y) but CONGRUENT(x, y)=TRUE, then MERGE(x,y) CONGRUENT(u, v) 1. If  (u)  (v) or (u)  (v), then return FALSE 2. For 1  i  (u), if FIND(u[i])  FIND(v[i]), then return FALSE 3. Return TRUE

Deciding QFEUF Suffices to check conjunctive formulas t 1 =u 1  …  t p =u p  r 1  s 1  …  r q  s q Algorithm: 1. Construct the corresponding graph G with a node n(x) for each (sub)term x in the formula 2. Let R be the identity relation on the nodes of G 3. For 1  i  p, call MERGE(n(t i ), n(u i )) 4. For 1  i  q, if n(r i ) is equivalent to n(s i ), then return UNSATISFIABLE 5. Return SATISFIABLE

A modern algorithm R. Nieuwenhuis and A. Olivas, “Fast Congruence Closure and Extensions”, 2006

Theory solvers for DPLL(T) Need to be incremental i.e., at each step receive one new constraint and determine satisfiability of the partial conjunction, doing only the necessary extra work.  Nelson and Oppen’s algorithm is incremental Need to provide explanations for unsatisfiability  Nieuwenhuis and Olivas address this issue

Initial transformations Curryfy  Use only one “apply” function symbol f  E.g. g(a) becomes f(g,a) and g(a, h(b), b) becomes f(f(f(g, a), f(h, b)), b)  Only linear growth in size Flatten  Replace subterms with new variables  E.g. f(f(f(g, a), f(h, b)), b) = b becomes {f(g,a)=c, f(h,b)=d, f(c,d)=e, f(e,b)=b}

Data structures 1. Pending: a list of input equations a=b or pairs of input equations (f(a 1,a 2 )=a, f(b 1,b 2 )=b) where a i and b i are already congruent 2. Representative table: array that stores the class representative of each variable 3. Class lists: store all members of each class 4. Use lists: Uselist(a) contains all f(b 1,b 2 )=b s.t. a is a representative of b 1 or b 2 5. Lookup table: Lookup(b,c) is some f(a 1,a 2 )=a s.t. b and c are representatives of a 1, and a 2

Procedure Merge

Procedure Propagate

Producing explanations Explain(e,e’): If a sequence U of unions of pairs (e 1,e 1 ’)…(e p,e p ’) has taken place, it returns a minimal subset E of U such that (e,e’) belongs to the equivalence relation genetared by E. Example: After this sequence of unions (1,8),(7,2),(3,13),(7,1),(6,7),(9,5),(9,3), (14,11),(10,4)(12,9),(4,11),(10,7) a call to Explain(1,4) returns the explanation {(7,1),(10,7),(10,4)} The returned set is unique

A new data structure We want Explain() to run O(k) time, were k is the size of the proof The graph whose edges are the pairs in the sequence of unions is a forest Explain(e,e’) consists of the edges in the path between e and e’ Easy to find if edges are directed towards the root At each Union(e, e’), where |tree(e)|<|tree(e’)|:  Reverse all edges on the path between e and its root  Add an edge e  e’

Example After this sequence of unions (1,8),(7,2),(3,13),(7,1),(6,7),(9,5),(9,3), (14,11),(10,4)(12,9),(4,11),(10,7) The proof forest could be The explanation of (1,4) consists of this path

The new algorithm (also reverse some edges)

Implementation of Explain f(g,h)=d, c=d, f(g,d)=a, e=c, e=b, b=h adcebh 1,32456 On an Explain(a,b) operation, the equations on the paths a  d and b  d are output From 1 and 3, we need to recursively call Explain(h, d) To maintain complexity, make sure no node is visited twice

Good explanations Shorter and older explanations are good because they lead to better backtracking Finding the shortest explanation is NP-hard, however we can still reduce the size of an explanation by removing redundancies Example: a 1 =b 1, a 1 =c 1, f(a 1,a 1 )=a, f(b 1,b 1 )=b, f(c 1,c 1 )=c Explain(a=c) will return all five equations but first and fourth are redundant abcb1b1 a1a1 c1c1

Minimizing explanations Post-process explanations to remove redundant steps. Theorem: A proof is redundant only if it contains three equations of the form f(a 1,a 2 )=a, f(b 1,b 2 )=b, f(c 1,c 2 )=c, where a i, b i and c i are equivalent. Presence of such equations is checked in O(k). Algorithm: While not all equations are marked as necessary, pick an unmarked one. Remove it, if the remaining explanation is correct. Otherwise mark it as necessary. Complextity O(k 2 logk)