extending answer set programs with interpreted functions
play

Extending Answer Set Programs with Interpreted Functions as - PowerPoint PPT Presentation

Extending Answer Set Programs with Interpreted Functions as First-class Citizens Christoph Redl redl@kr.tuwien.ac.at January 16, 2017 Redl C. (TU Vienna) HEX-Programs January 16, 2017 1 / 19 Motivation Outline Motivation 1 Interpreted


  1. Extending Answer Set Programs with Interpreted Functions as First-class Citizens Christoph Redl redl@kr.tuwien.ac.at January 16, 2017 Redl C. (TU Vienna) HEX-Programs January 16, 2017 1 / 19

  2. Motivation Outline Motivation 1 Interpreted Functions as First-class Citzens 2 3 Excursus: HEX-Programs 4 Implementation of Interpreted Functions on Top of HEX-Programs Applications 5 Conclusion 6 Redl C. (TU Vienna) HEX-Programs January 16, 2017 2 / 19

  3. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  4. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  5. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Existing approaches towards interpreted functions typically define functions as part of the program. Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  6. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Existing approaches towards interpreted functions typically define functions as part of the program. Example: loc ( X ) = garage ← car ( X ) , not loc ( X ) � = garage Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  7. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Existing approaches towards interpreted functions typically define functions as part of the program. Example: loc ( X ) = garage ← car ( X ) , not loc ( X ) � = garage Externally defined semantics of function symbols are supported by only few approaches (e.g. HEX-programs, VI-programs, Clingo5). Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  8. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Existing approaches towards interpreted functions typically define functions as part of the program. Example: loc ( X ) = garage ← car ( X ) , not loc ( X ) � = garage Externally defined semantics of function symbols are supported by only few approaches (e.g. HEX-programs, VI-programs, Clingo5). Example: result ( Y ) ← & add [ 4 , 5 ]( X ) , & multiply [ X , 3 ]( Y ) Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  9. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Existing approaches towards interpreted functions typically define functions as part of the program. Example: loc ( X ) = garage ← car ( X ) , not loc ( X ) � = garage Externally defined semantics of function symbols are supported by only few approaches (e.g. HEX-programs, VI-programs, Clingo5). Example: result ( Y ) ← & add [ 4 , 5 ]( X ) , & multiply [ X , 3 ]( Y ) But the functions are not first-class citizens ⇒ this inhibits higher-order functions. Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  10. Motivation Motivation Function Symbols in Answer Set Programs Function symbols are often uninterpreted and are used for structuring information. Example: multiply ( add ( 4 , 5 ) , 3 ) represents the expression ( 4 + 5 ) · 3 , but does not actually evaluate it. Existing approaches towards interpreted functions typically define functions as part of the program. Example: loc ( X ) = garage ← car ( X ) , not loc ( X ) � = garage Externally defined semantics of function symbols are supported by only few approaches (e.g. HEX-programs, VI-programs, Clingo5). Example: result ( Y ) ← & add [ 4 , 5 ]( X ) , & multiply [ X , 3 ]( Y ) But the functions are not first-class citizens ⇒ this inhibits higher-order functions. Goal: Using externally defined functions, but being able to access them as objects, compose them to new functions and pass them to other functions. Redl C. (TU Vienna) HEX-Programs January 16, 2017 3 / 19

  11. Motivation Motivation Main idea Represent interpreted functions themselves by terms in the program. This turns them into first-class citizens, i.e., accessible objects. Redl C. (TU Vienna) HEX-Programs January 16, 2017 4 / 19

  12. Motivation Motivation Main idea Represent interpreted functions themselves by terms in the program. This turns them into first-class citizens, i.e., accessible objects. Since they are objects in the program, they can be passed to other functions. Redl C. (TU Vienna) HEX-Programs January 16, 2017 4 / 19

  13. Motivation Motivation Main idea Represent interpreted functions themselves by terms in the program. This turns them into first-class citizens, i.e., accessible objects. Since they are objects in the program, they can be passed to other functions. At specific points, they can be applied to a list of parameters. Redl C. (TU Vienna) HEX-Programs January 16, 2017 4 / 19

  14. Motivation Motivation Main idea Represent interpreted functions themselves by terms in the program. This turns them into first-class citizens, i.e., accessible objects. Since they are objects in the program, they can be passed to other functions. At specific points, they can be applied to a list of parameters. This paves the way for new modeling techniques: abstract usage of functions, import of functions from outside, design patterns, higher-order techniques from functional programming. Redl C. (TU Vienna) HEX-Programs January 16, 2017 4 / 19

  15. Motivation Motivation Main idea Represent interpreted functions themselves by terms in the program. This turns them into first-class citizens, i.e., accessible objects. Since they are objects in the program, they can be passed to other functions. At specific points, they can be applied to a list of parameters. This paves the way for new modeling techniques: abstract usage of functions, import of functions from outside, design patterns, higher-order techniques from functional programming. Contribution Representation of functions as terms. Based on this representation, we present HEX IFU -programs. A translation of such programs to traditional HEX-programs. Applications. Redl C. (TU Vienna) HEX-Programs January 16, 2017 4 / 19

  16. Interpreted Functions as First-class Citzens Outline Motivation 1 Interpreted Functions as First-class Citzens 2 3 Excursus: HEX-Programs 4 Implementation of Interpreted Functions on Top of HEX-Programs Applications 5 Conclusion 6 Redl C. (TU Vienna) HEX-Programs January 16, 2017 5 / 19

  17. Interpreted Functions as First-class Citzens Representing Interpreted Functions by Terms Basic functions Function symbols f ∈ F are basic function associated with an arity ℓ . We assume that each f ∈ F has an associated (total) semantics function y ): C ℓ �→ T defined for all ℓ -ary vectors � y ∈ C ℓ of constants sem f ( � T . . . set of all function terms constructible over F and C . Redl C. (TU Vienna) HEX-Programs January 16, 2017 6 / 19

  18. Interpreted Functions as First-class Citzens Representing Interpreted Functions by Terms Basic functions Function symbols f ∈ F are basic function associated with an arity ℓ . We assume that each f ∈ F has an associated (total) semantics function y ): C ℓ �→ T defined for all ℓ -ary vectors � y ∈ C ℓ of constants sem f ( � T . . . set of all function terms constructible over F and C . Representing general (possibly composed) functions We let C contain constant symbols # i for all integers i ≥ 1 (placeholders), which are used to represent function parameters. We use T as function-representing (fr-)terms to turn interpreted functions into accessible objects. Redl C. (TU Vienna) HEX-Programs January 16, 2017 6 / 19

  19. Interpreted Functions as First-class Citzens Representing Interpreted Functions by Terms Example Assume that the basic functions multiply and add have the expected semantics. Then the fr-term t 1 = multiply ( add (# 1 , # 2 ) , # 3 ) represents in standard mathematical notation the function ˆ t 1 ( p 1 , p 2 , p 3 ) = ( p 1 + p 2 ) · p 3 . Redl C. (TU Vienna) HEX-Programs January 16, 2017 7 / 19

Recommend


More recommend