SlideShare una empresa de Scribd logo
1 de 105
9p p 2   Pontificating
Programming is Hard
Who watches the watchers?
Let’s talk about
  verification
XUnit
Standard Practice

• We all use it
• Most of us rely on it day to day
• We seem to trust it implicitly
def test_example
  # create something to test
  obj = MyExampleObject.new(arguments)
  # program statement
  result = obj.example_method(arguments)
  # verification
  assert_equal("fact", result)
  #implicit teardown
end


it "must be an example" do
  obj = MyExampleObject.new(arguments)
  result = obj.example_method(arguments)
  result.should == fact
end
XUnit is Complected

• It’s doing too much
XUnit is Complected

• It’s doing too much
• BDD is just XUnit with lots of bad English
XUnit is Complected

• It’s doing too much
• BDD is just XUnit with lots of bad English
• Poor separation of the tester and testee
XUnit is Complected

• It’s doing too much
• BDD is just XUnit with lots of bad English
• Poor separation of the tester and testee
• What are you testing?
XUnit is Complected

• It’s doing too much
• BDD is just XUnit with lots of bad English
• Poor separation of the tester and testee
• What are you testing?
 • Are you sure?!
Your mock object is a joke; that object is mocking you.
          For needing it. – Rich Hickey
Coverage is a Lie

• Too many false indicators of comprehensive
  verification
• We work really hard at the wrong things to
  achieve good coverage
• “The Emperor's new suit”
Always in Manual Drive

• Devise, write, and maintain all cases
• Edge cases are a (big) problem
 • Especially with simple functions
• Example: Integer commutative law
Generative Testing
Logic #fail


 9x f (x) 6= expect(x) ) bugs
9x f (x) = expect(x) ) ¬bugs
Logic #fail


 9x f (x) 6= expect(x) ) bugs
9x f (x) = expect(x) ) ¬bugs
Logic #fail


 9x f (x) 6= expect(x) ) bugs
9x f (x) = expect(x) ) ¬bugs
Generative Testing
• Developing test cases is hard
• We have computers!
• Define your domain, auto-generate inputs
• Write less, test more
• Find edge cases automatically!
Generative Testing
• Developing test cases is hard
• We have computers!
• Define your domain, auto-generate inputs
• Write less, test more
• Find edge cases automatically!
 • (money back guarantee)
(defspec integer-commutative-laws
  (partial map identity)
  [^{:tag `integer} a ^{:tag `integer} b]
  (if (longable? (+' a b))
    (assert (= (+ a b) (+ b a)
               (+' a b) (+' b a)
               (unchecked-add a b)
               (unchecked-add b a)))
    (assert (= (+' a b) (+' b a))))
  (if (longable? (*' a b))
    (assert (= (* a b) (* b a)
               (*' a b) (*' b a)
               (unchecked-multiply a b)
               (unchecked-multiply b a)))
    (assert (= (*' a b) (*' b a)))))
"integer commutative law" in {
  check { (x: Int, y: Int) =>
    (x + y) mustEqual (y + x)
    (x * y) mustEqual (y * x)
  }
}
Generative Testing

• Real world cases?
Generative Testing

• Real world cases?
 • Sparse trees
Generative Testing

• Real world cases?
 • Sparse trees
 • Complex pre-conditions
Generative Testing

• Real world cases?
 • Sparse trees
 • Complex pre-conditions
• How many iterations?
Rice’s Theorem
[…] there exists no automatic method that
decides with generality non-trivial questions
on the black-box behavior of computer
programs. – Wikipedia
Rice’s Theorem

• You can never have enough assertions
Rice’s Theorem

• You can never have enough assertions
• All you can do is improve “confidence”
 • (for some naïve definition thereof)
Rice’s Theorem

• You can never have enough assertions
• All you can do is improve “confidence”
 • (for some naïve definition thereof)
• Black box testing is a farce
Rice’s Theorem

• You can never have enough assertions
• All you can do is improve “confidence”
 • (for some naïve definition thereof)
• Black box testing is a farce
• Partial function indistinguishable from total
def addGood(x: Int, y: Int) = x + y


// egad!
def addBad(x: Int, y: Int) = (x, y) match {
  case (0, 0) => 0
  case (0, 1) => 1
  case (1, 0) => 1
  case (2, 3) => 5
  case (100, 500) => 600
}
Black Box Testing

• Do we just…enumerate cases?
Black Box Testing

• Do we just…enumerate cases?
• When do we stop? (hint: never!)
Black Box Testing

• Do we just…enumerate cases?
• When do we stop? (hint: never!)
• Can we assume edge cases are predictable?
Black Box Testing

• Do we just…enumerate cases?
• When do we stop? (hint: never!)
• Can we assume edge cases are predictable?
• What can we assume?
Black Box Testing

• Do we just…enumerate cases?
• When do we stop? (hint: never!)
• Can we assume edge cases are predictable?
• What can we assume?
• It’s all undecidable, let’s go shopping
In the beginning…
An Axiomatic Basis for
     Computer
    Programming
Partial Correctness


   P {Q} R
Built on two ideas
• Axioms
 • The foundation of proofs in our system
    (assignment, precendence, identity, etc)
• Inference
 • Higher order ideas that use combinations
    of axioms to draw conclusions
It drove us to think
about consequence in
 program execution
Be Careful!


¬9x 8y (y  x)
Computers are finite!


  8x (x  max)
Real Example
        Commutative law



 x+y =y+x
 x⇥y =y⇥x
Rules of Consequence

(` P {Q} R) ^ (` R   S) ) (` P {Q} S)

(` P {Q} R) ^ (` S   P ) ) (` S {Q} R)
Our problems are solved!
Se
       e G are solved!
Our problems ö
               del
Type Systems
Type Systems

• Mildly controversial…
Type Systems

• Mildly controversial…
• Formal verification…that you can’t disable!
Type Systems

• Mildly controversial…
• Formal verification…that you can’t disable!
• Part of the language (inextricably)
 • (yes, that is a definitional requirement)
Type Systems

• Mildly controversial…
• Formal verification…that you can’t disable!
• Part of the language (inextricably)
 • (yes, that is a definitional requirement)
• Model correctness as consistency
G`t :T
      0                   P ROGRESS
 t ) t _ t is value


G`t :T        t )t   0
                         P RESERVATION
   G`t :T 0
case class Miles(value: Int)
case class Kilometers(value: Int)


def launchMarsMission(distance: Miles) = {
  val kph = distance.value / (6 * 30 * 24)
  increaseSpeedToKPH(kph)
}
trait Forall[CC[_]] {
  def apply[A]: CC[A]
}

trait ST[S, A] {
  def flatMap[B](f: A => ST[S, B]): ST[S, B]
}

object ST {
  def run[A](
    f: Forall[({ type λ[S] = ST[S, A] => A })#λ]): A
}
Correct by Construction

• Incorrect algorithms fail to compile




                               Call me Ishmael…
Correct by Construction

• Incorrect algorithms fail to compile
• Bugs are a thing of the past



                               Call me Ishmael…
Correct by Construction

• Incorrect algorithms fail to compile
• Bugs are a thing of the past
• Programmers herald new era


                               Call me Ishmael…
Correct by Construction

• Incorrect algorithms fail to compile
• Bugs are a thing of the past
• Programmers herald new era
• Profit?

                               Call me Ishmael…
Curry-Howard

• Types are logical propositions
• Values are proofs of propositions
• Type checking is testing logical validity
• A system’s consistency is what is checked
-- Thm. Integer implies Walrus

theorem :: Integer -> Walrus
theorem a = theorem a
-- Thm. everything implies Walrus

theorem :: forall a . a -> Walrus
theorem a = theorem a
-- Thm. everything is true!

theorem :: forall a . a
theorem = theorem
Gödel
• Self-referentiality is a problem
Gödel
• Self-referentiality is a problem
 • Hello, Strange Loop!
Gödel
• Self-referentiality is a problem
 • Hello, Strange Loop!
• Incomplete or inconsistent
Gödel
• Self-referentiality is a problem
 • Hello, Strange Loop!
• Incomplete or inconsistent
• Some valid programs cannot be typed
Gödel
• Self-referentiality is a problem
 • Hello, Strange Loop!
• Incomplete or inconsistent
• Some valid programs cannot be typed
• Strong normalization helps
 • (avoids the need for recursive types!)
System F

• Strongly normalizing λ calculus
System F

• Strongly normalizing λ calculus
• Statically typed, and complete!
System F

• Strongly normalizing λ calculus
• Statically typed, and complete!
 • All valid programs can be typed
System F

• Strongly normalizing λ calculus
• Statically typed, and complete!
 • All valid programs can be typed
 • No invalid programs can be typed
System F

• Strongly normalizing λ calculus
• Statically typed, and complete!
 • All valid programs can be typed
 • No invalid programs can be typed
• Immensely expressive (lists, numbers, etc)
System F
System F

• Not expressive enough
System F

• Not expressive enough
• Cannot bootstrap its own compiler
System F

• Not expressive enough
• Cannot bootstrap its own compiler
• Many valid programs have no encoding
System F

• Not expressive enough
• Cannot bootstrap its own compiler
• Many valid programs have no encoding
• Not Turing-complete! (trivially so)
Static Typing

• Can’t even answer some basic questions
Static Typing

• Can’t even answer some basic questions
• Fails to definitively answer any questions
 • …for Turing-complete calculi
Static Typing

• Can’t even answer some basic questions
• Fails to definitively answer any questions
 • …for Turing-complete calculi
• Arms race of inconvenience
Static Typing

• Can’t even answer some basic questions
• Fails to definitively answer any questions
 • …for Turing-complete calculi
• Arms race of inconvenience
• Guardrails on a sidewalk
add :: Integer -> Integer -> Integer
add x y = x + y
add :: Integer -> Integer -> Integer
add x y = x + y



add :: Prime -> Prime -> Integer
add x y = x + y
(define (add x y)
  (+ x y))
(define (add x y)
  (+ x y))

(module strangeloop racket
  (provide
   (contract-out
    [add (->* (prime? prime?)
              ()
              integer?)])))
(define (divisible? i m)
  (cond
   [(= i 1) true]
   [else (cond
          [(= (remainder m i) 0) false]
          [else (divisible? (sub1 i) m)])]))

(define (prime? n)
  (divisible? (sub1 n) n))
(require 'strangeloop)
(add 7 7)
;; > 14
(add   4 7)
;; >   add: contract violation
;;     expected: prime?, given: 4
;;     in: the 1st argument of
;;          (-> prime? prime?
;;              integer?)
;;     contract from: strangeloop
;;     blaming: top-level
;;     at: stdin::79-82
;;     context...:
But like everything
else, it suffers from
   deficiencies...
Before Contract Application
(time (add 492876847 492876847))
;; > cpu time: 0 real time: 0 gc time: 0
;; 985753694
Before Contract Application
(time (add 492876847 492876847))
;; > cpu time: 0 real time: 0 gc time: 0
;; 985753694



           After Contract Application
(time (add 492876847 492876847))
;; > cpu time: 15963 real time: 15995 gc time: 0
;; 985753694
Runtime issues can
make contracts a non-
starter for production
         code
It’s All Bunk

• Black-Box verification is insufficient
It’s All Bunk

• Black-Box verification is insufficient
• White-Box verification is undecidable
It’s All Bunk

• Black-Box verification is insufficient
• White-Box verification is undecidable
 • …in general!
It’s All Bunk

• Black-Box verification is insufficient
• White-Box verification is undecidable
 • …in general!
• Constrain the domain
Functional Style

• Write your code in a functional style
• It is constraining…that’s the point!
• FP is easier to reason about
 • (both formally and informally)
• Easier to test, and easier to verify
Programming:
 The Good Parts
References
•   From System F to Typed Assembly Language

•   An Axiomatic Basis for Computer Programming

•   Hoare Logic and Auxiliary Variables

•   The Underlying Logic of Hoare Logic

•   Applying Design by Contract

•   Proof Carrying Code

•   Uniform Proofs as a Foundation for Logic Programming

•   Safe Kernel Extensions Without Run-Time Checking

Más contenido relacionado

Similar a Pontificating quantification

Software testing (2) trainingin-mumbai
Software testing (2) trainingin-mumbaiSoftware testing (2) trainingin-mumbai
Software testing (2) trainingin-mumbaivibrantuser
 
Software testing (2) trainingin-mumbai...
Software testing (2) trainingin-mumbai...Software testing (2) trainingin-mumbai...
Software testing (2) trainingin-mumbai...vibrantuser
 
Teaching Constraint Programming, Patrick Prosser
Teaching Constraint Programming,  Patrick ProsserTeaching Constraint Programming,  Patrick Prosser
Teaching Constraint Programming, Patrick ProsserPierre Schaus
 
Playing Go with Clojure
Playing Go with ClojurePlaying Go with Clojure
Playing Go with Clojureztellman
 
Number Crunching in Python
Number Crunching in PythonNumber Crunching in Python
Number Crunching in PythonValerio Maggio
 
Introducción práctica a TDD
Introducción práctica a TDDIntroducción práctica a TDD
Introducción práctica a TDDrubocoptero
 
Introducción práctica a Test-Driven Development (TDD)
Introducción práctica a Test-Driven Development (TDD)Introducción práctica a Test-Driven Development (TDD)
Introducción práctica a Test-Driven Development (TDD)Software Craftsmanship Alicante
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Omar Abdelhafith
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
Sean Kandel - Data profiling: Assessing the overall content and quality of a ...
Sean Kandel - Data profiling: Assessing the overall content and quality of a ...Sean Kandel - Data profiling: Assessing the overall content and quality of a ...
Sean Kandel - Data profiling: Assessing the overall content and quality of a ...huguk
 
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfconstructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfSayanSamanta39
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software DevelopmentNaveenkumar Muguda
 
Machine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConfMachine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConfSeth Juarez
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)Steve Upton
 
JS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJSFestUA
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Ahmad Bashar Eter
 
Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011Jesse Warden
 

Similar a Pontificating quantification (20)

Software testing (2) trainingin-mumbai
Software testing (2) trainingin-mumbaiSoftware testing (2) trainingin-mumbai
Software testing (2) trainingin-mumbai
 
Software testing (2) trainingin-mumbai...
Software testing (2) trainingin-mumbai...Software testing (2) trainingin-mumbai...
Software testing (2) trainingin-mumbai...
 
Java introduction
Java introductionJava introduction
Java introduction
 
Teaching Constraint Programming, Patrick Prosser
Teaching Constraint Programming,  Patrick ProsserTeaching Constraint Programming,  Patrick Prosser
Teaching Constraint Programming, Patrick Prosser
 
Playing Go with Clojure
Playing Go with ClojurePlaying Go with Clojure
Playing Go with Clojure
 
Number Crunching in Python
Number Crunching in PythonNumber Crunching in Python
Number Crunching in Python
 
Introducción práctica a TDD
Introducción práctica a TDDIntroducción práctica a TDD
Introducción práctica a TDD
 
Introducción práctica a Test-Driven Development (TDD)
Introducción práctica a Test-Driven Development (TDD)Introducción práctica a Test-Driven Development (TDD)
Introducción práctica a Test-Driven Development (TDD)
 
Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)Introduction to functional programming (In Arabic)
Introduction to functional programming (In Arabic)
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Sean Kandel - Data profiling: Assessing the overall content and quality of a ...
Sean Kandel - Data profiling: Assessing the overall content and quality of a ...Sean Kandel - Data profiling: Assessing the overall content and quality of a ...
Sean Kandel - Data profiling: Assessing the overall content and quality of a ...
 
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdfconstructing_generic_algorithms__ben_deane__cppcon_2020.pdf
constructing_generic_algorithms__ben_deane__cppcon_2020.pdf
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 
Machine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConfMachine Learning on Azure - AzureConf
Machine Learning on Azure - AzureConf
 
DSR Testing (Part 1)
DSR Testing (Part 1)DSR Testing (Part 1)
DSR Testing (Part 1)
 
JS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better PartsJS Fest 2018. Douglas Crockford. The Better Parts
JS Fest 2018. Douglas Crockford. The Better Parts
 
Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1Acm aleppo cpc training introduction 1
Acm aleppo cpc training introduction 1
 
Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011Refactoring RIA Unleashed 2011
Refactoring RIA Unleashed 2011
 
Message passing
Message passingMessage passing
Message passing
 
Word2vec and Friends
Word2vec and FriendsWord2vec and Friends
Word2vec and Friends
 

Más de Aaron Bedra

The Cost of Complexity
The Cost of ComplexityThe Cost of Complexity
The Cost of ComplexityAaron Bedra
 
AWS Security Essentials
AWS Security EssentialsAWS Security Essentials
AWS Security EssentialsAaron Bedra
 
Leveling the playing field
Leveling the playing fieldLeveling the playing field
Leveling the playing fieldAaron Bedra
 
Windy City Rails - Layered Security
Windy City Rails - Layered SecurityWindy City Rails - Layered Security
Windy City Rails - Layered SecurityAaron Bedra
 
Focus, SCNA 2011
Focus, SCNA 2011Focus, SCNA 2011
Focus, SCNA 2011Aaron Bedra
 
Repsheet: A Behavior Based Approach to Web Application Security
Repsheet: A Behavior Based Approach to Web Application SecurityRepsheet: A Behavior Based Approach to Web Application Security
Repsheet: A Behavior Based Approach to Web Application SecurityAaron Bedra
 
Clojure in the Field
Clojure in the FieldClojure in the Field
Clojure in the FieldAaron Bedra
 
The Art of the Spike
The Art of the SpikeThe Art of the Spike
The Art of the SpikeAaron Bedra
 

Más de Aaron Bedra (8)

The Cost of Complexity
The Cost of ComplexityThe Cost of Complexity
The Cost of Complexity
 
AWS Security Essentials
AWS Security EssentialsAWS Security Essentials
AWS Security Essentials
 
Leveling the playing field
Leveling the playing fieldLeveling the playing field
Leveling the playing field
 
Windy City Rails - Layered Security
Windy City Rails - Layered SecurityWindy City Rails - Layered Security
Windy City Rails - Layered Security
 
Focus, SCNA 2011
Focus, SCNA 2011Focus, SCNA 2011
Focus, SCNA 2011
 
Repsheet: A Behavior Based Approach to Web Application Security
Repsheet: A Behavior Based Approach to Web Application SecurityRepsheet: A Behavior Based Approach to Web Application Security
Repsheet: A Behavior Based Approach to Web Application Security
 
Clojure in the Field
Clojure in the FieldClojure in the Field
Clojure in the Field
 
The Art of the Spike
The Art of the SpikeThe Art of the Spike
The Art of the Spike
 

Último

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 

Último (20)

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 

Pontificating quantification

  • 1. 9p p 2 Pontificating
  • 3.
  • 4. Who watches the watchers?
  • 5. Let’s talk about verification
  • 7. Standard Practice • We all use it • Most of us rely on it day to day • We seem to trust it implicitly
  • 8. def test_example # create something to test obj = MyExampleObject.new(arguments) # program statement result = obj.example_method(arguments) # verification assert_equal("fact", result) #implicit teardown end it "must be an example" do obj = MyExampleObject.new(arguments) result = obj.example_method(arguments) result.should == fact end
  • 9. XUnit is Complected • It’s doing too much
  • 10. XUnit is Complected • It’s doing too much • BDD is just XUnit with lots of bad English
  • 11. XUnit is Complected • It’s doing too much • BDD is just XUnit with lots of bad English • Poor separation of the tester and testee
  • 12. XUnit is Complected • It’s doing too much • BDD is just XUnit with lots of bad English • Poor separation of the tester and testee • What are you testing?
  • 13. XUnit is Complected • It’s doing too much • BDD is just XUnit with lots of bad English • Poor separation of the tester and testee • What are you testing? • Are you sure?!
  • 14. Your mock object is a joke; that object is mocking you. For needing it. – Rich Hickey
  • 15. Coverage is a Lie • Too many false indicators of comprehensive verification • We work really hard at the wrong things to achieve good coverage • “The Emperor's new suit”
  • 16. Always in Manual Drive • Devise, write, and maintain all cases • Edge cases are a (big) problem • Especially with simple functions • Example: Integer commutative law
  • 18. Logic #fail 9x f (x) 6= expect(x) ) bugs 9x f (x) = expect(x) ) ¬bugs
  • 19. Logic #fail 9x f (x) 6= expect(x) ) bugs 9x f (x) = expect(x) ) ¬bugs
  • 20. Logic #fail 9x f (x) 6= expect(x) ) bugs 9x f (x) = expect(x) ) ¬bugs
  • 21. Generative Testing • Developing test cases is hard • We have computers! • Define your domain, auto-generate inputs • Write less, test more • Find edge cases automatically!
  • 22. Generative Testing • Developing test cases is hard • We have computers! • Define your domain, auto-generate inputs • Write less, test more • Find edge cases automatically! • (money back guarantee)
  • 23. (defspec integer-commutative-laws (partial map identity) [^{:tag `integer} a ^{:tag `integer} b] (if (longable? (+' a b)) (assert (= (+ a b) (+ b a) (+' a b) (+' b a) (unchecked-add a b) (unchecked-add b a))) (assert (= (+' a b) (+' b a)))) (if (longable? (*' a b)) (assert (= (* a b) (* b a) (*' a b) (*' b a) (unchecked-multiply a b) (unchecked-multiply b a))) (assert (= (*' a b) (*' b a)))))
  • 24. "integer commutative law" in { check { (x: Int, y: Int) => (x + y) mustEqual (y + x) (x * y) mustEqual (y * x) } }
  • 26. Generative Testing • Real world cases? • Sparse trees
  • 27. Generative Testing • Real world cases? • Sparse trees • Complex pre-conditions
  • 28. Generative Testing • Real world cases? • Sparse trees • Complex pre-conditions • How many iterations?
  • 30. […] there exists no automatic method that decides with generality non-trivial questions on the black-box behavior of computer programs. – Wikipedia
  • 31. Rice’s Theorem • You can never have enough assertions
  • 32. Rice’s Theorem • You can never have enough assertions • All you can do is improve “confidence” • (for some naïve definition thereof)
  • 33. Rice’s Theorem • You can never have enough assertions • All you can do is improve “confidence” • (for some naïve definition thereof) • Black box testing is a farce
  • 34. Rice’s Theorem • You can never have enough assertions • All you can do is improve “confidence” • (for some naïve definition thereof) • Black box testing is a farce • Partial function indistinguishable from total
  • 35. def addGood(x: Int, y: Int) = x + y // egad! def addBad(x: Int, y: Int) = (x, y) match { case (0, 0) => 0 case (0, 1) => 1 case (1, 0) => 1 case (2, 3) => 5 case (100, 500) => 600 }
  • 36. Black Box Testing • Do we just…enumerate cases?
  • 37. Black Box Testing • Do we just…enumerate cases? • When do we stop? (hint: never!)
  • 38. Black Box Testing • Do we just…enumerate cases? • When do we stop? (hint: never!) • Can we assume edge cases are predictable?
  • 39. Black Box Testing • Do we just…enumerate cases? • When do we stop? (hint: never!) • Can we assume edge cases are predictable? • What can we assume?
  • 40. Black Box Testing • Do we just…enumerate cases? • When do we stop? (hint: never!) • Can we assume edge cases are predictable? • What can we assume? • It’s all undecidable, let’s go shopping
  • 42. An Axiomatic Basis for Computer Programming
  • 44. Built on two ideas • Axioms • The foundation of proofs in our system (assignment, precendence, identity, etc) • Inference • Higher order ideas that use combinations of axioms to draw conclusions
  • 45. It drove us to think about consequence in program execution
  • 46. Be Careful! ¬9x 8y (y  x)
  • 47. Computers are finite! 8x (x  max)
  • 48. Real Example Commutative law x+y =y+x x⇥y =y⇥x
  • 49. Rules of Consequence (` P {Q} R) ^ (` R S) ) (` P {Q} S) (` P {Q} R) ^ (` S P ) ) (` S {Q} R)
  • 50. Our problems are solved!
  • 51. Se e G are solved! Our problems ö del
  • 53. Type Systems • Mildly controversial…
  • 54. Type Systems • Mildly controversial… • Formal verification…that you can’t disable!
  • 55. Type Systems • Mildly controversial… • Formal verification…that you can’t disable! • Part of the language (inextricably) • (yes, that is a definitional requirement)
  • 56. Type Systems • Mildly controversial… • Formal verification…that you can’t disable! • Part of the language (inextricably) • (yes, that is a definitional requirement) • Model correctness as consistency
  • 57. G`t :T 0 P ROGRESS t ) t _ t is value G`t :T t )t 0 P RESERVATION G`t :T 0
  • 58. case class Miles(value: Int) case class Kilometers(value: Int) def launchMarsMission(distance: Miles) = { val kph = distance.value / (6 * 30 * 24) increaseSpeedToKPH(kph) }
  • 59. trait Forall[CC[_]] { def apply[A]: CC[A] } trait ST[S, A] { def flatMap[B](f: A => ST[S, B]): ST[S, B] } object ST { def run[A]( f: Forall[({ type λ[S] = ST[S, A] => A })#λ]): A }
  • 60. Correct by Construction • Incorrect algorithms fail to compile Call me Ishmael…
  • 61. Correct by Construction • Incorrect algorithms fail to compile • Bugs are a thing of the past Call me Ishmael…
  • 62. Correct by Construction • Incorrect algorithms fail to compile • Bugs are a thing of the past • Programmers herald new era Call me Ishmael…
  • 63. Correct by Construction • Incorrect algorithms fail to compile • Bugs are a thing of the past • Programmers herald new era • Profit? Call me Ishmael…
  • 64. Curry-Howard • Types are logical propositions • Values are proofs of propositions • Type checking is testing logical validity • A system’s consistency is what is checked
  • 65. -- Thm. Integer implies Walrus theorem :: Integer -> Walrus theorem a = theorem a
  • 66. -- Thm. everything implies Walrus theorem :: forall a . a -> Walrus theorem a = theorem a
  • 67. -- Thm. everything is true! theorem :: forall a . a theorem = theorem
  • 69. Gödel • Self-referentiality is a problem • Hello, Strange Loop!
  • 70. Gödel • Self-referentiality is a problem • Hello, Strange Loop! • Incomplete or inconsistent
  • 71. Gödel • Self-referentiality is a problem • Hello, Strange Loop! • Incomplete or inconsistent • Some valid programs cannot be typed
  • 72. Gödel • Self-referentiality is a problem • Hello, Strange Loop! • Incomplete or inconsistent • Some valid programs cannot be typed • Strong normalization helps • (avoids the need for recursive types!)
  • 73. System F • Strongly normalizing λ calculus
  • 74. System F • Strongly normalizing λ calculus • Statically typed, and complete!
  • 75. System F • Strongly normalizing λ calculus • Statically typed, and complete! • All valid programs can be typed
  • 76. System F • Strongly normalizing λ calculus • Statically typed, and complete! • All valid programs can be typed • No invalid programs can be typed
  • 77. System F • Strongly normalizing λ calculus • Statically typed, and complete! • All valid programs can be typed • No invalid programs can be typed • Immensely expressive (lists, numbers, etc)
  • 79. System F • Not expressive enough
  • 80. System F • Not expressive enough • Cannot bootstrap its own compiler
  • 81. System F • Not expressive enough • Cannot bootstrap its own compiler • Many valid programs have no encoding
  • 82. System F • Not expressive enough • Cannot bootstrap its own compiler • Many valid programs have no encoding • Not Turing-complete! (trivially so)
  • 83. Static Typing • Can’t even answer some basic questions
  • 84. Static Typing • Can’t even answer some basic questions • Fails to definitively answer any questions • …for Turing-complete calculi
  • 85. Static Typing • Can’t even answer some basic questions • Fails to definitively answer any questions • …for Turing-complete calculi • Arms race of inconvenience
  • 86. Static Typing • Can’t even answer some basic questions • Fails to definitively answer any questions • …for Turing-complete calculi • Arms race of inconvenience • Guardrails on a sidewalk
  • 87.
  • 88. add :: Integer -> Integer -> Integer add x y = x + y
  • 89. add :: Integer -> Integer -> Integer add x y = x + y add :: Prime -> Prime -> Integer add x y = x + y
  • 90. (define (add x y) (+ x y))
  • 91. (define (add x y) (+ x y)) (module strangeloop racket (provide (contract-out [add (->* (prime? prime?) () integer?)])))
  • 92. (define (divisible? i m) (cond [(= i 1) true] [else (cond [(= (remainder m i) 0) false] [else (divisible? (sub1 i) m)])])) (define (prime? n) (divisible? (sub1 n) n))
  • 94. (add 4 7) ;; > add: contract violation ;; expected: prime?, given: 4 ;; in: the 1st argument of ;; (-> prime? prime? ;; integer?) ;; contract from: strangeloop ;; blaming: top-level ;; at: stdin::79-82 ;; context...:
  • 95. But like everything else, it suffers from deficiencies...
  • 96. Before Contract Application (time (add 492876847 492876847)) ;; > cpu time: 0 real time: 0 gc time: 0 ;; 985753694
  • 97. Before Contract Application (time (add 492876847 492876847)) ;; > cpu time: 0 real time: 0 gc time: 0 ;; 985753694 After Contract Application (time (add 492876847 492876847)) ;; > cpu time: 15963 real time: 15995 gc time: 0 ;; 985753694
  • 98. Runtime issues can make contracts a non- starter for production code
  • 99. It’s All Bunk • Black-Box verification is insufficient
  • 100. It’s All Bunk • Black-Box verification is insufficient • White-Box verification is undecidable
  • 101. It’s All Bunk • Black-Box verification is insufficient • White-Box verification is undecidable • …in general!
  • 102. It’s All Bunk • Black-Box verification is insufficient • White-Box verification is undecidable • …in general! • Constrain the domain
  • 103. Functional Style • Write your code in a functional style • It is constraining…that’s the point! • FP is easier to reason about • (both formally and informally) • Easier to test, and easier to verify
  • 105. References • From System F to Typed Assembly Language • An Axiomatic Basis for Computer Programming • Hoare Logic and Auxiliary Variables • The Underlying Logic of Hoare Logic • Applying Design by Contract • Proof Carrying Code • Uniform Proofs as a Foundation for Logic Programming • Safe Kernel Extensions Without Run-Time Checking

Notas del editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n