Typing Linear Constraints Salvatore RUGGIERI and Fred MESNARD Introduction Typing Linear Constraints Types for Moding CLP( R ) Programs Syntax Semantics Checking type assertions A linear programming Salvatore RUGGIERI and Fred MESNARD approach Interlude A parametrized approach Dipartimento di Informatica, Universit` a di Pisa, Italy Moding IREMIA, universit´ e de la R´ eunion, France CLP( R ) Well-moding Preliminary experimental results Conclusion 1/26
Typing Linear Constraints 1 Introduction Salvatore RUGGIERI and Fred MESNARD 2 Types Syntax Introduction Semantics Types Syntax Semantics 3 Checking type assertions Checking type assertions A linear programming approach A linear programming approach Interlude Interlude A parametrized A parametrized approach approach Moding CLP( R ) 4 Moding CLP( R ) Well-moding Preliminary Well-moding experimental results Preliminary experimental results Conclusion 5 Conclusion 2/26
Typing Linear Constraints Salvatore RUGGIERI and Fred MESNARD • Modes for logic programs assign to every predicate Introduction argument an input/output behavior. Types • Input: the predicate argument is ground on calls. Syntax Semantics • Output: the predicate argument is ground on answers. Checking type • Example: :- mode append(in, in, out). assertions A linear programming • Modes can be seen as lightweight specifications. approach Interlude • Groundness is restrictive in the CLP( R ) context. Based on A parametrized approach types, we want to extend the notion of moding to upper Moding CLP( R ) and/or lower bounds as well. Well-moding Preliminary experimental results Conclusion 3/26
Typing Linear Constraints Salvatore RUGGIERI and Fred Definition (types) MESNARD A type is an element of BT = { ⋆, ⊔ , ⊓ , � , ! } . Introduction Types • ! is intended to type variables that show at most one single Syntax Semantics value in every solution, a property known as definiteness ; Checking type assertions • � is intended to type variables that assume a range of A linear programming approach values (hence, lower and upper bounds exist); Interlude A parametrized • ⊔ (resp., ⊓ ) is intended for variables that have a lower approach Moding bound (resp., an upper bound); CLP( R ) Well-moding • ⋆ is to be used when no upper or lower bound can be Preliminary experimental stated. results Conclusion 4/26
Typing Linear Constraints Salvatore RUGGIERI and Fred MESNARD Definition (types assertions) Introduction Types • An atomic type declaration (atd) is an expression x : τ , Syntax Semantics where x is a variable and τ ∈ BT . Checking type • We define vars ( x : τ ) = { x } , and say that x is typed as τ . assertions A linear programming • A type declaration is a sequence of atd’s d 1 , . . . , d n , with approach Interlude n ≥ 0. We define vars ( d 1 , . . . , d n ) = ∪ i =1 .. n vars ( d i ). A parametrized approach • A type assertion is an expression d 1 ⊢ c → d 2 , where Moding CLP( R ) d 1 , d 2 are type declarations and c is a linear constraint. Well-moding Preliminary experimental results Conclusion 5/26
Typing Linear Constraints Example Salvatore RUGGIERI z :! ⊢ y − x ≤ z , y + x ≤ z , − y − 2 x ≤ 5 − z → y : ⊓ , x : ⊔ and Fred MESNARD states that if z has a fixed value then either the set of solutions of the involved constraint is empty or the set of solutions is Introduction such that y has an upper bound and x has a lower bound. Types Syntax Semantics The set of solutions for z = 1: Checking type assertions A linear programming approach Interlude A parametrized approach Moding CLP( R ) Well-moding Preliminary experimental results Conclusion 6/26
Typing Linear Constraints Example Salvatore RUGGIERI z :! ⊢ y − x ≤ z , y + x ≤ z , z ≤ y → y :! , x :! and Fred MESNARD states that if z has a fixed value then either the set of solutions of the involved constraint is empty or both x and y assume a Introduction unique value in it. Types Syntax Semantics The set of solutions for z = 1: Checking type assertions A linear programming approach Interlude A parametrized approach Moding CLP( R ) Well-moding Preliminary experimental results Conclusion 7/26
Definition (semantics) Typing Linear Constraints We associate to an atd d = x : τ a formula φ ( d ) over fresh Salvatore RUGGIERI variables υ ( d ), called parameters, as follows: and Fred MESNARD φ ( x :!) = x = a υ ( x :!) = { a } Introduction Types φ ( x : � ) = a ≤ x ∧ x ≤ b υ ( x : � ) = { a , b } Syntax Semantics φ ( x : ⊔ ) = a ≤ x υ ( x : ⊔ ) = { a } Checking type assertions φ ( x : ⊓ ) = x ≤ b υ ( x : ⊓ ) = { b } A linear programming φ ( x : ⋆ ) = true υ ( x : ⋆ ) = ∅ . approach Interlude A parametrized approach φ and υ extend to type declarations as follows: Moding CLP( R ) Well-moding φ ( d 1 , . . . , d n ) = ∧ i =1 .. n φ ( d i ) υ ( d 1 , . . . , d n ) = ∪ i =1 .. n υ ( d i ) . Preliminary experimental results Conclusion A type assertion d 1 ⊢ c → d 2 is valid if for v = vars ( c ) ∪ vars ( d 1 ) ∪ vars ( d 2 ), the following formula is true in R : ∀ υ ( d 1 ) ∃ υ ( d 2 ) ∀ v . ( φ ( d 1 ) ∧ c ) → φ ( d 2 ) . 8/26
Typing Linear Constraints Salvatore RUGGIERI and Fred MESNARD Example Introduction For the type assertion Types Syntax Semantics z :! ⊢ y − x ≤ z , y + x ≤ z , z ≤ y → y :! , x :! Checking type assertions A linear the formula to be proved is: programming approach Interlude A parametrized ∀ a ∃ b , c ∀ x , y , z . ( z = a ∧ y − x ≤ z ∧ y + x ≤ z ∧ z ≤ y ) approach Moding → ( y = b ∧ x = c ) . CLP( R ) Well-moding Preliminary experimental results Conclusion 9/26
Typing Linear Constraints Salvatore RUGGIERI and Fred MESNARD • Such formulas can be checked by real quantifier elimination methods. Introduction Types • It allows for generalizing to the non-linear case! Syntax Semantics For instance: Mathematica, QEPCAD, Redlog. Checking type • But we observe that our formulas represent a quite assertions A linear restricted class. programming approach Interlude • Our approach switches from A parametrized approach Moding the logical view of constraints-as-formulas CLP( R ) to Well-moding Preliminary experimental a geometric view of constraints-as-polyhedra. results Conclusion 10/26
Typing Linear Constraints Salvatore RUGGIERI Consider a linear constraint c and a type declaration d . and Fred MESNARD • c can be equivalently represented as a linear system of Introduction inequalities A c v ≤ b c where v = vars ( c ) ∪ vars ( d ). Types • The linear constraint φ ( d ) can be represented as Syntax Semantics A d v ≤ B d a d , where a d is the symbolic vector of Checking type parameters in υ ( d ). assertions A linear programming The resulting system φ ( d ) ∧ c is a parameterized system of approach Interlude linear inequalities P , where variables in υ ( d ) play the role of A parametrized approach parameters: Moding CLP( R ) � A c � b c Well-moding � � � � 0 Preliminary v ≤ + a d experimental A d 0 B d results Conclusion 11/26
Typing Linear Constraints Salvatore Definition (Parameterized polyhedron) RUGGIERI and Fred A parameterized polyhedron is a collection of polyhedra defined MESNARD by fixing the value for parameters in a parameterized system of Introduction linear inequalities: Sol ( Ax ≤ b + Ba , u ) = { x | Ax ≤ b + Bu } . Types Syntax Semantics Example Checking type assertions Let d be z :! and c be y − x ≤ z , y + x ≤ z , − y − 2 x ≤ 5 − z . A linear programming We have that φ ( d ) is z = a , and φ ( d ) ∧ c is: approach Interlude A parametrized approach -1 1 -1 0 0 Moding 1 1 -1 x 0 0 CLP( R ) Well-moding ≤ -2 -1 1 y 5 + 0 a Preliminary experimental 0 0 1 z 0 1 results Conclusion 0 0 -1 0 -1 12/26
Typing Linear Constraints Salvatore Let x = v i . RUGGIERI and Fred d ⊢ c → x : τ is valid iff MESNARD for every u , S u = Sol ( P , u ) either is empty or: Introduction • if τ = ! then max { v i | v ∈ S u } = min { v i | v ∈ S u } ∈ R , Types Syntax namely x assumes a single value; Semantics • if τ = � then max { v i | v ∈ S u } ∈ R and Checking type assertions min { v i | v ∈ S u } ∈ R namely both an upper and a lower A linear programming approach bound exist for x ; Interlude A parametrized • if τ = ⊔ then min { v i | v ∈ S u } ∈ R , namely a lower approach Moding bound exists for x ; CLP( R ) Well-moding • if τ = ⊓ then max { v i | v ∈ S u } ∈ R , namely an upper Preliminary experimental results bound exists for x ; Conclusion • if τ = ⋆ then we have nothing to show! 13/26
Recommend
More recommend