ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Veri?ed Stack-based
                         Genetic Programming
                         via Dependent Types
                               by Larry Diehl




Tuesday, July 19, 2011
Motivation
                     ? avoid searching space of stack under/
                         over?owing programs
                         ? use strongly typed genetic operators
                     ? avoid logic and runtime errors due to
                         increasingly complex genetic operators
                         ? use a total and dependently typed
                           language


Tuesday, July 19, 2011
Dependent Types
                     ? Agda programming language
                     ? purely functional (like Haskell)
                     ? total (coverage/termination/positivity)
                     ? types can encode any intuitionistic logic
                         formula
                         ? e.g. proof theory judgement ¡°Even 6¡±
Tuesday, July 19, 2011
Genetic Programming

                     ? representation
                     ? genetic operators
                     ? evaluation function
                     ? initialization procedure

Tuesday, July 19, 2011
¡°Forth¡± operations

                         word   consumes   produces
                         true       0          1
                          not       1          1
                         and        2          1




Tuesday, July 19, 2011
¡°Forth¡± terms

         1¡ú1 3¡ú1 0¡ú1 7¡ú7 6¡ú4 0¡ú3
          not and  not    and true
          not and  not    and true
                  true        true




Tuesday, July 19, 2011
append (ill)
                                    1
                                   and
                                   and
                             2    ¡Ù 3
                            not
                           true
                           true
                             0


Tuesday, July 19, 2011
append (ill)
                                    2
                                   and
                             2    ¡Ù 3
                            not
                           true
                           true
                             0



Tuesday, July 19, 2011
append (well)
                                  1
                                 and     1
                           2    = 2    and
                          not           not
                         true          true
                         true          true
                           0             0



Tuesday, July 19, 2011
split
                                   1
                           1      and
                         and       2 =     2
                          not             not
                         true            true
                         true            true
                           0               0



Tuesday, July 19, 2011
split
                                    1
                                  and
                           2       not
                         and      true
                          not       1 =     1
                         true             true
                         true               0
                           0


Tuesday, July 19, 2011
Agda Crash Course



Tuesday, July 19, 2011
data Bool : Set where
                           true false : Bool

                         data ? : Set where
                           zero : ?
                           suc : ? ! ?

                         one : ?
                         one = suc zero

                         two : ?
                         two = suc one

                         three : ?
                         three = suc two

Tuesday, July 19, 2011
data List (A : Set) : Set where
                           [] : List A
                           _¡Ë_ : A ! List A ! List A

                         false¡Ë[] : List Bool
                         false¡Ë[] = false ¡Ë []

                         true¡Ëfalse¡Ë[] : List Bool
                         true¡Ëfalse¡Ë[] = true ¡Ë false¡Ë[]




Tuesday, July 19, 2011
data Vec (A : Set) : ? ! Set where
                       [] : Vec A zero
                       _¡Ë_ : {n : ?} !
                         A ! Vec A n ! Vec A (suc n)

                     false¡Ë[]1 : Vec Bool one
                     false¡Ë[]1 = false ¡Ë []

                     true¡Ëfalse¡Ë[]2 : Vec Bool two
                     true¡Ëfalse¡Ë[]2 = true ¡Ë false¡Ë[]1




Tuesday, July 19, 2011
_+_ : ? ! ? ! ?
                 zero + n = n
                 suc m + n = suc (m + n)

                 _++_ : {A : Set} {m n : ?} !
                   Vec A m ! Vec A n ! Vec A (m + n)
                 [] ++ ys = ys
                 (x ¡Ë xs) ++ ys = x ¡Ë (xs ++ ys)

                 true¡Ëfalse¡Ëtrue¡Ë[]3 : Vec Bool three
                 true¡Ëfalse¡Ëtrue¡Ë[]3 =
                   (true ¡Ë false ¡Ë []) ++ (true ¡Ë [])



Tuesday, July 19, 2011
Representation



Tuesday, July 19, 2011
data Word : Set where
                           true not and : Word

                         data List (A : Set) : Set where
                           [] : List A

                           _¡Ë_ : A ! List A ! List A

                         Term = List Word




Tuesday, July 19, 2011
bc : Term -- 2 1
                         bc = and ¡Ë []

                         ab : Term -- 0 2
                         ab = not ¡Ë true ¡Ë true ¡Ë []

                         ac : Term -- 0 1
                         ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë []




Tuesday, July 19, 2011
bc : Term 2 1
                         bc = and []

                         ab : Term 0 2
                         ab = not (true (true []))

                         ac : Term 0 1
                         ac = and (not (true (true [])))



Tuesday, July 19, 2011
data Term (inp : ?) : ? ! Set where
                   []    : Term inp inp
                   true : {out : ?} !
                      Term inp out !
                      Term inp (1 + out)
                   not : {out : ?} !
                      Term inp (1 + out) !
                      Term inp (1 + out)
                   and : {out : ?} !
                      Term inp (2 + out) !
                      Term inp (1 + out)



Tuesday, July 19, 2011
module DTGP
                      {Word : Set}
                      (pre post : Word ! ? ! ?)
                    where

                    data Term (inp : ?) : ? ! Set where
                      [] : Term inp inp

                         _¡Ë_ : ? {n} (w : Word) !
                           Term inp (pre w n) !
                           Term inp (post w n)




Tuesday, July 19, 2011
data Word : Set where
                           true not and : Word

                         pre    : Word ! ? ! ?
                         pre    true n =      n
                         pre    not   n = 1 + n
                         pre    and   n = 2 + n

                         post   : Word ! ? ! ?
                         post   true n = 1 + n
                         post   not   n = 1 + n
                         post   and   n = 1 + n

                         open import DTGP pre post


Tuesday, July 19, 2011
bc : Term 2 1
                         bc = and ¡Ë []

                         ab : Term 0 2
                         ab = not ¡Ë true ¡Ë true ¡Ë []

                         ac : Term 0 1
                         ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë []




Tuesday, July 19, 2011
Genetic Operators



Tuesday, July 19, 2011
crossover : {inp   out : ?}
                           (female male :   Term inp out)
                           (randF randM :   ?) !
                           Term inp out ¡Á   Term inp out




Tuesday, July 19, 2011
bc : Term 2 1
                         bc = and ¡Ë []

                         ab : Term 0 2
                         ab = not ¡Ë true ¡Ë true ¡Ë []

                         ac : Term 0 1
                         ac = bc ++ ab




Tuesday, July 19, 2011
_++_ : ? {inp mid out} !
                    Term mid out !
                    Term inp mid !
                    Term inp out
                  [] ++ ys = ys
                  (x ¡Ë xs) ++ ys = x ¡Ë (xs ++ ys)




Tuesday, July 19, 2011
split
                                   1
                           1      and
                         and       2 =     2
                          not             not
                         true            true
                         true            true
                           0               0



Tuesday, July 19, 2011
ac : Term 0 1
                         ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë []

                         bc++ab : Split 2 ac
                         bc++ab = bc ++' ab




Tuesday, July 19, 2011
data Split {inp out} mid :
             Term inp out ! Set where
             _++'_ :
               (xs : Term mid out)
               (ys : Term inp mid) !
               Split mid (xs ++ ys)




Tuesday, July 19, 2011
ac : Term 0 1
                         ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë []

                         bc++ab : Split 2 ac
                         bc++ab = proj? (split 1 ac)




Tuesday, July 19, 2011
ac : Term 0 1
                         ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë []

                         bc++ab : ¦² ? ¦Ë mid ! Split mid ac
                         bc++ab = split 1 ac




Tuesday, July 19, 2011
split         : ? {inp out} (n : ?)
             (xs         : Term inp out) !
             ¦² ?         ¦Ë mid ! Split mid xs
           split         zero     xs = _ , [] ++' xs
           split         (suc n) [] = _ , [] ++' []
           split         (suc n) (x ¡Ë xs) with split n xs
           split         (suc n) (x ¡Ë .(xs ++ ys))
             | _         , xs ++' ys = _ , (x ¡Ë xs) ++' ys




Tuesday, July 19, 2011
Evaluation Function



Tuesday, July 19, 2011
bc : Term 2 1
             bc = and ¡Ë []

             eval-bc : Vec Bool 1
             eval-bc = eval bc (true ¡Ë false ¡Ë [])

             ac : Term 0 1
             ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë []

             eval-ac : Vec Bool 1
             eval-ac = eval ac []




Tuesday, July 19, 2011
eval : {inp out : ?} ! Term inp out !
                   Vec Bool inp ! Vec Bool out
                 eval [] is = is
                 eval (true ¡Ë xs) is = true ¡Ë eval xs is
                 eval (not ¡Ë xs) is with eval xs is
                 ... |        o ¡Ë os = ? o ¡Ë os
                 eval (and ¡Ë xs) is with eval xs is
                 ... | o? ¡Ë o? ¡Ë os = (o? ¡Ä o?) ¡Ë os




Tuesday, July 19, 2011
score   : Term 0 1 !   ?
                         score   xs with eval   xs []
                         ... |   true ¡Ë [] =    0
                         ... |   false ¡Ë [] =   1

                         open Evolution score




Tuesday, July 19, 2011
Initialization Procedure



Tuesday, July 19, 2011
choices : List Word
                         choices = true ¡Ë not ¡Ë and ¡Ë []

                         population : List (Term 0 1)
                         population = init 2 0 1 choices
                           -- (and ¡Ë true ¡Ë true ¡Ë []) ¡Ë
                           -- (not ¡Ë not ¡Ë true ¡Ë []) ¡Ë
                           -- (not ¡Ë true ¡Ë []) ¡Ë
                           -- (true ¡Ë []) ¡Ë
                           -- []




Tuesday, July 19, 2011
-- data Term (inp : ?) : ? ! Set where
  --   _¡Ë_ : ? {n} (w : Word) !
  --     Term inp (pre w n) !
  --     Term inp (post w n)
  -- pre : Word ! ? ! ?
  -- pre and n = 2 + n

  true¡Ëtrue : Term 0 2
  true¡Ëtrue = true ¡Ë true ¡Ë []

  and¡Ëand¡Ëtrue : Term 0 1
  and¡Ëand¡Ëtrue = _¡Ë_ {n = 0} and true¡Ëtrue



Tuesday, July 19, 2011
match : (w : Word) (out : ?) !
          Dec (¦² ? ¦Ë n ! out ¡Ô pre w n)
        match true n = yes (n , refl)
        match not zero = no ?p where
          ?p : ¦² ? (¦Ë n ! 0 ¡Ô suc n) ! ¡Í
          ?p (_ , ())
        match not (suc n) = yes (n , refl)




Tuesday, July 19, 2011
match and zero = no ?p where
              ?p : ¦² ? (¦Ë n ! 0 ¡Ô suc (suc n)) ! ¡Í
              ?p (_ , ())
            match and (suc zero) = no ?p where
              ?p : ¦² ? (¦Ë n ! 1 ¡Ô suc (suc n)) ! ¡Í
              ?p (_ , ())
            match and (suc (suc n)) = yes (n , refl)

            open Initialization match




Tuesday, July 19, 2011
Generalization



Tuesday, July 19, 2011
module DTGP
   {Domain Word : Set}
   (pre post : Word ! Domain ! Domain)
   (_?_ : (x y : Domain) ! Dec (x ¡Ô y))
 where

 data Term (inp : Domain) : Domain ! Set where
   [] : Term inp inp

         _¡Ë_ : ? {d} (w : Word) !
           Term inp (pre w d) !
           Term inp (post w d)



Tuesday, July 19, 2011
data Word : Set where
                       not gt : Word
                       num : ? ! Word

                     record Domain : Set where
                       constructor _,_
                       field
                         bools : ?
                         nats : ?

                     postulate _?_ :
                       (x y : Domain) ! Dec (x ¡Ô y)

Tuesday, July 19, 2011
pre     : Word ! Domain    ! Domain
                 pre     not     (m , n)    = 1 + m ,     n
                 pre     (num _) (m , n)    =     m ,     n
                 pre     gt      (m , n)    =     m , 2 + n

                 post     : Word ! Domain    ! Domain
                 post     not     (m , n)    = 1 + m ,     n
                 post     (num _) (m , n)    =     m , 1 + n
                 post     gt      (m , n)    = 1 + m ,     n

                 open DTGP pre post _?_




Tuesday, July 19, 2011
bc : Term (0 , 2) (1 , 0)
                         bc = not ¡Ë gt ¡Ë []

                         ab : Term (0 , 0) (0 , 2)
                         ab = num 3 ¡Ë num 5 ¡Ë []

                         ac : Term (0 , 0) (1 , 0)
                         ac = bc ++ ab




Tuesday, July 19, 2011
FIN
                 github.com/larrytheliquid/dtgp/tree/aaip11
                            questions?


Tuesday, July 19, 2011

More Related Content

Viewers also liked (7)

PPT
Reading writing purposes
ambrelee
?
PPTX
10 Best Practices For Successful Statement of Purpose Writing
Successful Statement of Purpose
?
PPT
Writing For A Purpose
amandanicolle06
?
PPSX
Authors purpose powerpoint - edmodo copy with audio
Robin Le Roy-Kyle
?
PPT
Purpose And Audience Powerpoint
Bryan Station High School, Lexington, KY
?
PPTX
Author's purpose
gracie0412
?
PPTX
Author¡¯s Purpose
Barbara Yardley
?
Reading writing purposes
ambrelee
?
10 Best Practices For Successful Statement of Purpose Writing
Successful Statement of Purpose
?
Writing For A Purpose
amandanicolle06
?
Authors purpose powerpoint - edmodo copy with audio
Robin Le Roy-Kyle
?
Purpose And Audience Powerpoint
Bryan Station High School, Lexington, KY
?
Author's purpose
gracie0412
?
Author¡¯s Purpose
Barbara Yardley
?

Recently uploaded (20)

PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
?
PDF
Open Source Milvus Vector Database v 2.6
Zilliz
?
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
?
PDF
Python Conference Singapore - 19 Jun 2025
ninefyi
?
PDF
¡°Scaling i.MX Applications Processors¡¯ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
?
PDF
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
?
PDF
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
?
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
?
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
?
PDF
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
?
PDF
My Journey from CAD to BIM: A True Underdog Story
Safe Software
?
PDF
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
?
PDF
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
?
PDF
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
?
PPSX
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
?
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
?
PDF
Kubernetes - Architecture & Components.pdf
geethak285
?
PPTX
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
?
PDF
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
?
PDF
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
?
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
?
Open Source Milvus Vector Database v 2.6
Zilliz
?
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
?
Python Conference Singapore - 19 Jun 2025
ninefyi
?
¡°Scaling i.MX Applications Processors¡¯ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
?
EIS-Webinar-Engineering-Retail-Infrastructure-06-16-2025.pdf
Earley Information Science
?
Redefining Work in the Age of AI - What to expect? How to prepare? Why it mat...
Malinda Kapuruge
?
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
?
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
?
Java 25 and Beyond - A Roadmap of Innovations
Ana-Maria Mihalceanu
?
My Journey from CAD to BIM: A True Underdog Story
Safe Software
?
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
?
Enhancing Environmental Monitoring with Real-Time Data Integration: Leveragin...
Safe Software
?
Optimizing the trajectory of a wheel loader working in short loading cycles
Reno Filla
?
Usergroup - OutSystems Architecture.ppsx
Kurt Vandevelde
?
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
?
Kubernetes - Architecture & Components.pdf
geethak285
?
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
?
5 Things to Consider When Deploying AI in Your Enterprise
Safe Software
?
Database Benchmarking for Performance Masterclass: Session 2 - Data Modeling ...
ScyllaDB
?
Ad

DTGP AAIP11

  • 1. Veri?ed Stack-based Genetic Programming via Dependent Types by Larry Diehl Tuesday, July 19, 2011
  • 2. Motivation ? avoid searching space of stack under/ over?owing programs ? use strongly typed genetic operators ? avoid logic and runtime errors due to increasingly complex genetic operators ? use a total and dependently typed language Tuesday, July 19, 2011
  • 3. Dependent Types ? Agda programming language ? purely functional (like Haskell) ? total (coverage/termination/positivity) ? types can encode any intuitionistic logic formula ? e.g. proof theory judgement ¡°Even 6¡± Tuesday, July 19, 2011
  • 4. Genetic Programming ? representation ? genetic operators ? evaluation function ? initialization procedure Tuesday, July 19, 2011
  • 5. ¡°Forth¡± operations word consumes produces true 0 1 not 1 1 and 2 1 Tuesday, July 19, 2011
  • 6. ¡°Forth¡± terms 1¡ú1 3¡ú1 0¡ú1 7¡ú7 6¡ú4 0¡ú3 not and not and true not and not and true true true Tuesday, July 19, 2011
  • 7. append (ill) 1 and and 2 ¡Ù 3 not true true 0 Tuesday, July 19, 2011
  • 8. append (ill) 2 and 2 ¡Ù 3 not true true 0 Tuesday, July 19, 2011
  • 9. append (well) 1 and 1 2 = 2 and not not true true true true 0 0 Tuesday, July 19, 2011
  • 10. split 1 1 and and 2 = 2 not not true true true true 0 0 Tuesday, July 19, 2011
  • 11. split 1 and 2 not and true not 1 = 1 true true true 0 0 Tuesday, July 19, 2011
  • 12. Agda Crash Course Tuesday, July 19, 2011
  • 13. data Bool : Set where true false : Bool data ? : Set where zero : ? suc : ? ! ? one : ? one = suc zero two : ? two = suc one three : ? three = suc two Tuesday, July 19, 2011
  • 14. data List (A : Set) : Set where [] : List A _¡Ë_ : A ! List A ! List A false¡Ë[] : List Bool false¡Ë[] = false ¡Ë [] true¡Ëfalse¡Ë[] : List Bool true¡Ëfalse¡Ë[] = true ¡Ë false¡Ë[] Tuesday, July 19, 2011
  • 15. data Vec (A : Set) : ? ! Set where [] : Vec A zero _¡Ë_ : {n : ?} ! A ! Vec A n ! Vec A (suc n) false¡Ë[]1 : Vec Bool one false¡Ë[]1 = false ¡Ë [] true¡Ëfalse¡Ë[]2 : Vec Bool two true¡Ëfalse¡Ë[]2 = true ¡Ë false¡Ë[]1 Tuesday, July 19, 2011
  • 16. _+_ : ? ! ? ! ? zero + n = n suc m + n = suc (m + n) _++_ : {A : Set} {m n : ?} ! Vec A m ! Vec A n ! Vec A (m + n) [] ++ ys = ys (x ¡Ë xs) ++ ys = x ¡Ë (xs ++ ys) true¡Ëfalse¡Ëtrue¡Ë[]3 : Vec Bool three true¡Ëfalse¡Ëtrue¡Ë[]3 = (true ¡Ë false ¡Ë []) ++ (true ¡Ë []) Tuesday, July 19, 2011
  • 18. data Word : Set where true not and : Word data List (A : Set) : Set where [] : List A _¡Ë_ : A ! List A ! List A Term = List Word Tuesday, July 19, 2011
  • 19. bc : Term -- 2 1 bc = and ¡Ë [] ab : Term -- 0 2 ab = not ¡Ë true ¡Ë true ¡Ë [] ac : Term -- 0 1 ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë [] Tuesday, July 19, 2011
  • 20. bc : Term 2 1 bc = and [] ab : Term 0 2 ab = not (true (true [])) ac : Term 0 1 ac = and (not (true (true []))) Tuesday, July 19, 2011
  • 21. data Term (inp : ?) : ? ! Set where [] : Term inp inp true : {out : ?} ! Term inp out ! Term inp (1 + out) not : {out : ?} ! Term inp (1 + out) ! Term inp (1 + out) and : {out : ?} ! Term inp (2 + out) ! Term inp (1 + out) Tuesday, July 19, 2011
  • 22. module DTGP {Word : Set} (pre post : Word ! ? ! ?) where data Term (inp : ?) : ? ! Set where [] : Term inp inp _¡Ë_ : ? {n} (w : Word) ! Term inp (pre w n) ! Term inp (post w n) Tuesday, July 19, 2011
  • 23. data Word : Set where true not and : Word pre : Word ! ? ! ? pre true n = n pre not n = 1 + n pre and n = 2 + n post : Word ! ? ! ? post true n = 1 + n post not n = 1 + n post and n = 1 + n open import DTGP pre post Tuesday, July 19, 2011
  • 24. bc : Term 2 1 bc = and ¡Ë [] ab : Term 0 2 ab = not ¡Ë true ¡Ë true ¡Ë [] ac : Term 0 1 ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë [] Tuesday, July 19, 2011
  • 26. crossover : {inp out : ?} (female male : Term inp out) (randF randM : ?) ! Term inp out ¡Á Term inp out Tuesday, July 19, 2011
  • 27. bc : Term 2 1 bc = and ¡Ë [] ab : Term 0 2 ab = not ¡Ë true ¡Ë true ¡Ë [] ac : Term 0 1 ac = bc ++ ab Tuesday, July 19, 2011
  • 28. _++_ : ? {inp mid out} ! Term mid out ! Term inp mid ! Term inp out [] ++ ys = ys (x ¡Ë xs) ++ ys = x ¡Ë (xs ++ ys) Tuesday, July 19, 2011
  • 29. split 1 1 and and 2 = 2 not not true true true true 0 0 Tuesday, July 19, 2011
  • 30. ac : Term 0 1 ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë [] bc++ab : Split 2 ac bc++ab = bc ++' ab Tuesday, July 19, 2011
  • 31. data Split {inp out} mid : Term inp out ! Set where _++'_ : (xs : Term mid out) (ys : Term inp mid) ! Split mid (xs ++ ys) Tuesday, July 19, 2011
  • 32. ac : Term 0 1 ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë [] bc++ab : Split 2 ac bc++ab = proj? (split 1 ac) Tuesday, July 19, 2011
  • 33. ac : Term 0 1 ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë [] bc++ab : ¦² ? ¦Ë mid ! Split mid ac bc++ab = split 1 ac Tuesday, July 19, 2011
  • 34. split : ? {inp out} (n : ?) (xs : Term inp out) ! ¦² ? ¦Ë mid ! Split mid xs split zero xs = _ , [] ++' xs split (suc n) [] = _ , [] ++' [] split (suc n) (x ¡Ë xs) with split n xs split (suc n) (x ¡Ë .(xs ++ ys)) | _ , xs ++' ys = _ , (x ¡Ë xs) ++' ys Tuesday, July 19, 2011
  • 36. bc : Term 2 1 bc = and ¡Ë [] eval-bc : Vec Bool 1 eval-bc = eval bc (true ¡Ë false ¡Ë []) ac : Term 0 1 ac = and ¡Ë not ¡Ë true ¡Ë true ¡Ë [] eval-ac : Vec Bool 1 eval-ac = eval ac [] Tuesday, July 19, 2011
  • 37. eval : {inp out : ?} ! Term inp out ! Vec Bool inp ! Vec Bool out eval [] is = is eval (true ¡Ë xs) is = true ¡Ë eval xs is eval (not ¡Ë xs) is with eval xs is ... | o ¡Ë os = ? o ¡Ë os eval (and ¡Ë xs) is with eval xs is ... | o? ¡Ë o? ¡Ë os = (o? ¡Ä o?) ¡Ë os Tuesday, July 19, 2011
  • 38. score : Term 0 1 ! ? score xs with eval xs [] ... | true ¡Ë [] = 0 ... | false ¡Ë [] = 1 open Evolution score Tuesday, July 19, 2011
  • 40. choices : List Word choices = true ¡Ë not ¡Ë and ¡Ë [] population : List (Term 0 1) population = init 2 0 1 choices -- (and ¡Ë true ¡Ë true ¡Ë []) ¡Ë -- (not ¡Ë not ¡Ë true ¡Ë []) ¡Ë -- (not ¡Ë true ¡Ë []) ¡Ë -- (true ¡Ë []) ¡Ë -- [] Tuesday, July 19, 2011
  • 41. -- data Term (inp : ?) : ? ! Set where -- _¡Ë_ : ? {n} (w : Word) ! -- Term inp (pre w n) ! -- Term inp (post w n) -- pre : Word ! ? ! ? -- pre and n = 2 + n true¡Ëtrue : Term 0 2 true¡Ëtrue = true ¡Ë true ¡Ë [] and¡Ëand¡Ëtrue : Term 0 1 and¡Ëand¡Ëtrue = _¡Ë_ {n = 0} and true¡Ëtrue Tuesday, July 19, 2011
  • 42. match : (w : Word) (out : ?) ! Dec (¦² ? ¦Ë n ! out ¡Ô pre w n) match true n = yes (n , refl) match not zero = no ?p where ?p : ¦² ? (¦Ë n ! 0 ¡Ô suc n) ! ¡Í ?p (_ , ()) match not (suc n) = yes (n , refl) Tuesday, July 19, 2011
  • 43. match and zero = no ?p where ?p : ¦² ? (¦Ë n ! 0 ¡Ô suc (suc n)) ! ¡Í ?p (_ , ()) match and (suc zero) = no ?p where ?p : ¦² ? (¦Ë n ! 1 ¡Ô suc (suc n)) ! ¡Í ?p (_ , ()) match and (suc (suc n)) = yes (n , refl) open Initialization match Tuesday, July 19, 2011
  • 45. module DTGP {Domain Word : Set} (pre post : Word ! Domain ! Domain) (_?_ : (x y : Domain) ! Dec (x ¡Ô y)) where data Term (inp : Domain) : Domain ! Set where [] : Term inp inp _¡Ë_ : ? {d} (w : Word) ! Term inp (pre w d) ! Term inp (post w d) Tuesday, July 19, 2011
  • 46. data Word : Set where not gt : Word num : ? ! Word record Domain : Set where constructor _,_ field bools : ? nats : ? postulate _?_ : (x y : Domain) ! Dec (x ¡Ô y) Tuesday, July 19, 2011
  • 47. pre : Word ! Domain ! Domain pre not (m , n) = 1 + m , n pre (num _) (m , n) = m , n pre gt (m , n) = m , 2 + n post : Word ! Domain ! Domain post not (m , n) = 1 + m , n post (num _) (m , n) = m , 1 + n post gt (m , n) = 1 + m , n open DTGP pre post _?_ Tuesday, July 19, 2011
  • 48. bc : Term (0 , 2) (1 , 0) bc = not ¡Ë gt ¡Ë [] ab : Term (0 , 0) (0 , 2) ab = num 3 ¡Ë num 5 ¡Ë [] ac : Term (0 , 0) (1 , 0) ac = bc ++ ab Tuesday, July 19, 2011
  • 49. FIN github.com/larrytheliquid/dtgp/tree/aaip11 questions? Tuesday, July 19, 2011