Download Calendars as Types and more Summaries Reasoning in PDF only on Docsity!
Calendars as Types
Data Modeling, Constraint Reasoning, and Type Checking
with Calendars
Stephanie Spranger
M¨unchen 2005
Erstgutachter: Prof. Dr. Fran¸cois Bry
Zweitgutachter: Prof. Dr. Nachum Dershowitz (Tel Aviv University, Israel)
Tag der m¨undlichen Pr¨ufung: 22. November 2005
Acknowledgments
This work has been developed during my three-year scholarship from the PhD program “Logics in Computer Science” (GKLI) at the University of Munich, funded by the Ger- man Research Society (DFG). Special thanks are due to Helmut Schwichtenberg who has launched this PhD program.
Above all, I thank my supervisor Fran¸cois Bry, the head of the research unit “Programming and Modeling Languages” (PMS) at the Institute for Informatics at the University of Munich. Without his confidence in my skills and perseverance on the one hand side and his numerous valuable ideas on the other hand side, surely, this work wouldn’t have been realized. Nachum Dershowitz, many thanks to you for examining this thesis and for supporting me during my work. Your interest in calendars, and in particular, your book on calendric calculations has inspired me for this work. I have to thank the team from PMS for a pleasant working atmosphere. Many colleagues from the research unit PMS, from the PhD program GKLI as well as from the REWERSE project (funded by the European Commission and by the Swiss Federal Office for Educa- tion and Science) gave me a lot of ideas. Thanks in particular to Hans J¨urgen Ohlbach, Bernhard Lorenz, Klaus Schulz, Martin Hofmann, and Emmanuel Coquery. And I have to thank Fran¸cois Fages who gave me a hint to easily show completeness of the constraint solver, introduced in this thesis. I thank Arnaud Lallouet for good ideas and an encouraging teamwork in Munich and Orl´eans and Matthias Wagner for his invitation to present this work at DoCoMo Research Labs Europe and the resulting interesting comments and remarks. Furthermore, I thank Jutta Haußer from Japanese studies (“Japan Zentrum”) of the Uni- versity of Munich for an interesting interdisciplinary cooperation; I have learned several things about Japanese time and calendar culture.
I have to exceptionally thank the student Frank-Andr´e Rieß who has worked with me on this project for a long and fruitful period of time.
I want to thank several colleagues from media research (“Institut f¨ur Kommunikationswis- senschaften”) of the University of Munich for good “lunch-times”. Finally, I thank my family and my friends who have sympathized with me for this work.
Munich, 10th October 2005 Stephanie Spranger
Abstract
This thesis investigates real-life calendars, calendar and time expressions, and time and date formats. The thesis aims at the development of computer-based tools for modeling and processing such calendric data, primarily in the “World Wide Web”, in particular regarding today’s internationalization efforts and the vision of the “Semantic Web”. Ap- plications are not only appointment scheduling problems and travel planning referring to calendar expressions like “consultation hour”, “meeting”, or “available departure times” but also mobile applications: a mobile application listing pharmacies in the surround- ing of a (mobile) user will preferably only mention those that are currently open. The temporal and calendric data used in such applications is inherently heterogeneous and context-dependent, referring to cultural, professional, legal, and/or locational aspects. To- day’s Web formalisms lack appropriate and specific tools for temporal and calendric data modeling and for efficiently processing such data. To realize the goal mentioned above, I have chosen a programming language approach to time and calendars that essentially differs from logic-based and algebraic approaches. The thesis underlying this work is twofold:
- “Calendar as Type”: time and calendar expressions such as “day”, month”, “year”, “consultation hour”, and “meeting” are not modeled in a logic or an algebra but, instead, by means of data types. The user is provided with a set of language con- structs (so-called type constructors). Advantages of this approach are: user-friendly modeling, increase of efficiency and consistency, program and document annotation, and abstraction.
- “Theory Reasoning”: Problems such as appointment scheduling or travel planning are formulated in the environment of a constraint solver specific to arbitrary calendar domains (i.e. user-defined data types like “day” or “consultation hour”) rather than by axiomatization, commonly used with approaches based on ontology modeling and reasoning. The constraint solver refers to and relies on (user-defined) calendric types, it maintains the semantics of different calendric types like “day” and “consultation hour”, and it allows for efficient constraint solving with arbitrary calendric data.
Concerning Computer Science, this work is related to research in the area of modeling language design and design of language constructs for programming languages based on concepts and theories from research on type systems and constraint programming. Theo- retical aspects of this work are the use of data types to model time and calendar expressions
iv Abstract
with type checking approaches and constraint solving over different domains referring to such calendric types. Practical aspects of this work are user-friendly language constructs for modeling calendars and calendric data and constraints which can be efficiently pro- cessed. Such specialized language constructs and processing tools for data that refer to a specific domain such as calendars and time are (or will be) important for several Semantic Web applications. Due to use of data types and type checking approaches to temporal and calendric data, the proposed tools can be integrated into any Web language. The thesis shows perspectives for future research on using data types and specific inference algorithms (e.g. constraint solving) for modeling and reasoning on specific theories (e.g. topologies and locational data).
vi Zusammenfassung
wodurch sowohl die Sematik von Kalenderbegriffen wie ”Tag” oder ”Sprechstunde” erhalten als auch die Effizienz des Constraintl¨osers verbessert wird.
In der Informatik ist die Arbeit im Bereich des Entwurfs von Modellierungssprachen und Sprachkonstrukten f¨ur Programmiersprachen unter Verwendung von Konzepten und Theorien der Entwicklung von Typsystemen und Constraintprogrammierung einzuordnen. Theoretische Aspekte der Arbeit sind die Verwendung von Datentypen zur Modellierung (von Kalender- und Zeitbegriffen) und L¨osen von Constraints ¨uber verschiedenen Werte- bereichen. Praktische Aspekte der Arbeit sind benutzerfreundliche Sprachkonstrukte zur Modellierung von Kalendern und Kalender- und Zeitbegriffen und von Anfragen ¨uber Kalender- und Zeitdaten, die maschinell gut verarbeitet werden k¨onnen und die f¨ur viele Anwendungen, insbesondere im ”Semantic Web”, hochnotwendig sind (oder sein werden). Dadurch daß Datatypen und Typr¨ufung verwendet werden, k¨onnen die entwickelten Werk- zeuge in beliebge Websprachen integriert werden. Die Arbeit zeigt Forschungsperspektiven im Bereich der Verwendung von Datentypen und speziellen Inferenzalgorithmen (zum Beispiel Constraintl¨osen) zur Modellierung und Verarbeitung spezieller Theorien (zum Beispiel Topologien und Ortsangaben) auf.
Notations
notation description τ, σ, ρ calendric type (time granularity); kind of points over calendric type τ ∗, σ∗, ρ∗^ kind of intervals over calendric type τ n, σn, ρn^ kind of durations over calendric type α, β, γ type variable ∀α :: K kinding expression, read as “for every type α of kind K”, K := {τ, τ ∗, τ n} σ τ aggregation σ ⊆ τ inclusion cσ→τ , cτ →σ conversion function and its inverse C finite set of aligned calendars, i.e. C := {τ 0 , τ 1 ,... , τn} and for all i ∈ { 1 ..n} τi ⊗ ⊆ τ 0 e CaTTS object language expression te CaTTS-DL object language expression ce CaTTS-CL object language expression Γ typing context ∀α :: K. Γ e : α typing statement trans(∀α :: K. Γ e : α) translation of typing statement ∀α :: K. Γ ` e : α ∀α, β :: K. α ≤ β subtype statement, ≤:= ⊗ ⊆ ∀α, β :: K. cβα coercion, i.e. translation of subtyping statement ∀α, β :: K. α ≤ β X, Y, Z constraint variable X ∈ Dτ^ , calendar domain expression for events Dτ^ := n..m, τ associated domain, n, m ∈ Z, n ≤ X ≤ m X ∈ Dτ^ ∗ , calendar domain expression for tasks Dτ^ ∗ := n..m + d−..d+, τ associated domain, n, m, d−, d+^ ∈ Z, n ≤ SX ≤ m, d−^ ≤ dX ≤ d+, n + d−^ − 1 ≤ EX ≤ m + d+^ − 1 SX := n..m starting point of X dX := d−..d+^ duration of X EX := nE ..mE ending point of X; nE := n + d−^ − 1, mE := m + d+^ − 1 D finite set of calendar domains DE finite set of calendar domain expressions C constraint C finite set of constraints 〈C; DE 〉 constraint problem
Naming and Subscribing Conventions
The choice of metavariable names, numeric subscriptions, and primes is guided throughout this thesis by the following principles.
- In syntax definitions, the bare metavariable e is used for all CaTTS expressions, τ for all calendric types of kind point, τ ∗^ for all types of kind interval, τ n^ for all types of kind duration, α for all types (of any kind), etc.
- In typing rules, the main expression (i.e. the one whose type is being calculated) is always called te in CaTTS-DL and ce in CaTTS-CL. Its subterms are named te 1 , te 2 , etc. (resp. ce 1 , ce 2 , etc.).
- In typing rules and throughout the text, instead of ∀α :: τ.
e : α (resp. ∀α :: τ ∗^ e : α, ∀α :: τ n^ e : α), it is written e : τ (resp. e : τ ∗, e : τ n), for short. - In typing rules, the type of an expression e is called α, written e : α, if it does not have a specific kind; otherwise it is called τ ,τ ∗, or τ n.
- In constraint reasoning, the whole constraint problem being reduced is called 〈C; DE 〉, and the problem it reduces to is called 〈C′; DE′ 〉.
- In constraint reasoning, the type of a constraint variables X is called τ or τ ∗, written Xτ^ (resp. Xτ^
∗ ), short for X is associated to the domain D of type τ , i.e. X ∈ Dτ (resp. short for X is associated to the domain D of type τ ∗, i.e. X ∈ Dτ^ ∗ ).
- The duration (domain) of the domain a variable Xτ^
∗ is associated with is written dXτ ∗^. The type of dXτ ∗^ is called τ n.
- The index (domain) of the domain a variable Xτ^ is associated with is written iXτ. The type of iXτ^ is called Z.
x
- 1 Introduction
- 1.1 Field of Research
- 1.2 Importance of Time and Calendars for the Semantic Web
- 1.2.1 Cultural Concerns
- 1.2.2 Internationalization Efforts
- 1.2.3 Applications
- 1.2.3.1 Web-based Appointment Scheduling
- 1.2.3.2 Web-based Event Planning
- 1.2.3.3 Web-based Budgeting
- 1.3 Thesis’ Contribution: Calendar Types and Constraints
- 1.4 Thesis’ Outline
- 1.4.1 Introduction to the Thesis
- 1.4.2 Background
- 1.4.3 A Time Model for Calendric Data, Types, and Constraints
- 1.4.4 The Language CaTTS
- 1.4.5 Constraint Reasoning with Calendric Data
- 1.4.6 An Approach to Predicate Subtyping with Calendric Types
- 1.4.7 Conclusion of the Thesis
- Information Systems 2 Background: Temporal Knowledge Representation and Reasoning for
- 2.1 Approaches to Temporal Knowledge Representation and Reasoning
- 2.1.1 Implicit Time Models
- 2.1.1.1 Situation Calculus
- 2.1.1.2 Event Calculus
- 2.1.1.3 Dynamic Logic
- 2.1.2 Explicit Time Models
- 2.1.2.1 Point-based Models
- 2.1.2.2 Interval-Based Models
- 2.1.2.3 Combined and Generalized Models
- 2.1.3 Temporal Constraints
- 2.1.3.1 Metric Temporal Constraints
- 2.1.3.2 Qualitative Temporal Constraints
- 2.1.3.3 Metric and Qualitative Constraints Combined xii CONTENTS
- 2.1.4 Time Granularity Systems
- 2.1.4.1 Set-theoretic Time Granularity Systems
- 2.1.4.2 Logic-based Time Granularity Systems
- 2.1.4.3 Automata-based Time Granularity Systems
- 2.2 Calendric Computations
- 2.3 Web and Semantic Web Formalisms and Applications
- 2.3.1 Data Type Definition Languages
- 2.3.1.1 XML DTD
- 2.3.1.2 XML Schema
- 2.3.2 Ontology Languages
- 2.3.2.1 RDF: Resource Description Framework
- 2.3.2.2 OWL: Ontology Web Language
- 2.3.2.3 Applications: Time Ontologies
- 2.3.3 Internationalization
- 2.3.4 Web Services for Calendric Data
- 2.3.4.1 Web-based Meeting Scheduler
- 2.3.4.2 Calendar Web Server
- 2.3.5 Temporal and Active Web Systems
- 2.4 In Comparison with CaTTS
- 2.4.1 Approaches to Temporal Knowledge Representation and Reasoning
- 2.4.2 Calendric Computations
- 2.4.3 Web and Semantic Web Formalisms and Applications
- 3 A Time Model for Calendric Data, Types, and Constraints
- 3.1 Base Time Line
- 3.2 “Discretization” of Time
- 3.2.1 Time Granularities
- 3.2.1.1 Activities over Time Granularities
- 3.2.1.2 Time Granularities in CaTTS
- 3.2.2 Relations between Time Granularities
- 3.2.2.1 Aggregations
- 3.2.2.2 Inclusions
- 3.3 Calendars
- 3.4 Time Granularity Conversion
- 4 The Language CaTTS
- 4.1 CaTTS-DL: Definition Language
- 4.1.1 Reference Time
- 4.1.2 CaTTS-TDL: Type Definition Language
- 4.1.2.1 Predicate Subtypes
- 4.1.2.2 Calendar as Type
- 4.1.3 CaTTS-FDL
- 4.2 CaTTS-CL: Constraint Language CONTENTS xiii
- 4.2.1 Specifying Constraint Problems
- 4.2.2 Answers and Solutions to Constraint Problems
- 4.2.3 Programs
- 4.3 Example: Modeling Calendars and Constraints in CaTTS
- 4.3.1 Calendar Signature
- 4.3.2 Gregorian Calendar
- 4.3.3 Hebrew Calendar
- 4.3.4 An Academic Calendar
- 4.3.5 Time Zones
- 4.3.6 Date Formats
- 4.3.7 Multi-Calendar Appointment Scheduling Problem
- 5 Constraint Reasoning with Calendric Data
- 5.1 Constraint Programming in a Nutshell
- 5.1.1 Constraint Satisfaction Problems
- 5.1.2 Example
- 5.1.3 Proof Rules and Derivations
- 5.2 Multi-Calendar Appointment Scheduling Problems
- 5.3 The Underlying Constraint System
- 5.4 Calendric Constraints
- 5.4.1 Activity Constraints
- 5.4.1.1 Events
- 5.4.1.2 Tasks
- 5.4.2 Time Constraints
- 5.4.3 The Conversion Constraint
- 5.5 The Constraint Propagation Algorithm
- 5.5.1 Achieving Local Consistency
- 5.5.2 Proof Rules for Time Constraints
- 5.5.3 The Proof Rule for the Conversion Constraint
- 5.5.4 Example: Application of Proof Rules
- 5.6 Complexity of the Multi-Calendar Constraint Solver
- 6 An Approach to Predicate Subtyping with Calendric Types
- 6.1 (Sub-)Typing in a Nutshell
- 6.1.1 The Simply Typed Lambda Calculus with Subtyping
- 6.1.2 Subtyping Semantics
- 6.1.2.1 Inclusion Polymorphism
- 6.1.2.2 Implicit Coercion
- 6.1.3 Predicate Subtypes and Dependent Types
- 6.2 Properties and Advantages of Calendric Types
- 6.2.1 Concise Modeling, Documentation, and Annotation
- 6.2.2 Multi-Calendar Support: Modularity, Reuse, and Maintenance
- 6.2.3 Calendar-Conversion Functionality xiv CONTENTS
- 6.2.4 Multi-Calendar Constraint Solving
- 6.2.5 Use in Different Web Languages
- 6.3 Predicate Subtypes in CaTTS
- 6.4 Conversion Function Generation from Type Predicates
- 6.4.1 Definition of the Conversion Function
- 6.4.2 Conversion Function Generation from Aggregation Subtypes
- 6.4.2.1 Periodic Aggregations
- 6.4.2.2 Periodic Aggregations with finite many Exceptions
- 6.4.2.3 Restricted Aggregations
- 6.4.3 Conversion Function Generation from Inclusion Subtypes
- 6.4.3.1 Selections
- 6.4.3.2 Conjunctions
- 6.4.3.3 Disjunctions
- 6.4.3.4 Exceptions
- 6.5 Well-Formed CaTTS-DL Calendar Specifications
- 6.5.1 Syntax
- 6.5.2 Typing Relation
- ification 6.5.3 Example: Checking Well-Formedness of a CaTTS-DL calendar spec-
- 6.6 Note: Equivalence of Calendric Type Definitions
- 6.7 Typing and Subtyping in CaTTS-CL
- 6.7.1 Syntax
- 6.7.2 Subsumption
- 6.7.3 The Subtype Relation
- 6.7.4 The Typing Relation
- 6.7.5 Example: Type Checking a CaTTS-CL Program
- 6.7.6 Consistency Checks based on Calendric Types
- 6.8 Coercion Semantics for Subtyping in CaTTS-CL
- 6.8.1 Coercion Semantics
- 6.8.2 Example: Transforming a CaTTS-CL Program into a CLcatts Program
- 6.8.3 Coherence
- 6.9 Note: Typing CaTTS-DL Calendar Specifications
- 7 Conclusion
- 7.1 Results
- 7.1.1 Underlying Problem
- 7.1.2 CaTTS: A Programming Language Approach to Time and Calendars
- 7.1.3 CaTTS’ Language Processors
- 7.2 Perspectives for Future Research
- 7.2.1 Possible Extensions of the Type Language CaTTS
- 7.2.1.1 Further Directions to Calendric Data Modeling
- 7.2.1.2 Further Directions to Multi-Calendar Constraint Solving
- 7.2.1.3 Further Directions to Type Checking with Calendric Types Contents xv
- 7.2.2 Topologies as Types
- 7.2.2.1 Granularities
- 7.2.2.2 Topological Data Modeling
- 7.3 Concluding Remarks
- A CaTTS’ Syntax
- A.1 Reserved Words
- A.2 Constants
- A.3 Comments
- A.4 Identifiers
- A.5 Grammar
- A.6 Syntactic and Closure Restrictions
- A.7 Note: CaTTS’ Reference Implementation
- B A CHR Implementation of CaTTS’ Constraint Propagation Algorithm
- B.1 Constraints and Functions Available for the Constraint Solver
- B.2 Activity Constraints
- B.3 Bounds Consistency
- B.4 Time Constraints
- B.5 Conversion Constraint
- B.6 Termination
- C A Haskell Implementation of Predicate Subtyping in CaTTS
- C.1 Auxiliary Data Structures and Functions
- C.2 Well-Formedness of CaTTS-DL Calendar Specifications
- C.2.1 Syntax
- C.2.2 Well-Formedness
- C.3 Typing and Subtyping in CaTTS-CL
- C.3.1 Syntax
- C.3.2 Subtyping
- C.3.3 Typing
- C.3.4 Coercion
- C.3.5 Transformation
xvi Contents