SlideShare a Scribd company logo
Verified Stack-based
                         Genetic Programming
                         via Dependent Types
                               by Larry Diehl




Tuesday, July 19, 2011
Motivation
                     • avoid searching space of stack under/
                         overflowing 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

Reading writing purposes
Reading writing purposesReading writing purposes
Reading writing purposes
ambrelee
 
10 Best Practices For Successful Statement of Purpose Writing
10 Best Practices For Successful Statement of Purpose Writing10 Best Practices For Successful Statement of Purpose Writing
10 Best Practices For Successful Statement of Purpose Writing
Successful Statement of Purpose
 
Authors purpose powerpoint - edmodo copy with audio
Authors purpose powerpoint - edmodo copy with audioAuthors purpose powerpoint - edmodo copy with audio
Authors purpose powerpoint - edmodo copy with audioRobin Le Roy-Kyle
 
Author's purpose
Author's purposeAuthor's purpose
Author's purpose
gracie0412
 
Author’s Purpose
Author’s PurposeAuthor’s Purpose
Author’s Purpose
Barbara Yardley
 

Viewers also liked (7)

Reading writing purposes
Reading writing purposesReading writing purposes
Reading writing purposes
 
10 Best Practices For Successful Statement of Purpose Writing
10 Best Practices For Successful Statement of Purpose Writing10 Best Practices For Successful Statement of Purpose Writing
10 Best Practices For Successful Statement of Purpose Writing
 
Writing For A Purpose
Writing For A PurposeWriting For A Purpose
Writing For A Purpose
 
Authors purpose powerpoint - edmodo copy with audio
Authors purpose powerpoint - edmodo copy with audioAuthors purpose powerpoint - edmodo copy with audio
Authors purpose powerpoint - edmodo copy with audio
 
Purpose And Audience Powerpoint
Purpose And Audience PowerpointPurpose And Audience Powerpoint
Purpose And Audience Powerpoint
 
Author's purpose
Author's purposeAuthor's purpose
Author's purpose
 
Author’s Purpose
Author’s PurposeAuthor’s Purpose
Author’s Purpose
 

Recently uploaded

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 

Recently uploaded (20)

Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 

DTGP AAIP11

  • 1. Verified Stack-based Genetic Programming via Dependent Types by Larry Diehl Tuesday, July 19, 2011
  • 2. Motivation • avoid searching space of stack under/ overflowing 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