SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
Constructing List Homomorphisms from Proofs

            Yun-Yan Chi             Shin-Cheng Mu

                  IIS, Academia Sinica, Taiwan


                    September 17, 2012




       Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 1/ 25
Prelude
                                Preliminaries
                             The Way To Go



List Homomorphism


    ▸   A function h on lists is called a list homomorphism if it
        satisfies
                           h (xs + ys) = h xs h ys,
                                  +
        for some associative operator ( )
    ▸   E.g. sum (xs + ys) = sum xs + sum ys
                     +




                  Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 2/ 25
Prelude
                                 Preliminaries
                              The Way To Go



List Homomorphism


    ▸   A function h on lists is called a list homomorphism if it
        satisfies
                           h (xs + ys) = h xs h ys,
                                  +
        for some associative operator ( )
    ▸   E.g. sum (xs + ys) = sum xs + sum ys
                     +
    ▸   Potential chances of parallelisation
          ▸   compute h xs and h ys in parallel
          ▸   combine the results using ( )
    ▸   Can a list homomorphism be mechanically constructed?




                   Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 2/ 25
Prelude
                                   Preliminaries
                                The Way To Go



A clue


     ▸   The well-known third list-homomorphism theorem:
           ▸    h is a list homomorphism
           ▸    if h can be foldr (⊲) e and foldl(⊳) e
                for some (⊲), (⊳) and e
     ▸   E.g.

                       sum ([3, 5, 7, 9]) = 3 + sum [5, 7, 9]
                                                   = sum [3, 5, 7] + 9
                                                   = sum [3, 5] + sum [7, 9]




                     Yun-Yan Chi, Shin-Cheng Mu        APLAS 2011 3/ 25
Prelude
                               Preliminaries
                            The Way To Go



But, how?



    ▸   Plenty of previous work was devoted to the construction of
        ( ) from the definitions of (⊲) and (⊳)
    ▸   Practically, efforts are needed to prove
        h = foldr (⊲) e = foldl (⊳) e
    ▸   This occurs often that one of (⊲) or (⊳) is picked as definition
        of h, while the other is much harder to find




                 Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 4/ 25
Prelude
                               Preliminaries
                            The Way To Go



But, how?



    ▸   We may have a good guess of ( ) by mixing (⊲) and (⊳)
    ▸   The proof of the correctness of ( ) is very similar to the proof
        of h = foldr (⊲) e = foldl (⊳) e, which we have to provide
        anyway
    ▸   Our idea: transform the proof of the correctness of ( ) from
        the proof of foldr = foldl, after assembling a possible ( )




                 Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 4/ 25
Prelude    Fold
                           Preliminaries   Tupling
                        The Way To Go      Foldr-Fusion Law




Prelude


Preliminaries
   Fold
   Tupling
   Foldr-Fusion Law


The Way To Go
   Proof by Fusion
   Proof Generalisation




             Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 5/ 25
Prelude    Fold
                                      Preliminaries   Tupling
                                   The Way To Go      Foldr-Fusion Law



Foldr
        ▸   A function h is a instance of foldr (⊲) e if h can be defined as
              ▸    h [] = e
              ▸    h (x xs) = x ⊲ h xs
            for some e and (⊲)
        ▸   E.g.

                                 foldr (⊲) e xs
                             = foldr (⊲) e (x1          (x2      (x3     [ ])))
                             = x1 ⊲ foldr (⊲) e (x2               (x3    [ ]))
                             = ...
                             = x1 ⊲ (x2 ⊲ (x3 ⊲ e))



                        Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 6/ 25
Prelude    Fold
                                      Preliminaries   Tupling
                                   The Way To Go      Foldr-Fusion Law



Foldl
        ▸   Symmetrically, h is a foldl(⊳) e if it can be defined as
              ▸    h [] = e
              ▸    h (xs + [x]) = h xs ⊳ x,
                         +
            for some (⊳) and e
        ▸   E.g.

                            foldl (⊳) e xs
                        = foldl (⊳) e ((([ ] + [x1 ]) + [x2 ]) + [x3 ])
                                             +        +        +
                        = foldl (⊳) e (([ ] + [x1 ]) + [x2 ]) ⊳ x3
                                            +        +
                        = ...
                        = ((e ⊳ x1 ) ⊳ x2 ) ⊳ x3



                        Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 7/ 25
Prelude    Fold
                                 Preliminaries   Tupling
                              The Way To Go      Foldr-Fusion Law



Tupling




     ▸   Not all functions can be a fold
     ▸   Tupling:
         for h, find a k such that ⟨h, k⟩ is a fold
     ▸   ⟨h, k⟩ x = (h x, k x)




                   Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 8/ 25
Prelude    Fold
                                Preliminaries   Tupling
                             The Way To Go      Foldr-Fusion Law



Foldr-Fusion Law

     ▸   One can fuse f and foldr into another foldr




                  Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 9/ 25
Prelude    Fold
                                Preliminaries   Tupling
                             The Way To Go      Foldr-Fusion Law



Foldr-Fusion Law

     ▸   One can fuse f and foldr into another foldr

                      (f ○ foldr (⊲) e) xs
                  = (f ○ foldr (⊲) e) (x1 (x2 (x3 ... [])))
                  = f (x1 ⊲ (x2 ⊲ (x3 ⊲ ... ⊲ e)))
                  =       { f (x ⊲ z) = x ⊕ f z }
                      x1 ⊕ (f (x2 ⊲ (x3 ⊲ ... ⊲ e)))
                  = ...
                  = x1 ⊕ (x2 ⊕ (x3 ⊕ ... ⊕ (f e)))
                  = foldr (⊕) (f e) xs




                  Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 9/ 25
Prelude
                                                  Proof by Fusion
                                  Preliminaries
                                                  Proof Generalisation
                               The Way To Go



Return to our approach


     ▸   Since we try to transform the proof of
           ▸   h = foldr (⊲) e = foldl (⊳) e
         to the proof of
           ▸   the correctness of ( ),
     ▸   we want to know how to
          1. prove that h = foldr (⊲) e = foldl (⊳) e
          2. prove that ( ) do define a list homomorphism
          3. transform the former to the latter




                    Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 10/ 25
Prelude
                                                     Proof by Fusion
                                     Preliminaries
                                                     Proof Generalisation
                                  The Way To Go



h = foldr (⊲) e = foldl (⊳) e

     ▸   Let h = foldr (⊲) e
     ▸   To prove that h = foldl (⊳) e, we have to show
           ▸   h[] = e
           ▸   h (xs + [z]) = h xs ⊳ z
                     +
     ▸   In point-free style: h ○ (+
                                   +[z]) = (⊳ z) ○ h

                        h ○ (+
                             +[z])
                   =       { foldr -fusion, since (+
                                                   +[z]) = foldr ( ) [z] }
                        foldr (⊲) (h [z])
                   =       { foldr -fusion (backwards) }
                        (⊳ z) ○ foldr (⊲) e
                   = (⊳ z) ○ h



                       Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 11/ 25
Prelude
                                                  Proof by Fusion
                                  Preliminaries
                                                  Proof Generalisation
                               The Way To Go



h = foldr (⊲) e = foldl (⊳) e



     ▸   For the second foldr -fusion
           ▸   z ⊲e=e⊳z
           ▸   (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z) - the associativity of (⊲) and (⊳)

     ▸   We will have the proof of h = foldr (⊲) e = foldl (⊳) e
         if we have the proof of above fusion conditions




                    Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 11/ 25
Prelude
                                                    Proof by Fusion
                                    Preliminaries
                                                    Proof Generalisation
                                 The Way To Go



h is list homomorphism

     ▸   To prove that h is a list homomorphism, we have to show
           ▸   h (xs + ys) = h xs
                     +                    h ys
     ▸   In point-free style: h ○ (+
                                   +ys) = ( h ys) ○ h

                     h ○ (+
                          +ys)
                 =     { foldr -fusion, since (+
                                               +ys) = foldr ( ) ys }
                     foldr (⊲) (h ys)
                 =     { foldr -fusion (backwards) }
                     ( h ys) ○ foldr (⊲) e
                 = ( h ys) ○ h




                     Yun-Yan Chi, Shin-Cheng Mu     APLAS 2011 12/ 25
Prelude
                                                     Proof by Fusion
                                  Preliminaries
                                                     Proof Generalisation
                               The Way To Go



h is list homomorphism



     ▸   For the second foldr -fusion
           ▸   h ys = e   h ys
           ▸   (x ⊲ y )   h ys = x ⊲ (y           h ys)

     ▸   If we have the proof of those fusion conditions, we will have
         the proof of ( ) do define a list homomorphism




                    Yun-Yan Chi, Shin-Cheng Mu       APLAS 2011 12/ 25
Prelude
                                                  Proof by Fusion
                                  Preliminaries
                                                  Proof Generalisation
                               The Way To Go



Generalisation

     ▸   To transform the proof of
           ▸   h = foldr (⊲) e = foldl (⊳) e

         to the proof of
           ▸   h (xs + ys) = h xs
                     +                  h ys




                    Yun-Yan Chi, Shin-Cheng Mu    APLAS 2011 13/ 25
Prelude
                                                     Proof by Fusion
                                  Preliminaries
                                                     Proof Generalisation
                               The Way To Go



Generalisation

     ▸   To transform the proof of
           ▸   z ⊲e=e⊳z
           ▸   (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z)
         to the proof of
           ▸   h ys = e   h ys
           ▸   (x ⊲ y )   h ys = x ⊲ (y           h ys)




                    Yun-Yan Chi, Shin-Cheng Mu       APLAS 2011 13/ 25
Prelude
                                                     Proof by Fusion
                                  Preliminaries
                                                     Proof Generalisation
                               The Way To Go



Generalisation

     ▸   To transform the proof of
           ▸   z ⊲e=e⊳z
           ▸   (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z)
         to the proof of
           ▸   h ys = e   h ys
           ▸   (x ⊲ y )   h ys = x ⊲ (y           h ys)

     ▸   To come up with ( ) and its correctness proof
     ▸   Generalise the former proof to the latter by replacing the
         occurrences of z in (⊳) by metavariables




                    Yun-Yan Chi, Shin-Cheng Mu       APLAS 2011 13/ 25
Setup
                          Example: Steep
                                           Proving foldr (⊲) e = foldl (⊳) e
                             Conclusions
                                           Constructing ( )




Example: Steep
   Setup
   Proving foldr (⊲) e = foldl (⊳) e
   Constructing ( )



Conclusions




              Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 14/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   E.g. steep [20, 10, 5, 2]




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   E.g. steep [20, 10, 5, 2]




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   E.g. steep [20, 10, 5, 2]




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   E.g. steep [20, 10, 5, 2]




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   Can steep be a foldr ?




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   Can steep be a foldr ?




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   Can steep be a foldl ?




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   Can steep be a foldl ?




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   Can steep be a foldl ?




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                             Example: Steep
                                              Proving foldr (⊲) e = foldl (⊳) e
                                Conclusions
                                              Constructing ( )



Steep
    ▸   A list of numbers is said to be steep if each number is larger
        than the sum of the numbers to its right.
    ▸   Can steep be a foldl ?




                 Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 15/ 25
Setup
                               Example: Steep
                                                Proving foldr (⊲) e = foldl (⊳) e
                                  Conclusions
                                                Constructing ( )



Cap
      ▸   cap xs, upper-bound of value we can attach to the right of xs
      ▸   cap can be a foldr together with sum




                   Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 16/ 25
Setup
                               Example: Steep
                                                Proving foldr (⊲) e = foldl (⊳) e
                                  Conclusions
                                                Constructing ( )



Cap
      ▸   cap xs, upper-bound of value we can attach to the right of xs
      ▸   cap can be a foldl




                   Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 16/ 25
Setup
                                 Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                    Conclusions
                                                  Constructing ( )



Steep as Fold



     ▸   We can compute steep if we can compute cap
     ▸   ⟨cap, sum⟩ can be foldr (⊲) (∞, 0) and foldl (⊳) (∞, 0),
         where
           ▸   x ⊲ (c2 , s2 ) = ((x − s2 ) ↓ c2 , x + s2 )
           ▸   (c1 , s1 ) ⊳ z = ((c1 − z) ↓ z, s1 + z)
     ▸   It is not so obvious that foldr = foldl




                     Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 17/ 25
Setup
                          Example: Steep
                                           Proving foldr (⊲) e = foldl (⊳) e
                             Conclusions
                                           Constructing ( )




Example: Steep
   Setup
   Proving foldr (⊲) e = foldl (⊳) e
   Constructing ( )



Conclusions




              Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 18/ 25
Setup
                              Example: Steep
                                               Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                               Constructing ( )



Fusion Conditions

     ▸   z ⊲ (∞, 0) = (∞, 0) ⊳ z
     ▸   (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z)
     ▸   The former condition trivially holds:

                                   z ⊲ (∞, 0)
                               =      { definition of (⊲) }
                                   ((z − 0) ↓ ∞, z + 0)
                               =      { arithmetics }
                                   ((∞ − z) ↓ z, 0 + z)
                               =      { definition of (⊳) }
                                   (∞, 0) ⊳ z.



                  Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 19/ 25
Setup
                          Example: Steep
                                           Proving foldr (⊲) e = foldl (⊳) e
                             Conclusions
                                           Constructing ( )



Proof of Associativity

                   (x ⊲ (c, s)) ⊳ z
               =      { definition of (⊲) }
                   ((x − s) ↓ c, x + s) ⊳ z
               =      { definition of (⊳) }
                   ((((x − s) ↓ c) − z) ↓ z, x + s + z)
               =      { (−z) distributes over (↓) }
                   (((x − s − z) ↓ (c − z)) ↓ z, x + s + z)
               =      { arithmetics }
                   (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z)
               =      { definition of (⊲) }
                   x ⊲ ((c − z) ↓ z, s + z)
               =      { definition of (⊳) }
                   x ⊲ ((c, s) ⊳ z)


              Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 20/ 25
Setup
                          Example: Steep
                                           Proving foldr (⊲) e = foldl (⊳) e
                             Conclusions
                                           Constructing ( )




Example: Steep
   Setup
   Proving foldr (⊲) e = foldl (⊳) e
   Constructing ( )



Conclusions




              Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 21/ 25
Setup
                              Example: Steep
                                               Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                               Constructing ( )



The Aim now is



    1. Generalise the proof of
         ▸   (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z)
       to a proof of
         ▸   (x ⊲ y )   (c2 , s2 ) = x ⊲ (y    (c2 , s2 )).
    2. Construct a definition of ( )




                  Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 22/ 25
Setup
                              Example: Steep
                                               Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                               Constructing ( )



Generalise The Proof
     ▸   Copy the proof of associativity
                        (x ⊲ (c, s)) ⊳ z
                    =     { definition of (⊲) }
                        ((x − s) ↓ c, x + s) ⊳ z
                    =     { definition of (⊳)       }
                        ((((x − s) ↓ c) − z) ↓ z, x + s + z)
                    =     { -z distributes over (↓) }
                        (((x − s − z) ↓ (c − z)) ↓ z, x + s + z)
                    =     { arithmetics }
                        (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z)
                    =     { definition of (⊲) }
                        x ⊲ ((c − z) ↓ z, s + z)
                    =     { definition of (⊳)       }
                        x ⊲ ((c, s) ⊳ z)

                  Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 23/ 25
Setup
                              Example: Steep
                                               Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                               Constructing ( )



Generalise The Proof
     ▸   Generalise ⊳ z to       (c2 , s2 )
                       (x ⊲ (c, s)) ⊳ z
                   =      { definition of (⊲) }
                       ((x − s) ↓ c, x + s) ⊳ z
                   =      { definition of (⊳)       }
                       ((((x − s) ↓ c) − z) ↓ z, x + s + z)
                   =      { -z distributes over (↓) }
                       (((x − s − z) ↓ (c − z)) ↓ z, x + s + z)
                   =      { arithmetics }
                       (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z)
                   =      { definition of (⊲) }
                       x ⊲ ((c − z) ↓ z, s + z)
                   =      { definition of (⊳)       }
                       x ⊲ ((c, s) ⊳ z)

                  Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 23/ 25
Setup
                              Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                                  Constructing ( )



Generalise The Proof
     ▸   Generalise ⊳ z to       (c2 , s2 )
                       (x ⊲ (c, s))      (c2 , s2 )
                   =      { definition of (⊲) }
                       ((x − s) ↓ c, x + s)       (c2 , s2 )
                   =      { definition of ( ) }
                       ((((x − s) ↓ c) − z) ↓ z, x + s + z)
                   =      { -z distributes over (↓) }
                       (((x − s − z) ↓ (c − z)) ↓ z, x + s + z)
                   =      { arithmetics }
                       (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z)
                   =      { definition of (⊲) }
                       x ⊲ ((c − z) ↓ z, s + z)
                   =      { definition of ( ) }
                       x ⊲ ((c, s)     (c2 , s2 ))

                  Yun-Yan Chi, Shin-Cheng Mu      APLAS 2011 23/ 25
Setup
                              Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                                  Constructing ( )



Generalise The Proof
     ▸   Replace z by metavariable Xi
                       (x ⊲ (c, s))      (c2 , s2 )
                   =      { definition of (⊲) }
                       ((x − s) ↓ c, x + s)       (c2 , s2 )
                   =      { definition of ( ) }
                       ((((x − s) ↓ c) − z) ↓ z, x + s + z)
                   =      { -z distributes over (↓) }
                       (((x − s − z) ↓ (c − z)) ↓ z, x + s + z)
                   =      { arithmetics }
                       (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z)
                   =      { definition of (⊲) }
                       x ⊲ ((c − z) ↓ z, s + z)
                   =      { definition of ( ) }
                       x ⊲ ((c, s)     (c2 , s2 ))

                  Yun-Yan Chi, Shin-Cheng Mu      APLAS 2011 23/ 25
Setup
                              Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                                  Constructing ( )



Generalise The Proof
     ▸   Replace z by metavariable Xi
                     (x ⊲ (c, s))    (c2 , s2 )
                 =     { definition of (⊲) }
                     ((x − s) ↓ c, x + s)      (c2 , s2 )
                 =     { definition of ( ) }
                     ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X3 )
                 =     { -X1 distributes over (↓) }
                     (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X3 )
                 =     { arithmetics }
                     (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X3 )
                 =     { definition of (⊲) }
                     x ⊲ ((c − X1 ) ↓ X2 , s + X1 )
                 =     { definition of ( ) }
                     x ⊲ ((c, s)    (c2 , s2 ))

                  Yun-Yan Chi, Shin-Cheng Mu      APLAS 2011 23/ 25
Setup
                              Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                                  Constructing ( )



Generalise The Proof
     ▸   (s + X1 ) and (s + X3 ) have to be the same term
                     (x ⊲ (c, s))    (c2 , s2 )
                 =     { definition of (⊲) }
                     ((x − s) ↓ c, x + s)      (c2 , s2 )
                 =     { definition of ( ) }
                     ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X3 )
                 =     { -X1 distributes over (↓) }
                     (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X3 )
                 =     { arithmetics }
                     (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X3 )
                 =     { definition of (⊲) }
                     x ⊲ ((c − X1 ) ↓ X2 , s + X1 )
                 =     { definition of ( ) }
                     x ⊲ ((c, s)    (c2 , s2 ))

                  Yun-Yan Chi, Shin-Cheng Mu      APLAS 2011 23/ 25
Setup
                              Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                 Conclusions
                                                  Constructing ( )



Generalise The Proof
     ▸   (s + X1 ) and (s + X3 ) have to be the same term
                     (x ⊲ (c, s))    (c2 , s2 )
                 =     { definition of (⊲) }
                     ((x − s) ↓ c, x + s)      (c2 , s2 )
                 =     { definition of ( ) }
                     ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X1 )
                 =     { -X1 distributes over (↓) }
                     (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X1 )
                 =     { arithmetics }
                     (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X1 )
                 =     { definition of (⊲) }
                     x ⊲ ((c − X1 ) ↓ X2 , s + X1 )
                 =     { definition of ( ) }
                     x ⊲ ((c, s)    (c2 , s2 ))

                  Yun-Yan Chi, Shin-Cheng Mu      APLAS 2011 23/ 25
Setup
                               Example: Steep
                                                   Proving foldr (⊲) e = foldl (⊳) e
                                  Conclusions
                                                   Constructing ( )



Generalise The Proof
     ▸   Proof of (x ⊲ y )       (c2 , s2 ) = x ⊲ (y          (c2 , s2 ))
                      (x ⊲ (c, s))    (c2 , s2 )
                  =     { definition of (⊲) }
                      ((x − s) ↓ c, x + s)      (c2 , s2 )
                  =     { definition of ( ) }
                      ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X1 )
                  =     { -X1 distributes over (↓) }
                      (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X1 )
                  =     { arithmetics }
                      (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X1 )
                  =     { definition of (⊲) }
                      x ⊲ ((c − X1 ) ↓ X2 , s + X1 )
                  =     { definition of ( ) }
                      x ⊲ ((c, s)    (c2 , s2 ))

                   Yun-Yan Chi, Shin-Cheng Mu      APLAS 2011 23/ 25
Setup
                                 Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                    Conclusions
                                                  Constructing ( )



Refining The ( )

    ▸   (c1 , s1 )   (c2 , s2 ) = ((c1 − X1 ) ↓ X2 , s1 + X1 )
    ▸   Satisfies that (c2 , s2 ) = (∞, 0)            (c2 , s2 )

                              (c2 , s2 ) = ((∞ − X1 ) ↓ X2 , 0 + X1 )
                          ≡ (c2 , s2 ) = (∞ ↓ X2 , X1 )
                          ≡ (c2 , s2 ) = (X2 , X1 )




                     Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 24/ 25
Setup
                                 Example: Steep
                                                  Proving foldr (⊲) e = foldl (⊳) e
                                    Conclusions
                                                  Constructing ( )



Refining The ( )

    ▸   (c1 , s1 )   (c2 , s2 ) = ((c1 − X1 ) ↓ X2 , s1 + X1 )
    ▸   Satisfies that (c2 , s2 ) = (∞, 0)            (c2 , s2 )

                              (c2 , s2 ) = ((∞ − X1 ) ↓ X2 , 0 + X1 )
                          ≡ (c2 , s2 ) = (∞ ↓ X2 , X1 )
                          ≡ (c2 , s2 ) = (X2 , X1 )
    ▸   We have thus discovered that
           ▸   (c1 , s1 ) (c2 , s2 ) = ((c1 − s2 ) ↓ c2 , s1 + s2 )
           ▸   This ( ) has got to be correct, because we have the proof
               already!



                     Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 24/ 25
Example: Steep
                                  Conclusions



Conclusions



     ▸   We have proposed and demonstrated a novel approach to
         constructing ( ).
     ▸   Starting with a trivial generalisation of either (⊲) or (⊳), we
         exploit the constraint enforced by the proof of associativity to
         refine ( ).
     ▸   Once we have constructed ( ), we have its correctness proof
         too.




                   Yun-Yan Chi, Shin-Cheng Mu   APLAS 2011 25/ 25

Weitere ähnliche Inhalte

Was ist angesagt?

Cs229 notes8
Cs229 notes8Cs229 notes8
Cs229 notes8VuTran231
 
Lecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceLecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceasimnawaz54
 
Laplace's Demon: seminar #1
Laplace's Demon: seminar #1Laplace's Demon: seminar #1
Laplace's Demon: seminar #1Christian Robert
 
Dominación y extensiones óptimas de operadores con rango esencial compacto en...
Dominación y extensiones óptimas de operadores con rango esencial compacto en...Dominación y extensiones óptimas de operadores con rango esencial compacto en...
Dominación y extensiones óptimas de operadores con rango esencial compacto en...esasancpe
 
Predicates and Quantifiers
Predicates and Quantifiers Predicates and Quantifiers
Predicates and Quantifiers Istiak Ahmed
 
Predicates and quantifiers presentation topics
Predicates  and quantifiers  presentation topicsPredicates  and quantifiers  presentation topics
Predicates and quantifiers presentation topicsR.h. Himel
 
Predicates and Quantifiers
Predicates and QuantifiersPredicates and Quantifiers
Predicates and Quantifiersblaircomp2003
 
IRJET - Fuzzy Soft Hyperideals in Meet Hyperlattices
IRJET - Fuzzy Soft Hyperideals in Meet HyperlatticesIRJET - Fuzzy Soft Hyperideals in Meet Hyperlattices
IRJET - Fuzzy Soft Hyperideals in Meet HyperlatticesIRJET Journal
 
Harmonic Analysis and Deep Learning
Harmonic Analysis and Deep LearningHarmonic Analysis and Deep Learning
Harmonic Analysis and Deep LearningSungbin Lim
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...HidenoriOgata
 

Was ist angesagt? (15)

Cs229 notes8
Cs229 notes8Cs229 notes8
Cs229 notes8
 
Lecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inferenceLecture 2 predicates quantifiers and rules of inference
Lecture 2 predicates quantifiers and rules of inference
 
Laplace's Demon: seminar #1
Laplace's Demon: seminar #1Laplace's Demon: seminar #1
Laplace's Demon: seminar #1
 
Dominación y extensiones óptimas de operadores con rango esencial compacto en...
Dominación y extensiones óptimas de operadores con rango esencial compacto en...Dominación y extensiones óptimas de operadores con rango esencial compacto en...
Dominación y extensiones óptimas de operadores con rango esencial compacto en...
 
Predicates and Quantifiers
Predicates and Quantifiers Predicates and Quantifiers
Predicates and Quantifiers
 
Limits BY ATC
Limits BY ATCLimits BY ATC
Limits BY ATC
 
Slides mc gill-v3
Slides mc gill-v3Slides mc gill-v3
Slides mc gill-v3
 
Predicates and quantifiers presentation topics
Predicates  and quantifiers  presentation topicsPredicates  and quantifiers  presentation topics
Predicates and quantifiers presentation topics
 
Predicates and Quantifiers
Predicates and QuantifiersPredicates and Quantifiers
Predicates and Quantifiers
 
Math
MathMath
Math
 
Sildes buenos aires
Sildes buenos airesSildes buenos aires
Sildes buenos aires
 
ABC-Gibbs
ABC-GibbsABC-Gibbs
ABC-Gibbs
 
IRJET - Fuzzy Soft Hyperideals in Meet Hyperlattices
IRJET - Fuzzy Soft Hyperideals in Meet HyperlatticesIRJET - Fuzzy Soft Hyperideals in Meet Hyperlattices
IRJET - Fuzzy Soft Hyperideals in Meet Hyperlattices
 
Harmonic Analysis and Deep Learning
Harmonic Analysis and Deep LearningHarmonic Analysis and Deep Learning
Harmonic Analysis and Deep Learning
 
Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...Hyperfunction method for numerical integration and Fredholm integral equation...
Hyperfunction method for numerical integration and Fredholm integral equation...
 

Ähnlich wie Constructing List Homomorphisms from Proofs

Meta-learning and the ELBO
Meta-learning and the ELBOMeta-learning and the ELBO
Meta-learning and the ELBOYoonho Lee
 
Discussion cabras-robert-130323171455-phpapp02
Discussion cabras-robert-130323171455-phpapp02Discussion cabras-robert-130323171455-phpapp02
Discussion cabras-robert-130323171455-phpapp02Deb Roy
 
Testing for mixtures by seeking components
Testing for mixtures by seeking componentsTesting for mixtures by seeking components
Testing for mixtures by seeking componentsChristian Robert
 
Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9Daisuke Yoneoka
 
Jarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introductionJarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introductionPalGov
 
Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?Christian Robert
 
AI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxAI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxYousef Aburawi
 
The dual geometry of Shannon information
The dual geometry of Shannon informationThe dual geometry of Shannon information
The dual geometry of Shannon informationFrank Nielsen
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)SHUBHAM KUMAR GUPTA
 
Presentation iaf 2014 v1
Presentation iaf 2014 v1Presentation iaf 2014 v1
Presentation iaf 2014 v1Fayçal Touazi
 
PAGOdA poster
PAGOdA posterPAGOdA poster
PAGOdA posterDBOnto
 
Notes on Intersection theory
Notes on Intersection theoryNotes on Intersection theory
Notes on Intersection theoryHeinrich Hartmann
 
CISEA 2019: ABC consistency and convergence
CISEA 2019: ABC consistency and convergenceCISEA 2019: ABC consistency and convergence
CISEA 2019: ABC consistency and convergenceChristian Robert
 

Ähnlich wie Constructing List Homomorphisms from Proofs (17)

Meta-learning and the ELBO
Meta-learning and the ELBOMeta-learning and the ELBO
Meta-learning and the ELBO
 
Discussion cabras-robert-130323171455-phpapp02
Discussion cabras-robert-130323171455-phpapp02Discussion cabras-robert-130323171455-phpapp02
Discussion cabras-robert-130323171455-phpapp02
 
Testing for mixtures by seeking components
Testing for mixtures by seeking componentsTesting for mixtures by seeking components
Testing for mixtures by seeking components
 
lacl (1)
lacl (1)lacl (1)
lacl (1)
 
Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9Murphy: Machine learning A probabilistic perspective: Ch.9
Murphy: Machine learning A probabilistic perspective: Ch.9
 
Lecture11
Lecture11Lecture11
Lecture11
 
Slides mc gill-v4
Slides mc gill-v4Slides mc gill-v4
Slides mc gill-v4
 
Jarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introductionJarrar.lecture notes.aai.2011s.ch8.fol.introduction
Jarrar.lecture notes.aai.2011s.ch8.fol.introduction
 
Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?Inferring the number of components: dream or reality?
Inferring the number of components: dream or reality?
 
AI_05_First Order Logic.pptx
AI_05_First Order Logic.pptxAI_05_First Order Logic.pptx
AI_05_First Order Logic.pptx
 
The dual geometry of Shannon information
The dual geometry of Shannon informationThe dual geometry of Shannon information
The dual geometry of Shannon information
 
Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)Predicate logic_2(Artificial Intelligence)
Predicate logic_2(Artificial Intelligence)
 
Presentation iaf 2014 v1
Presentation iaf 2014 v1Presentation iaf 2014 v1
Presentation iaf 2014 v1
 
PAGOdA poster
PAGOdA posterPAGOdA poster
PAGOdA poster
 
Probability[1]
Probability[1]Probability[1]
Probability[1]
 
Notes on Intersection theory
Notes on Intersection theoryNotes on Intersection theory
Notes on Intersection theory
 
CISEA 2019: ABC consistency and convergence
CISEA 2019: ABC consistency and convergenceCISEA 2019: ABC consistency and convergence
CISEA 2019: ABC consistency and convergence
 

Mehr von Yun-Yan Chi

Tezos Taipei Meetup #2 - 15/06/2019
Tezos Taipei Meetup #2 - 15/06/2019Tezos Taipei Meetup #2 - 15/06/2019
Tezos Taipei Meetup #2 - 15/06/2019Yun-Yan Chi
 
Traversing on Algebraic Datatype
Traversing on Algebraic DatatypeTraversing on Algebraic Datatype
Traversing on Algebraic DatatypeYun-Yan Chi
 
for "Parallelizing Multiple Group-by Queries using MapReduce"
for "Parallelizing Multiple Group-by Queries using MapReduce"for "Parallelizing Multiple Group-by Queries using MapReduce"
for "Parallelizing Multiple Group-by Queries using MapReduce"Yun-Yan Chi
 
Program Language - Fall 2013
Program Language - Fall 2013 Program Language - Fall 2013
Program Language - Fall 2013 Yun-Yan Chi
 
Machine X Language
Machine X LanguageMachine X Language
Machine X LanguageYun-Yan Chi
 
Examples for loopless
Examples for looplessExamples for loopless
Examples for looplessYun-Yan Chi
 
Data type a la carte
Data type a la carteData type a la carte
Data type a la carteYun-Yan Chi
 
Genetic programming
Genetic programmingGenetic programming
Genetic programmingYun-Yan Chi
 
Paper presentation: The relative distance of key point based iris recognition
Paper presentation: The relative distance of key point based iris recognitionPaper presentation: The relative distance of key point based iris recognition
Paper presentation: The relative distance of key point based iris recognitionYun-Yan Chi
 
Deriving a compiler and interpreter for a Multi-level
Deriving a compiler and interpreter for a Multi-level Deriving a compiler and interpreter for a Multi-level
Deriving a compiler and interpreter for a Multi-level Yun-Yan Chi
 
Number System in Haskell
Number System in Haskell Number System in Haskell
Number System in Haskell Yun-Yan Chi
 

Mehr von Yun-Yan Chi (13)

Tezos Taipei Meetup #2 - 15/06/2019
Tezos Taipei Meetup #2 - 15/06/2019Tezos Taipei Meetup #2 - 15/06/2019
Tezos Taipei Meetup #2 - 15/06/2019
 
Traversing on Algebraic Datatype
Traversing on Algebraic DatatypeTraversing on Algebraic Datatype
Traversing on Algebraic Datatype
 
for "Parallelizing Multiple Group-by Queries using MapReduce"
for "Parallelizing Multiple Group-by Queries using MapReduce"for "Parallelizing Multiple Group-by Queries using MapReduce"
for "Parallelizing Multiple Group-by Queries using MapReduce"
 
Program Language - Fall 2013
Program Language - Fall 2013 Program Language - Fall 2013
Program Language - Fall 2013
 
Machine X Language
Machine X LanguageMachine X Language
Machine X Language
 
Examples for loopless
Examples for looplessExamples for loopless
Examples for loopless
 
Insert 2 Merge
Insert 2 MergeInsert 2 Merge
Insert 2 Merge
 
Any tutor
Any tutorAny tutor
Any tutor
 
Data type a la carte
Data type a la carteData type a la carte
Data type a la carte
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
 
Paper presentation: The relative distance of key point based iris recognition
Paper presentation: The relative distance of key point based iris recognitionPaper presentation: The relative distance of key point based iris recognition
Paper presentation: The relative distance of key point based iris recognition
 
Deriving a compiler and interpreter for a Multi-level
Deriving a compiler and interpreter for a Multi-level Deriving a compiler and interpreter for a Multi-level
Deriving a compiler and interpreter for a Multi-level
 
Number System in Haskell
Number System in Haskell Number System in Haskell
Number System in Haskell
 

Kürzlich hochgeladen

( Sports training) All topic (MCQs).pptx
( Sports training) All topic (MCQs).pptx( Sports training) All topic (MCQs).pptx
( Sports training) All topic (MCQs).pptxParshotamGupta1
 
Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...
Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...
Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...gurkirankumar98700
 
Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...
Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...
Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...Eticketing.co
 
08448380779 Call Girls In Karol Bagh Women Seeking Men
08448380779 Call Girls In Karol Bagh Women Seeking Men08448380779 Call Girls In Karol Bagh Women Seeking Men
08448380779 Call Girls In Karol Bagh Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In IIT Women Seeking Men
08448380779 Call Girls In IIT Women Seeking Men08448380779 Call Girls In IIT Women Seeking Men
08448380779 Call Girls In IIT Women Seeking MenDelhi Call girls
 
Who Is Emmanuel Katto Uganda? His Career, personal life etc.
Who Is Emmanuel Katto Uganda? His Career, personal life etc.Who Is Emmanuel Katto Uganda? His Career, personal life etc.
Who Is Emmanuel Katto Uganda? His Career, personal life etc.Marina Costa
 
Plan d'orientations stratégiques rugby féminin
Plan d'orientations stratégiques rugby fémininPlan d'orientations stratégiques rugby féminin
Plan d'orientations stratégiques rugby fémininThibaut TATRY
 
Tableaux 9ème étape circuit fédéral 2024
Tableaux 9ème étape circuit fédéral 2024Tableaux 9ème étape circuit fédéral 2024
Tableaux 9ème étape circuit fédéral 2024HechemLaameri
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service 🦺
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service  🦺CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service  🦺
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service 🦺anilsa9823
 
VIP Kolkata Call Girl Liluah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Liluah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Liluah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Liluah 👉 8250192130 Available With Roomdivyansh0kumar0
 
JORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdf
JORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdfJORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdf
JORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdfArturo Pacheco Alvarez
 
CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service 🧣
CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service  🧣CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service  🧣
CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service 🧣anilsa9823
 
08448380779 Call Girls In Lajpat Nagar Women Seeking Men
08448380779 Call Girls In Lajpat Nagar Women Seeking Men08448380779 Call Girls In Lajpat Nagar Women Seeking Men
08448380779 Call Girls In Lajpat Nagar Women Seeking MenDelhi Call girls
 
Chennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...
Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...
Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...Eticketing.co
 
🔝|97111༒99012🔝 Call Girls In {Delhi} Cr Park ₹5.5k Cash Payment With Room De...
🔝|97111༒99012🔝 Call Girls In  {Delhi} Cr Park ₹5.5k Cash Payment With Room De...🔝|97111༒99012🔝 Call Girls In  {Delhi} Cr Park ₹5.5k Cash Payment With Room De...
🔝|97111༒99012🔝 Call Girls In {Delhi} Cr Park ₹5.5k Cash Payment With Room De...Diya Sharma
 

Kürzlich hochgeladen (20)

Call Girls 🫤 Malviya Nagar ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
Call Girls 🫤 Malviya Nagar ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOYCall Girls 🫤 Malviya Nagar ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOY
Call Girls 🫤 Malviya Nagar ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
 
( Sports training) All topic (MCQs).pptx
( Sports training) All topic (MCQs).pptx( Sports training) All topic (MCQs).pptx
( Sports training) All topic (MCQs).pptx
 
Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...
Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...
Jankipuram / Call Girls Lucknow | Whatsapp No 🫗 8923113531 🎳 VIP Escorts Serv...
 
Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...
Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...
Croatia vs Italy Euro Cup 2024 Three pitfalls for Spalletti’s Italy in Group ...
 
08448380779 Call Girls In Karol Bagh Women Seeking Men
08448380779 Call Girls In Karol Bagh Women Seeking Men08448380779 Call Girls In Karol Bagh Women Seeking Men
08448380779 Call Girls In Karol Bagh Women Seeking Men
 
Call Girls In RK Puram 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In RK Puram 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICECall Girls In RK Puram 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
Call Girls In RK Puram 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SERVICE
 
Call Girls Service Noida Extension @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
Call Girls Service Noida Extension @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...Call Girls Service Noida Extension @9999965857 Delhi 🫦 No Advance  VVIP 🍎 SER...
Call Girls Service Noida Extension @9999965857 Delhi 🫦 No Advance VVIP 🍎 SER...
 
08448380779 Call Girls In IIT Women Seeking Men
08448380779 Call Girls In IIT Women Seeking Men08448380779 Call Girls In IIT Women Seeking Men
08448380779 Call Girls In IIT Women Seeking Men
 
Who Is Emmanuel Katto Uganda? His Career, personal life etc.
Who Is Emmanuel Katto Uganda? His Career, personal life etc.Who Is Emmanuel Katto Uganda? His Career, personal life etc.
Who Is Emmanuel Katto Uganda? His Career, personal life etc.
 
Call Girls 🫤 Paharganj ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
Call Girls 🫤 Paharganj ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOYCall Girls 🫤 Paharganj ➡️ 9999965857  ➡️ Delhi 🫦  Russian Escorts FULL ENJOY
Call Girls 🫤 Paharganj ➡️ 9999965857 ➡️ Delhi 🫦 Russian Escorts FULL ENJOY
 
Plan d'orientations stratégiques rugby féminin
Plan d'orientations stratégiques rugby fémininPlan d'orientations stratégiques rugby féminin
Plan d'orientations stratégiques rugby féminin
 
Tableaux 9ème étape circuit fédéral 2024
Tableaux 9ème étape circuit fédéral 2024Tableaux 9ème étape circuit fédéral 2024
Tableaux 9ème étape circuit fédéral 2024
 
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service 🦺
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service  🦺CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service  🦺
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best Female service 🦺
 
VIP Kolkata Call Girl Liluah 👉 8250192130 Available With Room
VIP Kolkata Call Girl Liluah 👉 8250192130  Available With RoomVIP Kolkata Call Girl Liluah 👉 8250192130  Available With Room
VIP Kolkata Call Girl Liluah 👉 8250192130 Available With Room
 
JORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdf
JORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdfJORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdf
JORNADA 4 LIGA MURO 2024TUXTEPEC1234.pdf
 
CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service 🧣
CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service  🧣CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service  🧣
CALL ON ➥8923113531 🔝Call Girls Telibagh Lucknow best Night Fun service 🧣
 
08448380779 Call Girls In Lajpat Nagar Women Seeking Men
08448380779 Call Girls In Lajpat Nagar Women Seeking Men08448380779 Call Girls In Lajpat Nagar Women Seeking Men
08448380779 Call Girls In Lajpat Nagar Women Seeking Men
 
Chennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Anna Nagar Phone 🍆 8250192130 👅 celebrity escorts service
 
Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...
Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...
Croatia vs Albania Clash of Euro Cup 2024 Squad Preparations and Euro Cup Dre...
 
🔝|97111༒99012🔝 Call Girls In {Delhi} Cr Park ₹5.5k Cash Payment With Room De...
🔝|97111༒99012🔝 Call Girls In  {Delhi} Cr Park ₹5.5k Cash Payment With Room De...🔝|97111༒99012🔝 Call Girls In  {Delhi} Cr Park ₹5.5k Cash Payment With Room De...
🔝|97111༒99012🔝 Call Girls In {Delhi} Cr Park ₹5.5k Cash Payment With Room De...
 

Constructing List Homomorphisms from Proofs

  • 1. Constructing List Homomorphisms from Proofs Yun-Yan Chi Shin-Cheng Mu IIS, Academia Sinica, Taiwan September 17, 2012 Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 1/ 25
  • 2. Prelude Preliminaries The Way To Go List Homomorphism ▸ A function h on lists is called a list homomorphism if it satisfies h (xs + ys) = h xs h ys, + for some associative operator ( ) ▸ E.g. sum (xs + ys) = sum xs + sum ys + Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 2/ 25
  • 3. Prelude Preliminaries The Way To Go List Homomorphism ▸ A function h on lists is called a list homomorphism if it satisfies h (xs + ys) = h xs h ys, + for some associative operator ( ) ▸ E.g. sum (xs + ys) = sum xs + sum ys + ▸ Potential chances of parallelisation ▸ compute h xs and h ys in parallel ▸ combine the results using ( ) ▸ Can a list homomorphism be mechanically constructed? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 2/ 25
  • 4. Prelude Preliminaries The Way To Go A clue ▸ The well-known third list-homomorphism theorem: ▸ h is a list homomorphism ▸ if h can be foldr (⊲) e and foldl(⊳) e for some (⊲), (⊳) and e ▸ E.g. sum ([3, 5, 7, 9]) = 3 + sum [5, 7, 9] = sum [3, 5, 7] + 9 = sum [3, 5] + sum [7, 9] Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 3/ 25
  • 5. Prelude Preliminaries The Way To Go But, how? ▸ Plenty of previous work was devoted to the construction of ( ) from the definitions of (⊲) and (⊳) ▸ Practically, efforts are needed to prove h = foldr (⊲) e = foldl (⊳) e ▸ This occurs often that one of (⊲) or (⊳) is picked as definition of h, while the other is much harder to find Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 4/ 25
  • 6. Prelude Preliminaries The Way To Go But, how? ▸ We may have a good guess of ( ) by mixing (⊲) and (⊳) ▸ The proof of the correctness of ( ) is very similar to the proof of h = foldr (⊲) e = foldl (⊳) e, which we have to provide anyway ▸ Our idea: transform the proof of the correctness of ( ) from the proof of foldr = foldl, after assembling a possible ( ) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 4/ 25
  • 7. Prelude Fold Preliminaries Tupling The Way To Go Foldr-Fusion Law Prelude Preliminaries Fold Tupling Foldr-Fusion Law The Way To Go Proof by Fusion Proof Generalisation Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 5/ 25
  • 8. Prelude Fold Preliminaries Tupling The Way To Go Foldr-Fusion Law Foldr ▸ A function h is a instance of foldr (⊲) e if h can be defined as ▸ h [] = e ▸ h (x xs) = x ⊲ h xs for some e and (⊲) ▸ E.g. foldr (⊲) e xs = foldr (⊲) e (x1 (x2 (x3 [ ]))) = x1 ⊲ foldr (⊲) e (x2 (x3 [ ])) = ... = x1 ⊲ (x2 ⊲ (x3 ⊲ e)) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 6/ 25
  • 9. Prelude Fold Preliminaries Tupling The Way To Go Foldr-Fusion Law Foldl ▸ Symmetrically, h is a foldl(⊳) e if it can be defined as ▸ h [] = e ▸ h (xs + [x]) = h xs ⊳ x, + for some (⊳) and e ▸ E.g. foldl (⊳) e xs = foldl (⊳) e ((([ ] + [x1 ]) + [x2 ]) + [x3 ]) + + + = foldl (⊳) e (([ ] + [x1 ]) + [x2 ]) ⊳ x3 + + = ... = ((e ⊳ x1 ) ⊳ x2 ) ⊳ x3 Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 7/ 25
  • 10. Prelude Fold Preliminaries Tupling The Way To Go Foldr-Fusion Law Tupling ▸ Not all functions can be a fold ▸ Tupling: for h, find a k such that ⟨h, k⟩ is a fold ▸ ⟨h, k⟩ x = (h x, k x) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 8/ 25
  • 11. Prelude Fold Preliminaries Tupling The Way To Go Foldr-Fusion Law Foldr-Fusion Law ▸ One can fuse f and foldr into another foldr Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 9/ 25
  • 12. Prelude Fold Preliminaries Tupling The Way To Go Foldr-Fusion Law Foldr-Fusion Law ▸ One can fuse f and foldr into another foldr (f ○ foldr (⊲) e) xs = (f ○ foldr (⊲) e) (x1 (x2 (x3 ... []))) = f (x1 ⊲ (x2 ⊲ (x3 ⊲ ... ⊲ e))) = { f (x ⊲ z) = x ⊕ f z } x1 ⊕ (f (x2 ⊲ (x3 ⊲ ... ⊲ e))) = ... = x1 ⊕ (x2 ⊕ (x3 ⊕ ... ⊕ (f e))) = foldr (⊕) (f e) xs Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 9/ 25
  • 13. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go Return to our approach ▸ Since we try to transform the proof of ▸ h = foldr (⊲) e = foldl (⊳) e to the proof of ▸ the correctness of ( ), ▸ we want to know how to 1. prove that h = foldr (⊲) e = foldl (⊳) e 2. prove that ( ) do define a list homomorphism 3. transform the former to the latter Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 10/ 25
  • 14. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go h = foldr (⊲) e = foldl (⊳) e ▸ Let h = foldr (⊲) e ▸ To prove that h = foldl (⊳) e, we have to show ▸ h[] = e ▸ h (xs + [z]) = h xs ⊳ z + ▸ In point-free style: h ○ (+ +[z]) = (⊳ z) ○ h h ○ (+ +[z]) = { foldr -fusion, since (+ +[z]) = foldr ( ) [z] } foldr (⊲) (h [z]) = { foldr -fusion (backwards) } (⊳ z) ○ foldr (⊲) e = (⊳ z) ○ h Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 11/ 25
  • 15. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go h = foldr (⊲) e = foldl (⊳) e ▸ For the second foldr -fusion ▸ z ⊲e=e⊳z ▸ (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z) - the associativity of (⊲) and (⊳) ▸ We will have the proof of h = foldr (⊲) e = foldl (⊳) e if we have the proof of above fusion conditions Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 11/ 25
  • 16. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go h is list homomorphism ▸ To prove that h is a list homomorphism, we have to show ▸ h (xs + ys) = h xs + h ys ▸ In point-free style: h ○ (+ +ys) = ( h ys) ○ h h ○ (+ +ys) = { foldr -fusion, since (+ +ys) = foldr ( ) ys } foldr (⊲) (h ys) = { foldr -fusion (backwards) } ( h ys) ○ foldr (⊲) e = ( h ys) ○ h Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 12/ 25
  • 17. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go h is list homomorphism ▸ For the second foldr -fusion ▸ h ys = e h ys ▸ (x ⊲ y ) h ys = x ⊲ (y h ys) ▸ If we have the proof of those fusion conditions, we will have the proof of ( ) do define a list homomorphism Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 12/ 25
  • 18. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go Generalisation ▸ To transform the proof of ▸ h = foldr (⊲) e = foldl (⊳) e to the proof of ▸ h (xs + ys) = h xs + h ys Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 13/ 25
  • 19. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go Generalisation ▸ To transform the proof of ▸ z ⊲e=e⊳z ▸ (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z) to the proof of ▸ h ys = e h ys ▸ (x ⊲ y ) h ys = x ⊲ (y h ys) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 13/ 25
  • 20. Prelude Proof by Fusion Preliminaries Proof Generalisation The Way To Go Generalisation ▸ To transform the proof of ▸ z ⊲e=e⊳z ▸ (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z) to the proof of ▸ h ys = e h ys ▸ (x ⊲ y ) h ys = x ⊲ (y h ys) ▸ To come up with ( ) and its correctness proof ▸ Generalise the former proof to the latter by replacing the occurrences of z in (⊳) by metavariables Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 13/ 25
  • 21. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Example: Steep Setup Proving foldr (⊲) e = foldl (⊳) e Constructing ( ) Conclusions Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 14/ 25
  • 22. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ E.g. steep [20, 10, 5, 2] Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 23. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ E.g. steep [20, 10, 5, 2] Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 24. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ E.g. steep [20, 10, 5, 2] Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 25. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ E.g. steep [20, 10, 5, 2] Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 26. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ Can steep be a foldr ? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 27. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ Can steep be a foldr ? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 28. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ Can steep be a foldl ? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 29. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ Can steep be a foldl ? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 30. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ Can steep be a foldl ? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 31. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep ▸ A list of numbers is said to be steep if each number is larger than the sum of the numbers to its right. ▸ Can steep be a foldl ? Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 15/ 25
  • 32. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Cap ▸ cap xs, upper-bound of value we can attach to the right of xs ▸ cap can be a foldr together with sum Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 16/ 25
  • 33. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Cap ▸ cap xs, upper-bound of value we can attach to the right of xs ▸ cap can be a foldl Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 16/ 25
  • 34. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Steep as Fold ▸ We can compute steep if we can compute cap ▸ ⟨cap, sum⟩ can be foldr (⊲) (∞, 0) and foldl (⊳) (∞, 0), where ▸ x ⊲ (c2 , s2 ) = ((x − s2 ) ↓ c2 , x + s2 ) ▸ (c1 , s1 ) ⊳ z = ((c1 − z) ↓ z, s1 + z) ▸ It is not so obvious that foldr = foldl Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 17/ 25
  • 35. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Example: Steep Setup Proving foldr (⊲) e = foldl (⊳) e Constructing ( ) Conclusions Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 18/ 25
  • 36. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Fusion Conditions ▸ z ⊲ (∞, 0) = (∞, 0) ⊳ z ▸ (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z) ▸ The former condition trivially holds: z ⊲ (∞, 0) = { definition of (⊲) } ((z − 0) ↓ ∞, z + 0) = { arithmetics } ((∞ − z) ↓ z, 0 + z) = { definition of (⊳) } (∞, 0) ⊳ z. Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 19/ 25
  • 37. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Proof of Associativity (x ⊲ (c, s)) ⊳ z = { definition of (⊲) } ((x − s) ↓ c, x + s) ⊳ z = { definition of (⊳) } ((((x − s) ↓ c) − z) ↓ z, x + s + z) = { (−z) distributes over (↓) } (((x − s − z) ↓ (c − z)) ↓ z, x + s + z) = { arithmetics } (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z) = { definition of (⊲) } x ⊲ ((c − z) ↓ z, s + z) = { definition of (⊳) } x ⊲ ((c, s) ⊳ z) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 20/ 25
  • 38. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Example: Steep Setup Proving foldr (⊲) e = foldl (⊳) e Constructing ( ) Conclusions Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 21/ 25
  • 39. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) The Aim now is 1. Generalise the proof of ▸ (x ⊲ y ) ⊳ z = x ⊲ (y ⊳ z) to a proof of ▸ (x ⊲ y ) (c2 , s2 ) = x ⊲ (y (c2 , s2 )). 2. Construct a definition of ( ) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 22/ 25
  • 40. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ Copy the proof of associativity (x ⊲ (c, s)) ⊳ z = { definition of (⊲) } ((x − s) ↓ c, x + s) ⊳ z = { definition of (⊳) } ((((x − s) ↓ c) − z) ↓ z, x + s + z) = { -z distributes over (↓) } (((x − s − z) ↓ (c − z)) ↓ z, x + s + z) = { arithmetics } (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z) = { definition of (⊲) } x ⊲ ((c − z) ↓ z, s + z) = { definition of (⊳) } x ⊲ ((c, s) ⊳ z) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 41. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ Generalise ⊳ z to (c2 , s2 ) (x ⊲ (c, s)) ⊳ z = { definition of (⊲) } ((x − s) ↓ c, x + s) ⊳ z = { definition of (⊳) } ((((x − s) ↓ c) − z) ↓ z, x + s + z) = { -z distributes over (↓) } (((x − s − z) ↓ (c − z)) ↓ z, x + s + z) = { arithmetics } (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z) = { definition of (⊲) } x ⊲ ((c − z) ↓ z, s + z) = { definition of (⊳) } x ⊲ ((c, s) ⊳ z) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 42. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ Generalise ⊳ z to (c2 , s2 ) (x ⊲ (c, s)) (c2 , s2 ) = { definition of (⊲) } ((x − s) ↓ c, x + s) (c2 , s2 ) = { definition of ( ) } ((((x − s) ↓ c) − z) ↓ z, x + s + z) = { -z distributes over (↓) } (((x − s − z) ↓ (c − z)) ↓ z, x + s + z) = { arithmetics } (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z) = { definition of (⊲) } x ⊲ ((c − z) ↓ z, s + z) = { definition of ( ) } x ⊲ ((c, s) (c2 , s2 )) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 43. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ Replace z by metavariable Xi (x ⊲ (c, s)) (c2 , s2 ) = { definition of (⊲) } ((x − s) ↓ c, x + s) (c2 , s2 ) = { definition of ( ) } ((((x − s) ↓ c) − z) ↓ z, x + s + z) = { -z distributes over (↓) } (((x − s − z) ↓ (c − z)) ↓ z, x + s + z) = { arithmetics } (((x − (s + z)) ↓ ((c − z) ↓ z), x + s + z) = { definition of (⊲) } x ⊲ ((c − z) ↓ z, s + z) = { definition of ( ) } x ⊲ ((c, s) (c2 , s2 )) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 44. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ Replace z by metavariable Xi (x ⊲ (c, s)) (c2 , s2 ) = { definition of (⊲) } ((x − s) ↓ c, x + s) (c2 , s2 ) = { definition of ( ) } ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X3 ) = { -X1 distributes over (↓) } (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X3 ) = { arithmetics } (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X3 ) = { definition of (⊲) } x ⊲ ((c − X1 ) ↓ X2 , s + X1 ) = { definition of ( ) } x ⊲ ((c, s) (c2 , s2 )) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 45. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ (s + X1 ) and (s + X3 ) have to be the same term (x ⊲ (c, s)) (c2 , s2 ) = { definition of (⊲) } ((x − s) ↓ c, x + s) (c2 , s2 ) = { definition of ( ) } ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X3 ) = { -X1 distributes over (↓) } (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X3 ) = { arithmetics } (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X3 ) = { definition of (⊲) } x ⊲ ((c − X1 ) ↓ X2 , s + X1 ) = { definition of ( ) } x ⊲ ((c, s) (c2 , s2 )) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 46. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ (s + X1 ) and (s + X3 ) have to be the same term (x ⊲ (c, s)) (c2 , s2 ) = { definition of (⊲) } ((x − s) ↓ c, x + s) (c2 , s2 ) = { definition of ( ) } ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X1 ) = { -X1 distributes over (↓) } (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X1 ) = { arithmetics } (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X1 ) = { definition of (⊲) } x ⊲ ((c − X1 ) ↓ X2 , s + X1 ) = { definition of ( ) } x ⊲ ((c, s) (c2 , s2 )) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 47. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Generalise The Proof ▸ Proof of (x ⊲ y ) (c2 , s2 ) = x ⊲ (y (c2 , s2 )) (x ⊲ (c, s)) (c2 , s2 ) = { definition of (⊲) } ((x − s) ↓ c, x + s) (c2 , s2 ) = { definition of ( ) } ((((x − s) ↓ c) − X1 ) ↓ X2 , x + s + X1 ) = { -X1 distributes over (↓) } (((x − s − X1 ) ↓ (c − X1 )) ↓ X2 , x + s + X1 ) = { arithmetics } (((x − (s + X1 )) ↓ ((c − X1 ) ↓ X2 ), x + s + X1 ) = { definition of (⊲) } x ⊲ ((c − X1 ) ↓ X2 , s + X1 ) = { definition of ( ) } x ⊲ ((c, s) (c2 , s2 )) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 23/ 25
  • 48. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Refining The ( ) ▸ (c1 , s1 ) (c2 , s2 ) = ((c1 − X1 ) ↓ X2 , s1 + X1 ) ▸ Satisfies that (c2 , s2 ) = (∞, 0) (c2 , s2 ) (c2 , s2 ) = ((∞ − X1 ) ↓ X2 , 0 + X1 ) ≡ (c2 , s2 ) = (∞ ↓ X2 , X1 ) ≡ (c2 , s2 ) = (X2 , X1 ) Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 24/ 25
  • 49. Setup Example: Steep Proving foldr (⊲) e = foldl (⊳) e Conclusions Constructing ( ) Refining The ( ) ▸ (c1 , s1 ) (c2 , s2 ) = ((c1 − X1 ) ↓ X2 , s1 + X1 ) ▸ Satisfies that (c2 , s2 ) = (∞, 0) (c2 , s2 ) (c2 , s2 ) = ((∞ − X1 ) ↓ X2 , 0 + X1 ) ≡ (c2 , s2 ) = (∞ ↓ X2 , X1 ) ≡ (c2 , s2 ) = (X2 , X1 ) ▸ We have thus discovered that ▸ (c1 , s1 ) (c2 , s2 ) = ((c1 − s2 ) ↓ c2 , s1 + s2 ) ▸ This ( ) has got to be correct, because we have the proof already! Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 24/ 25
  • 50. Example: Steep Conclusions Conclusions ▸ We have proposed and demonstrated a novel approach to constructing ( ). ▸ Starting with a trivial generalisation of either (⊲) or (⊳), we exploit the constraint enforced by the proof of associativity to refine ( ). ▸ Once we have constructed ( ), we have its correctness proof too. Yun-Yan Chi, Shin-Cheng Mu APLAS 2011 25/ 25