On the Design of a Galculator
Upcoming SlideShare
Loading in...5
×
 

On the Design of a Galculator

on

  • 379 views

Presented at CIC09, Braga, Portugal in May 7-8, 2009.

Presented at CIC09, Braga, Portugal in May 7-8, 2009.

Statistics

Views

Total Views
379
Views on SlideShare
379
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    On the Design of a Galculator On the Design of a Galculator Presentation Transcript

    • On the design of a Galculator Paulo Silva Departamento de Informática Universidade do Minho Braga, Portugal Third Joint Research Workshop on Coinduction, Interaction and Composition May 7 – 8, 2009 Braga LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 1 / 29
    • Outline Outline 1 Introduction Motivation Objectives 2 Theoretical background Indirect equality Galois connections Point-free transform 3 Galculator 4 Conclusion Conclusion Future work LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 2 / 29
    • Introduction Outline 1 Introduction Motivation Objectives 2 Theoretical background Indirect equality Galois connections Point-free transform 3 Galculator 4 Conclusion Conclusion Future work LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 3 / 29
    • Introduction Motivation Software correctness Current approaches Software correctness is an ambitious challenge Logic based approaches benefit from the help of theorem provers Sometimes proofs are hindered by the theory It is not always easy to devise the correct strategy Alternatives Sometimes algebraic approaches are possible Algebras “abstract” the underlying logic Proofs become more syntactic Galois connections can play an important role Paulo Silva (UMinho) On the design of a Galculator LogoDI2 CIC’09 4 / 29
    • Introduction Motivation Whole division implementation Haskell code x ‘div ‘ y | x < y = 0 | x y = (x − y ) ‘div ‘ y + 1 for non-negative x and positive y . This is the code. Where is the specification? LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 5 / 29
    • Introduction Motivation Whole division specification Implicit definition c =x ÷y ⇔ ∃r : 0 r <y : x =c×y +r Explicit definition x ÷y = z :: z × y x Galois connection z ×y x ⇔ z x ÷y (y > 0) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 6 / 29
    • Introduction Motivation Whole division specification Implicit definition c =x ÷y ⇔ ∃r : 0 r <y : x =c×y +r Explicit definition x ÷y = z :: z × y x Galois connection z ×y x ⇔ z x ÷y (y > 0) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 6 / 29
    • Introduction Motivation Whole division specification Implicit definition c =x ÷y ⇔ ∃r : 0 r <y : x =c×y +r Explicit definition x ÷y = z :: z × y x Galois connection z ×y x ⇔ z x ÷y (y > 0) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 6 / 29
    • Introduction Motivation Whole division Specification vs. Implementation We can verify if the implementation meets the specification. We can calculate the implementation from the specification. Another useful Galois connection a−b =c ⇔ a=c+b a−b c ⇔ a c+b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 7 / 29
    • Introduction Motivation Whole division Specification vs. Implementation We can verify if the implementation meets the specification. We can calculate the implementation from the specification. Another useful Galois connection a−b =c ⇔ a=c+b a−b c ⇔ a c+b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 7 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷ y assuming x x { cancellation, thanks to a − b z ×y −y ⇔ 0, y > 0 } c⇔a c+b } x −y { distributivity } (z − 1) × y ⇔ { z ×y z −1 ⇔ x ⇔ z x ÷ y assuming x y} (x − y ) ÷ y { a−b z x −y c⇔a c+b } (x − y ) ÷ y + 1 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 8 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷ y assuming x x { cancellation, thanks to a − b z ×y −y ⇔ 0, y > 0 } c⇔a c+b } x −y { distributivity } (z − 1) × y ⇔ { z ×y z −1 ⇔ x ⇔ z x ÷ y assuming x y} (x − y ) ÷ y { a−b z x −y c⇔a c+b } (x − y ) ÷ y + 1 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 8 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷ y assuming x x { cancellation, thanks to a − b z ×y −y ⇔ 0, y > 0 } c⇔a c+b } x −y { distributivity } (z − 1) × y ⇔ { z ×y z −1 ⇔ x ⇔ z x ÷ y assuming x y} (x − y ) ÷ y { a−b z x −y c⇔a c+b } (x − y ) ÷ y + 1 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 8 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷ y assuming x x { cancellation, thanks to a − b z ×y −y ⇔ 0, y > 0 } c⇔a c+b } x −y { distributivity } (z − 1) × y ⇔ { z ×y z −1 ⇔ x ⇔ z x ÷ y assuming x y} (x − y ) ÷ y { a−b z x −y c⇔a c+b } (x − y ) ÷ y + 1 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 8 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷ y assuming x x { cancellation, thanks to a − b z ×y −y ⇔ 0, y > 0 } c⇔a c+b } x −y { distributivity } (z − 1) × y ⇔ { z ×y z −1 ⇔ x ⇔ z x ÷ y assuming x y} (x − y ) ÷ y { a−b z x −y c⇔a c+b } (x − y ) ÷ y + 1 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 8 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷ y assuming x x { cancellation, thanks to a − b z ×y −y ⇔ 0, y > 0 } c⇔a c+b } x −y { distributivity } (z − 1) × y ⇔ { z ×y z −1 ⇔ x ⇔ z x ÷ y assuming x y} (x − y ) ÷ y { a−b z x −y c⇔a c+b } (x − y ) ÷ y + 1 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 8 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷y } x { transitivity, since x < y } z ×y ⇔ x ∧ z ×y <y { since y = 0 } z ×y ⇔ { z z x ∧ z 0 0 entails z × y x, since 0 x } 0 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 9 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷y } x { transitivity, since x < y } z ×y ⇔ x ∧ z ×y <y { since y = 0 } z ×y ⇔ { z z x ∧ z 0 0 entails z × y x, since 0 x } 0 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 9 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷y } x { transitivity, since x < y } z ×y ⇔ x ∧ z ×y <y { since y = 0 } z ×y ⇔ { z z x ∧ z 0 0 entails z × y x, since 0 x } 0 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 9 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷y } x { transitivity, since x < y } z ×y ⇔ x ∧ z ×y <y { since y = 0 } z ×y ⇔ { z z x ∧ z 0 0 entails z × y x, since 0 x } 0 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 9 / 29
    • Introduction Motivation Proof. z ⇔ x ÷y { z ×y z ×y ⇔ x ⇔ z x ÷y } x { transitivity, since x < y } z ×y ⇔ x ∧ z ×y <y { since y = 0 } z ×y ⇔ { z z x ∧ z 0 0 entails z × y x, since 0 x } 0 LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 9 / 29
    • Introduction Objectives Objectives Galculator Build a proof assistant based on Galois connections, their algebra and associated tactics LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 10 / 29
    • Theoretical background Outline 1 Introduction Motivation Objectives 2 Theoretical background Indirect equality Galois connections Point-free transform 3 Galculator 4 Conclusion Conclusion Future work LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 11 / 29
    • Theoretical background Indirect equality Indirect inequality Definition (Indirect inequality) a b ⇔ ∀ x :: x a⇒x b a b ⇔ ∀ x :: b x ⇒a x LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 12 / 29
    • Theoretical background Indirect equality Proof. a=b ⇔ { Anti-symmetry } a ⇔ b∧b a { Indirect inequality } ∀ x :: x ⇔ a⇒x b ∧ ∀ x :: x b⇒x a { Rearranging quantifiers } ∀ x :: x ⇔ a⇒x b∧x b⇒x a { Mutual implication } ∀ x :: x a⇔x b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 13 / 29
    • Theoretical background Indirect equality Proof. a=b ⇔ { Anti-symmetry } a ⇔ b∧b a { Indirect inequality } ∀ x :: x ⇔ a⇒x b ∧ ∀ x :: x b⇒x a { Rearranging quantifiers } ∀ x :: x ⇔ a⇒x b∧x b⇒x a { Mutual implication } ∀ x :: x a⇔x b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 13 / 29
    • Theoretical background Indirect equality Proof. a=b ⇔ { Anti-symmetry } a ⇔ b∧b a { Indirect inequality } ∀ x :: x ⇔ a⇒x b ∧ ∀ x :: x b⇒x a { Rearranging quantifiers } ∀ x :: x ⇔ a⇒x b∧x b⇒x a { Mutual implication } ∀ x :: x a⇔x b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 13 / 29
    • Theoretical background Indirect equality Proof. a=b ⇔ { Anti-symmetry } a ⇔ b∧b a { Indirect inequality } ∀ x :: x ⇔ a⇒x b ∧ ∀ x :: x b⇒x a { Rearranging quantifiers } ∀ x :: x ⇔ a⇒x b∧x b⇒x a { Mutual implication } ∀ x :: x a⇔x b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 13 / 29
    • Theoretical background Indirect equality Proof. a=b ⇔ { Anti-symmetry } a ⇔ b∧b a { Indirect inequality } ∀ x :: x ⇔ a⇒x b ∧ ∀ x :: x b⇒x a { Rearranging quantifiers } ∀ x :: x ⇔ a⇒x b∧x b⇒x a { Mutual implication } ∀ x :: x a⇔x b LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 13 / 29
    • Theoretical background Indirect equality Indirect equality Definition (Indirect equality) a=b ⇔ ∀ x :: x a⇔x b a=b ⇔ ∀ x :: a x ⇔b x LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 14 / 29
    • Theoretical background Galois connections Galois connections Definition (Galois connection) Given two preordered sets (A, A ) and (B, B ) and two functions g f Bo A and A o B , the pair (f , g) is a Galois connection if and only if, for all a ∈ A and b ∈ B: f a B b ⇔ a A gb Graphical notation A  Al f g ,
    • B B or (A, A) o (f ,g) (B, B) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 15 / 29
    • Theoretical background Galois connections Properties Property f a Bb⇔a Agb a A a ⇒f a B f a b B b ⇒g b A g b a A g (f a) f (g b) B b f (g (f a)) = f a g (f (g b)) = g b g (b B b ) = g b A g b f (a A a ) = f a B f a g B= A f ⊥A = ⊥B Description “Shunting rule” Monotonicity (LA) Monotonicity (UA) Lower cancellation Upper cancellation Semi-inverse Semi-inverse Distributivity (UA over meet) Distributivity (LA over join) Top-preservation (UA) Bottom-preservation (LA) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 16 / 29
    • Theoretical background Galois connections Galois connections — Algebra Identity connection (A, A) o (id,id) (A, A) Composition if (A, ) o (f ,g) (B, ) and (B, ) o (h,k ) (h◦f ,g ◦k ) (C, ) then (A, ) o (C, ) Composition is associative and the identity is its unit. Galois connections form a category. LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 17 / 29
    • Theoretical background Galois connections Galois connections — Algebra Converse if (A, ) o (f ,g) (B, ) then (B, ) o (g,f ) (A, ) Relator For every relator F if (A, ) o (f ,g) (B, ) then (FA, F (F f ,F g) )o (FB, F ) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 18 / 29
    • Theoretical background Point-free transform Logic vs. algebra Logic Propositional logic Intuitionistic propositional logic Predicate logic Algebra Boolean algebra Heyting algebra ?? LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 19 / 29
    • Theoretical background Point-free transform Relation algebras Extension of Boolean algebras Original work of De Morgan, Peirce and Schröder Further developed by Tarski in his attempt to formalize set theory without variables Amenable for syntactic manipulation Only one inference rule is needed: substitution of equals by equals Equational reasoning LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 20 / 29
    • Theoretical background Point-free transform Relation algebras Extension of Boolean algebras Original work of De Morgan, Peirce and Schröder Further developed by Tarski in his attempt to formalize set theory without variables Amenable for syntactic manipulation Only one inference rule is needed: substitution of equals by equals Equational reasoning LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 20 / 29
    • Theoretical background Point-free transform Fork algebras Limitation of relation algebras Relations algebras can express first-order predicates with at most three variables Fork algebras Extend relation algebras with a pairing operator Equivalent in expressive and deductive power to first-order logic LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 21 / 29
    • Theoretical background Point-free transform Fork algebras Limitation of relation algebras Relations algebras can express first-order predicates with at most three variables Fork algebras Extend relation algebras with a pairing operator Equivalent in expressive and deductive power to first-order logic LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 21 / 29
    • Theoretical background Point-free transform Point-free transform summary Pointwise ¬(bRa) bRa ∧ bSa bSa ∨ bSa True False b=a aRb ∃ c :: bRc ∧ cSa ∀ x :: xRb ⇒ xSa ∀ x :: aRx ⇒ bSx bRa ∧ cSa bRa ∧ dSc ∀ a, b :: bRa ⇒ bSa ∀ a, b :: bRa ⇔ bSa Paulo Silva (UMinho) Pointfree b(¬R)a b(R ∩ S)a b(R ∪ S)a b a b⊥a b id a bR ◦ a b(R ◦ S)a b(R S)a b(S/R)a (b, c) R, S a (b, d)(R × S)(a, c) R⊆S R=S On the design of a Galculator LogoDI2 CIC’09 22 / 29
    • Theoretical background Point-free transform Point-free definitions Definition (Galois connection) f◦ ◦ B = A ◦ g Definition (Indirect equality) f =g f =g ⇔ ⇔ ◦ f ◦ ◦ f = =g ◦ ◦ g ◦ LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 23 / 29
    • Galculator Outline 1 Introduction Motivation Objectives 2 Theoretical background Indirect equality Galois connections Point-free transform 3 Galculator 4 Conclusion Conclusion Future work LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 24 / 29
    • Galculator Design Principles Combine GC Derive Laws Relation algebra Derive Properties Derive Theory domain Derive Rules TRS Strategies Combine Paulo Silva (UMinho) On the design of a Galculator LogoDI2 CIC’09 25 / 29
    • Conclusion Outline 1 Introduction Motivation Objectives 2 Theoretical background Indirect equality Galois connections Point-free transform 3 Galculator 4 Conclusion Conclusion Future work LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 26 / 29
    • Conclusion Conclusion Conclusion Proof assistant prototype based on Galois connections Innovative approach Combination of Galois connections and point-free calculus Non-trivial example of the application of distinctive features of functional languages Generalized algebraic data types Existential data types Combinatorial approaches (parsing, rewriting) Support for embedded domain specific languages Computations as monads Higher-order functions New: Polymorphic type representation with unification ... LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 27 / 29
    • Conclusion Future work Future work Automated proofs Free-theorems Integration with host theorem provers (e.g., Coq) LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 28 / 29
    • The End Download Source code and documentation available from www.di.uminho.pt/research/galculator Contact Questions to paufil@di.uminho.pt LogoDI2 Paulo Silva (UMinho) On the design of a Galculator CIC’09 29 / 29