Programming from Galois Connections Anisa Allahdadi Thematic Seminar 21 June 2012
Objectives Problem Statements: one defining a broad class of solutions (the easy part) requesting one particular optimal solution, (the hard part) This article introduces a binary relational combinator which mirrors this linguistics structure and exploits its potential for calculating programs by optimization.
Some skills of a good programmer Abstraction Abstract Modeling, in the early stages of thinking about a software problem Induction Solving a complex program by imagining some smaller parts already solved Divide and conquer programming strategy
The “Best” Solution Whole number division: x ÷ y is the largest natural number when multiplied by y, is at most x takeWhile p: longest prefix of the input list such that all elements satisfy predicate p Scheduling: The best schedule for a collection of tasks, given their time spans and an acyclic graph
Easy / Hard E: the collection of solution candidates H: criteria under which a best solution is chosen
Example #1 x ÷ y is the largest natural number that, when multiplied by y, is at most x.
Galois Connection A Galois connection is a pair of functions f and g satisfying: f and g are adjoints of each other (f is the lower adjoint and g is the upper adjoint)
Example #2 Indirect Equality Galois connection blending with indirect equality
Cont.
Example #3 Take (n, x): yields the longest prefix of its input sequence up to some given length n.
Cont.
Shrink Operator Galois adjoints By the easy part E is “shrunk” by the requirements of the hard part H
Cont. Factoring Galois connection into two parts
Cont. Abbreviate to : the left hand operator: the right hand operand: Given two relations of and , “Shrunk by R”:
Conclusion Galois connection as a well-known mathematical device capable of scaling up “programming from Galois connections” is proposed as a way of calculating programs from specifications in form of Galois connections The main contribution of this work: using the algebra of programming expressed in closed formula which records what is “easy” and “hard” to implement A new relational combinator (shrinking) expressing such formula at pointfree level Cons: not every problem casts into a Galois connection
Questions? Thanks for your time!