The Nuggetizer: Abstracting Away Higher-Orderness for Program - - PowerPoint PPT Presentation

the nuggetizer abstracting away higher orderness for
SMART_READER_LITE
LIVE PREVIEW

The Nuggetizer: Abstracting Away Higher-Orderness for Program - - PowerPoint PPT Presentation

The Nuggetizer: Abstracting Away Higher-Orderness for Program Verification Paritosh Shroff Department of Computer Science Johns Hopkins University Joint work with Christian Skalka (University of Vermont) and Scott F. Smith (Johns Hopkins


slide-1
SLIDE 1

The Nuggetizer: Abstracting Away Higher-Orderness for Program Verification

Paritosh Shroff Department of Computer Science Johns Hopkins University

Joint work with Christian Skalka (University of Vermont) and Scott F. Smith (Johns Hopkins University)

slide-2
SLIDE 2

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 2

Objective

Prove non-trivial inductive properties about higher-order programs

Statically Automatically Without any programmer annotations

Exemplar: Value range analysis for higher-

  • rder functional programs

Inferring the range of values assignable to integer

variables at runtime

slide-3
SLIDE 3

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 3

Example: Factorial Program

let f = λfact. λn. if (n != 0) then n * fact fact (n - 1) else 1 in f f 5

Focus of rest of the talk: Verify range of n is [0, 5]

Recursion encoded by “self-passing”

slide-4
SLIDE 4

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 4

Motivation

Higher-Order Functional Programming

Powerful programming paradigm Complex from automated verification standpoint

Actual low-level operations and the order in which

they take place are far removed from the source code, especially in presence of recursion, for example, via the Y-combinator The simpler first-order view is easiest for automated verification methods to be applied to

slide-5
SLIDE 5

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 5

Our Approach

Abstract Away the Higher-Orderness

Distill the first-order computational structure from

higher-order programs into a nugget

Preserve much of other behavior, including

Control-Flow (Flow-Sensitivity + Path-Sensitivity) Infinite Datatype Domains Other Inductive Program Structures

Feed the nugget to a theorem prover to prove

desirable properties of the source program

slide-6
SLIDE 6

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 6

A Nugget

Set of purely first-order inductive definitions Denotes the underlying computational

structure of the higher-order program

Characterizes all value bindings that may arise

during corresponding program’s execution

Extracted automatically by the nuggetizer

from any untyped functional program

slide-7
SLIDE 7

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 7

Example: Factorial Program

let f = λfact. λn. if (n != 0) then n * fact fact (n - 1) else 1 in f f 5 Property of interest: Range of n is [0, 5] Nugget at n: { n a 5, n a (n - 1)n != 0 }

slide-8
SLIDE 8

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 8

Example: Factorial Program

let f = λfact. λn. if (n != 0) then n * fact fact (n - 1) else 1 in f f 5 Property of interest: Range of n is [0, 5] Nugget at n: { n a 5, n a (n - 1)n != 0 }

slide-9
SLIDE 9

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 9

Example: Factorial Program

let f = λfact. λn. if (n != 0) then n * fact fact (n - 1) else 1 in f f 5 Property of interest: Range of n is [0, 5] Nugget at n: { n a 5, n a (n - 1)n != 0 }

Guard: A precondition on the usage of the mapping

slide-10
SLIDE 10

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 10

Denotation of a Nugget

The least set of values implied by the mappings such that their guards hold { n a 5, n a (n - 1)n != 0 } ⇓ { n a 5, n a 4, n a 3, n a 2, n a 1, n a 0 }

n a -1 is disallowed as n a 0 does not satisfy the guard (n != 0), analogous to the program’s computation Range of n is denoted to be precisely [0, 5]

slide-11
SLIDE 11

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 11

Nuggets in Theorem Provers

Nuggets are automatically translatable to

equivalent definitions in a theorem prover

Theorem provers provide built-in mechanisms for

writing inductive definitions, and automatically generating proof strategies thereupon

We provide an automatic translation scheme

for Isabelle/HOL

We have proved 0 ≤ n ≤ 5 and similar properties

for other programs

slide-12
SLIDE 12

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 12

Summary of Our Approach

Source Code (Higher-Order) Nugget (First-Order) Theorem Prover

extract feed into

Program Properties

prove automatic automatic automatic automatic prove

slide-13
SLIDE 13

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 13

The Nuggetizer

Extracts nuggets from higher-order programs

via a collecting semantics

Incrementally accumulates the nugget over an

abstract execution of the program

= 0CFA + flow-sensitivity + path-sensitivity

Abstract execution closely mimics concrete

execution

Novel prune-rerun technique ensures

convergence and soundness in presence of flow-sensitivity and recursion

slide-14
SLIDE 14

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 14

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

Abstract Call Stack Abstract Environment

empty

f a (λfact. λn. …), f′ a (λn. …), fact a f, fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

A-normal form – each program point has an associated variable

slide-15
SLIDE 15

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 15

Illustration of the Nuggetizer

f a (λfact. λn. …), f′ a (λn. …), fact a f, fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Collect the let-binding in the abstract environment

Abstract Environment

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Abstract Call Stack

empty

redex

slide-16
SLIDE 16

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 16

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

redex

Invoke (λfact. λn. …) on f, and place it in the call stack

Abstract Call Stack

(λfact. λn. …) f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment

slide-17
SLIDE 17

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 17

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

Pop (λfact. λn. …), and return (λn. …) to f′

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

empty

slide-18
SLIDE 18

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 18

Illustration of the Nuggetizer

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Invoke (λn. …) on 5, and place it in the call stack

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

slide-19
SLIDE 19

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 19

Illustration of the Nuggetizer

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Analyze the then and else branches in parallel

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

slide-20
SLIDE 20

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 20

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

Invoke (λfact. λn. …) on fact under the guard n != 0

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …) (λfact. λn. …)

slide-21
SLIDE 21

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 21

Illustration of the Nuggetizer

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Pop (λfact. λn. …), and return (λn. …) to fact′

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

slide-22
SLIDE 22

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 22

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

slide-23
SLIDE 23

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 23

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

Prune (ignore) the recursive invocation of (λn. …)

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

slide-24
SLIDE 24

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 24

r only serves as a placeholder for the return value of the recursive call

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Illustration of the Nuggetizer

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

r and, transitively, r′ have no concrete bindings, as of now

slide-25
SLIDE 25

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 25

Illustration of the Nuggetizer

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Merge the results of the two branches, tagged with appropriate guards

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

(λn. …)

r and, transitively, r′ now have concrete bindings

slide-26
SLIDE 26

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 26

Illustration of the Nuggetizer

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Pop (λn. …), and return r to z

redex

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment Abstract Call Stack

empty

slide-27
SLIDE 27

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 27

Illustration of the Nuggetizer

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Abstract Environment

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Abstract Call Stack

empty The abstract execution terminates

slide-28
SLIDE 28

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 28

Illustration of the Nuggetizer

Nugget

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (n * r′)n != 0, r a 1n == 0, z a r

Nugget: The least fixed-point of the abstract environment

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in n * r′ else 1 in r in let f′ = f f in in let z = f′ 5 in z

Abstract Call Stack

empty

Fixed-point of the abstract environment -- observable by rerunning abstract execution

slide-29
SLIDE 29

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 29

Can also contribute new mappings

Especially in presence of higher-order recursive

functions which themselves return functions

Rerunning Abstract Execution

slide-30
SLIDE 30

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 30

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Illustration of Rerunning for Convergence

Abstract Call Stack

empty

Higher-order recursive function itself returning functions Abstract Environment

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0

slide-31
SLIDE 31

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 31

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Illustration of Rerunning for Convergence

Abstract Call Stack

(λn. …) During the initial run

Abstract Environment

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0

redex

Prune the recursive invocation of (λn. …), as before

slide-32
SLIDE 32

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 32

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Illustration of Rerunning for Convergence

Abstract Call Stack

(λn. …)

redex Abstract Environment

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0

No concrete binding for r′, the analysis simply skips

  • ver the redex ‘r′ ()’

Skip over the call-site r′ ()

slide-33
SLIDE 33

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 33

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Illustration of Rerunning for Convergence

Abstract Call Stack

(λn. …)

Abstract Environment

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0 Merge the results of the two branches, tagged with appropriate guards

r′ now has concrete bindings, but no binding for r′′

slide-34
SLIDE 34

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 34

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Illustration of Rerunning for Convergence

Abstract Call Stack

empty End of the initial run

Abstract Environment

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0

slide-35
SLIDE 35

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 35

Illustration of Rerunning for Convergence

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Abstract Call Stack

(λn. …) During the rerun

Abstract Environment

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0

r′ has concrete bindings redex

slide-36
SLIDE 36

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 36

Illustration of Rerunning for Convergence

let f = λfact. λn. let r = if (n != 0) then let fact′ = fact fact in let r′ = fact′ (n - 1) in let r′′ = r′ () in λx. (n * r′′) else λy. 1 in r in let f′ = f f in in let z = f′ 5 in in let z′ = z () in z′

Nugget

f a (λfact. λn. …), fact a f, f′ a (λn. …), fact a factn != 0, fact′ a (λn. …), n a 5, n a (n - 1)n != 0, r′ a r, r a (λx. n * r′′)n != 0, r a (λy. 1)n == 0, z a r, x a (), y a (), z′ a (n * r′′)n != 0, z′ a 1n == 0, x a ()n != 0, y a ()n != 0, r′′ a (n * r′′)n != 0, r′′ a 1n == 0

Abstract Call Stack

empty End of the rerun

Now a fixed-point of the abstract environment --

  • bservable by rerunning

abstract execution

slide-37
SLIDE 37

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 37

However…

Number of reruns required to reach a fixed- point is always (provably) finite

Abstract environment is monotonically increasing

across runs

Size of abstract environment is strongly bound

Domain, range and guards of all mappings are

fragments of the source program

All feasible mappings will eventually be collected after some finite number of reruns, and a fixed-point reached

slide-38
SLIDE 38

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 38

Properties of the Nuggetizer

Soundness Nugget denotes all values that may arise in variables at runtime Termination Nuggetizer computes a nugget for all programs Runtime Complexity Runtime complexity of the nuggetizer is O(n!·n3), where n is the size

  • f a program

We expect it to be significantly less in practice

slide-39
SLIDE 39

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 39

Related Work

No direct precedent to our work

An automated algorithm for abstracting arbitrary higher-

  • rder programs as first-order inductive definitions
  • A logical descendent of 0CFA [Shivers’91]
  • Dependent, Refinement Types [Xi+’05, Flanagan+’06]
  • Require programmer annotations
  • Our approach: No programmer annotations
  • Logic Flow Analysis [Might’07]
  • Does not generate inductive definitions
  • Invokes theorem prover many times, and on-the-fly
  • Our approach: only once, at the end
slide-40
SLIDE 40

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 40

Currently working towards

Completeness

A lossless translation of higher-order programs to

first-order inductive definitions

(The current analysis is sound but not complete)

Incorporating Flow-Sensitive Mutable State

Shape-analysis of heap data structures

Prototype Implementation

slide-41
SLIDE 41

Thank You

slide-42
SLIDE 42

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 42

Example of Incompleteness

let f = λsort. λx. λlimit. if (x < limit) then sort sort (x + 1) (limit - 1) else 1 in f f 0 9 Range of x is [0, 5] and range of limit is [4, 9] Nugget at x and limit: { x a 0, x a (x + 1)x < limit, limit a 9, limit a (limit - 1)x < limit } ⇓ { x a 0, …, x a 9, limit a 9, …, limit a 0 } Correlation between order of assignments to x and limit is lost

Inspired by bidirectional bubble sort

slide-43
SLIDE 43

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 43

External Inputs

let f = λfact. λn. if (n != 0) then n * fact fact (n - 1) else 1 in if (inp ≥ 0) then f f inp Property of interest: Symbolic range of n is [0, …, inp] Nugget at n: { n a inpinp ≥ 0, n a (n - 1)n != 0 } ⇓ { n a inp, n a inp - 1, …, n a 0 }

slide-44
SLIDE 44

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 44

A more complex example

Z = λf. (λx. f (λy. x x y)) (λx. f (λy. x x y)) let f′ = λfact. λn. if (n != 0) then n * fact (n - 1) else 1 in Z f′ 5 Nugget at n: { n a 5, n a y, y a (n - 1)n != 0 } ≡ { n a 5, n a (n - 1)n != 0 }

slide-45
SLIDE 45

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 45

Another complex example

let g = λfact′. λm. fact′ fact′ (m - 1) in let f = λfact. λn. if (n != 0) then n * g fact n else 1 in f f 5 Nugget at n and m: { n a 5, m a nn != 0, n a (m – 1) } ⇓ { n a 5, n a 4, n a 3, n a 2, n a 1, n a 0 } { m a 5, m a 4, m a 3, m a 2, m a 1 }

slide-46
SLIDE 46

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 46

General, End-to-End Programming Logic

let f = λfact. λn. assert (n ≥ 0); if (n != 0) then n * fact fact (n - 1) else 1 in f f 5 assert (n ≥ 0) would be compiled down to a theorem, and automatically proved by the theorem prover

  • ver the automatically generated nugget

Many asserts are implicit

Array bounds and null pointer checks

slide-47
SLIDE 47

29 Nov 2007, APLAS Abstracting Away Higher-Orderness for Program Verification 47

Methodology by Analogy

Program Model Checking Our Approach Abstraction Model

Finite Automaton Model Checking Faster First-Order Programs, Non-Inductive Properties First-Order Inductive Definitions (Nugget)

Verification Method

Theorem Proving

Pros

Higher-Order Programs, Inductive Properties

Cons

Slower