SMT and Z3 Nikolaj Bjrner Microsoft Research ReRISE Winter School, - - PowerPoint PPT Presentation

β–Ά
smt and z3
SMART_READER_LITE
LIVE PREVIEW

SMT and Z3 Nikolaj Bjrner Microsoft Research ReRISE Winter School, - - PowerPoint PPT Presentation

SMT and Z3 Nikolaj Bjrner Microsoft Research ReRISE Winter School, Linz, Austria February 5, 2014 Plan Mon An invitation to SMT with Z3 Tue Equalities and Theory Combination Wed Theories: Arithmetic, Arrays, Data types Thu Quantifiers and


slide-1
SLIDE 1

SMT and Z3

Nikolaj BjΓΈrner Microsoft Research

ReRISE Winter School, Linz, Austria February 5, 2014

slide-2
SLIDE 2

Plan

Mon An invitation to SMT with Z3 Tue Equalities and Theory Combination Wed Theories: Arithmetic, Arrays, Data types Thu Quantifiers and Theories Fri Programming Z3: Interfacing and Solving

slide-3
SLIDE 3

Quiz

Show: A difference logic graph without negative cycles has a

  • model. Give a procedure for extracting a model.

True or false: A formula over difference logic has a model

  • ver reals iff it has a model over integers?

Give an efficient algorithm to extract models for UTVPI over integers. Encode lambda Calculus into π‘›π‘π‘ž, 𝐿, 𝑠𝑓𝑏𝑒 (without 𝐽).

slide-4
SLIDE 4

Plan

  • Arithmetic
  • Arrays and friends
  • Data types [Introduction]
slide-5
SLIDE 5

What Theories?

EUF LRA LIA Arrays Bit-Vectors

  • Alg. DT

SAT

Overall aim: Rich Theories (and logics) with Efficient Decision Procedures

Strings

  • Reg. Exprs.

NRA NIA Floats f* * BAPA

MultiSets

homomor phisms Optimiz ation Orders Objects HOL

DL

ASP

Queues XDucers Sequences MSOL Auth

slide-6
SLIDE 6

Be afraid!

slide-7
SLIDE 7

Linear Real Arithmetic

  • Many approaches

– Graph-based for difference logic: a – b ο‚£ 3 – Fourier-Motzkin elimination: – Standard Simplex – General Form Simplex – GDPLL [McMillan], Unate Resolution [Coton], Conflict Resolution [Korovin et.al.]

slide-8
SLIDE 8

Difference Logic: a – b ο‚£ 5

Very useful in practice! Most arithmetical constraints in software verification/analysis are in this fragment. x := x + 1 x1 = x0 + 1 x1 - x0 ο‚£ 1, x0 - x1 ο‚£ -1

slide-9
SLIDE 9

Job shop scheduling

slide-10
SLIDE 10

Difference Logic

Chasing negative cycles! Algorithms based on Bellman-Ford (O(mn)).

slide-11
SLIDE 11

Unit Two Variables Per Inequality

𝑦 + 𝑧 ≀ 5 ∧ βˆ’π‘¦ + 𝑧 ≀ βˆ’4 ∧ 𝑧 + 𝑧 β‰₯ 1

slide-12
SLIDE 12

Unit Two Variables Per Inequality

𝑦 + 𝑧 ≀ 5 ∧ βˆ’π‘¦ + 𝑧 ≀ βˆ’4 ∧ 2𝑧 β‰₯ 1 2𝑧 ≀ 1 ∧ 2𝑧 β‰₯ 1

slide-13
SLIDE 13

Unit Two Variables Per Inequality

𝑦 + 𝑧 ≀ 5 ∧ βˆ’π‘¦ + 𝑧 ≀ βˆ’4 ∧ 2𝑧 β‰₯ 1 2𝑧 ≀ 1 ∧ 2𝑧 β‰₯ 1 𝑧 ≀ 0 ∧ 𝑧 β‰₯ 1

slide-14
SLIDE 14

Unit Two Variables Per Inequality: UTVPI

Reduce to Difference Logic:

  • For every variable 𝑦 introduce fresh variables

𝑦+, π‘¦βˆ’

  • Meaning: 2𝑦 ≔ 𝑦+ βˆ’ π‘¦βˆ’
  • Rewrite constraints as follows:
  • 𝑦 βˆ’ 𝑧 ≀ 𝑙

β‡’ 𝑦+ βˆ’ 𝑧+ ≀ 𝑙 π‘§βˆ’ βˆ’ π‘¦βˆ’ ≀ 𝑙

slide-15
SLIDE 15

UTVPI

  • 𝑦 βˆ’ 𝑧 ≀ 𝑙

β‡’ 𝑦+ βˆ’ 𝑧+ ≀ 𝑙 π‘§βˆ’ βˆ’ π‘¦βˆ’ ≀ 𝑙

  • 𝑦 ≀ 𝑙

β‡’ 𝑦+ βˆ’ π‘¦βˆ’ ≀ 2𝑙

  • 𝑦 + 𝑧 ≀ 𝑙

β‡’ 𝑦+ βˆ’ π‘§βˆ’ ≀ 𝑙 𝑧+ βˆ’ π‘¦βˆ’ ≀ 𝑙

  • 𝑦 + 𝑧 ≀ 𝑙

β‡’ chalkboard

slide-16
SLIDE 16

UTVPI

𝑦 + 𝑧 ≀ 5 ∧ βˆ’π‘¦ + 𝑧 ≀ βˆ’4 ∧ 2𝑧 β‰₯ 1 𝑦+ βˆ’ π‘§βˆ’ ≀ 5 ∧ 𝑧+ βˆ’ π‘¦βˆ’ ≀ 5 ∧ βˆ’π‘¦+ + 𝑧+ ≀ βˆ’4 ∧ π‘¦βˆ’ βˆ’ π‘§βˆ’ ≀ βˆ’4 ∧ π‘§βˆ’ βˆ’ 𝑧+ ≀ 1

slide-17
SLIDE 17

UTVPI

  • Solve for 𝑦+ and π‘¦βˆ’
  • 𝑁(𝑦) ≔ (𝑁(𝑦+) βˆ’ 𝑁(π‘¦βˆ’))/2
  • Nothing can go wrong…

2𝑧 ≀ 1 ∧ 2𝑧 β‰₯ 1

slide-18
SLIDE 18

UTVPI

  • 𝑁(𝑦) ≔ (𝑁(𝑦+) βˆ’ 𝑁(π‘¦βˆ’))/2
  • Nothing can go wrong… as if
  • What if:

– 𝑦 is an integer – 𝑁(𝑦+) is odd and – 𝑁(π‘¦βˆ’) is even

  • Thm: Parity can be fixed iff there is no tight

loop forcing the wrong parity

slide-19
SLIDE 19

π‘¦βˆ’ βˆ’ 𝑧+ ≀ 5 𝑧+ βˆ’ π‘¨βˆ’ ≀ βˆ’6 π‘¨βˆ’ βˆ’ 𝑦+ ≀ βˆ’2 𝑦+ βˆ’ 𝑀+ ≀ 3 𝑀+ βˆ’ π‘¦βˆ’ ≀

UTVPI

β‡’ π‘¦βˆ’ βˆ’ 𝑦+ ≀ βˆ’3 𝑦+ βˆ’ π‘¦βˆ’ ≀ 3

slide-20
SLIDE 20

General Form

slide-21
SLIDE 21

From Definitions to a Tableau

s1 ο‚Ί x + y, s2 ο‚Ί x + 2y

slide-22
SLIDE 22

From Definitions to a Tableau

s1 ο‚Ί x + y, s2 ο‚Ί x + 2y

s1 = x + y, s2 = x + 2y

slide-23
SLIDE 23

From Definitions to a Tableau

s1 ο‚Ί x + y, s2 ο‚Ί x + 2y

s1 = x + y, s2 = x + 2y s1 - x - y = 0 s2 - x - 2y = 0

slide-24
SLIDE 24

From Definitions to a Tableau

s1 ο‚Ί x + y, s2 ο‚Ί x + 2y

s1 = x + y, s2 = x + 2y s1 - x - y = 0 s2 - x - 2y = 0 s1, s2 are basic (dependent) x,y are non-basic

slide-25
SLIDE 25

Pivoting

A way to swap a basic with a non-basic variable! It is just equational reasoning. Key invariant: a basic variable occurs in only one equation. Example: swap s1 and y

s1 - x - y = 0 s2 - x - 2y = 0

slide-26
SLIDE 26

Pivoting

A way to swap a basic with a non-basic variable! It is just equational reasoning. Key invariant: a basic variable occurs in only one equation. Example: swap s1 and y

s1 - x - y = 0 s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - x - 2y = 0

slide-27
SLIDE 27

Pivoting

A way to swap a basic with a non-basic variable! It is just equational reasoning. Key invariant: a basic variable occurs in only one equation. Example: swap s1 and y

s1 - x - y = 0 s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - 2s1 + x = 0

slide-28
SLIDE 28

Pivoting

A way to swap a basic with a non-basic variable! It is just equational reasoning. Key invariant: a basic variable occurs in only one equation. Example: swap s1 and y

s1 - x - y = 0 s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - 2s1 + x = 0 It is just substituting equals by equals.

slide-29
SLIDE 29

Pivoting

A way to swap a basic with a non-basic variable! It is just equational reasoning. Key invariant: a basic variable occurs in only one equation. Example: swap s1 and y

s1 - x - y = 0 s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - 2s1 + x = 0 It is just substituting equals by equals.

Definition: An assignment (model) is a mapping from variables to values

Key Property: If an assignment satisfies the equations before a pivoting step, then it will also satisfy them after!

slide-30
SLIDE 30

Pivoting

A way to swap a basic with a non-basic variable! It is just equational reasoning. Key invariant: a basic variable occurs in only one equation. Example: swap s2 and y

s1 - x - y = 0 s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - x - 2y = 0

  • s1 + x + y = 0

s2 - 2s1 + x = 0 It is just substituting equals by equals.

Definition: An assignment (model) is a mapping from variables to values

Key Property: If an assignment satisfies the equations before a pivoting step, then it will also satisfy them after! Example: M(x) = 1 M(y) = 1 M(s1) = 2 M(s2) = 3

slide-31
SLIDE 31

Equations + Bounds + Assignment

slide-32
SLIDE 32

β€œRepairing Models”

If the assignment of a non-basic variable does not satisfy a bound, then fix it and propagate the change to all dependent variables. a = c – d b = c + d M(a) = 0 M(b) = 0 M(c) = 0 M(d) = 0 1 ο‚£ c a = c – d b = c + d M(a) = 1 M(b) = 1 M(c) = 1 M(d) = 0 1 ο‚£ c

slide-33
SLIDE 33

β€œRepairing Models”

If the assignment of a non-basic variable does not satisfy a bound, then fix it and propagate the change to all dependent variables. Of course, we may introduce new β€œproblems”. a = c – d b = c + d M(a) = 0 M(b) = 0 M(c) = 0 M(d) = 0 1 ο‚£ c a ο‚£ 0 a = c – d b = c + d M(a) = 1 M(b) = 1 M(c) = 1 M(d) = 0 1 ο‚£ c a ο‚£ 0

slide-34
SLIDE 34

β€œRepairing Models”

If the assignment of a basic variable does not satisfy a bound, then pivot it, fix it, and propagate the change to its new dependent variables. a = c – d b = c + d M(a) = 0 M(b) = 0 M(c) = 0 M(d) = 0 1 ο‚£ a c = a + d b = a + 2d M(a) = 0 M(b) = 0 M(c) = 0 M(d) = 0 1 ο‚£ a c = a + d b = a + 2d M(a) = 1 M(b) = 1 M(c) = 1 M(d) = 0 1 ο‚£ a

slide-35
SLIDE 35

β€œRepairing Models”

Sometimes, a model cannot be repaired. It is pointless to pivot. a = b – c a ο‚£ 0, 1 ο‚£ b, c ο‚£ 0 M(a) = 1 M(b) = 1 M(c) = 0 The value of M(a) is too big. We can reduce it by:

  • reducing M(b)

not possible b is at lower bound

  • increasing M(c)

not possible c is at upper bound

slide-36
SLIDE 36

β€œRepairing Models”

s1 ο‚Ί a + d, s2 ο‚Ί c + d a = s1 – s2 + c a ο‚£ 0, 1 ο‚£ s1, s2 ο‚£ 0, 0 ο‚£ c M(a) = 1 M(s1) = 1 M(s2) = 0 M(c) = 0 Extracting proof from failed repair attempts is easy.

slide-37
SLIDE 37

β€œRepairing Models”

s1 ο‚Ί a + d, s2 ο‚Ί c + d a = s1 – s2 + c a ο‚£ 0, 1 ο‚£ s1, s2 ο‚£ 0, 0 ο‚£ c M(a) = 1 M(s1) = 1 M(s2) = 0 M(c) = 0 Extracting proof from failed repair attempts is easy. { a ο‚£ 0, 1 ο‚£ s1, s2 ο‚£ 0, 0 ο‚£ c } is inconsistent

slide-38
SLIDE 38

β€œRepairing Models”

s1 ο‚Ί a + d, s2 ο‚Ί c + d a = s1 – s2 + c a ο‚£ 0, 1 ο‚£ s1, s2 ο‚£ 0, 0 ο‚£ c M(a) = 1 M(s1) = 1 M(s2) = 0 M(c) = 0 Extracting proof from failed repair attempts is easy. { a ο‚£ 0, 1 ο‚£ s1, s2 ο‚£ 0, 0 ο‚£ c } is inconsistent { a ο‚£ 0, 1 ο‚£ a + d, c + d ο‚£ 0, 0 ο‚£ c } is inconsistent

slide-39
SLIDE 39
slide-40
SLIDE 40

What are arrays?

  • Applicative stores:
  • Or, special combinator:

( , , )[ ] ( , , )[ ] [ ] write a i v i v i j write a i v j a j ο€½ ο‚Ή οƒž ο€½

( , , ) . ( , , [ ]) write a i v j ite i j v a j  ο€½ ο€½

slide-41
SLIDE 41

What are arrays?

  • Special combinator:
  • Existential fragment is decidable by reduction

to congruence closure using finite set of instances.

  • Models for arrays are finite maps with default

values.

( , , ) . ( , , [ ]) write a i v j ite i j v a j  ο€½ ο€½

slide-42
SLIDE 42

What else are arrays?

  • Special combinators:
  • Result: Existential fragment is decidable and in NP by

reduction to congruence closure using finite set of instances.

( , , ) . ( , , [ ]) ( ) . ( , ) . ( [ ], [ ])

f

write a i v j ite i j v a j K v j v map a b j f a j b j    ο€½ ο€½ ο€½ ο€½

slide-43
SLIDE 43

What else are arrays++?

  • Extra special combinators:
  • Easy to encode lambda calculus

( , , ) . ( , , [ ]) ( ) . ( , ) . ( [ ], [ ]) .

f

write a i v j ite i j v a j K v j v map a b j f a j b j I j j     ο€½ ο€½ ο€½ ο€½ ο€½

slide-44
SLIDE 44

What else are arrays++?

  • Encoding lambda terms into CAL+:
  • Where

[[ . ]] ( ,[[ ]]) ( , ) [[ ]] ( , ) ( ) [[( )]] ([[ ]],[[ ]]) ( , ( , )) ( ( , ), ( , ))

read f

x M tr x M tr x x I x x tr x y K y MN map M N tr x f M N map tr x M tr x N  ο€½ ο€½ ο€½ ο€½ ο€½ ο€½

, :: | . | ( ) M N x x M MN  ο€½

Exercise: encode lambda calculus without I

  • NB. Our procedure is going to assume that function passed to map is not from read.
slide-45
SLIDE 45

Example translation

[[ .(( .( )) )]] ( ,[[(( .( )) )]]) ( , ([[ .( )]],[[ ]])) ( , ([[ .( )]], )) ( , ( ( ,[[( )]]), )) ( , ( ( , ( , )), )) ( , ( ( (

read

read read read read read read map

x y yx x tr x y yx x tr x map y yx x tr x map y yx x tr x map tr y yx x tr x map tr y map y x x tr x map map tr      ο€½ ο€½ ο€½ ο€½ ο€½ ο€½ ( , ( ( , ( )), )) ( ( , ( , ( ))), ( , )) ( ( ( , ), ( , ( )))), ) ( ( ( ), ( , ( )))), ) , ), ( , ))), ))

read read read read mapread read mapread

read map map map map map map map ma

tr x map map I K x x map tr x map I K x tr x x map map tr x I tr x K x I map map K I tr x K x I map y y tr y x x ο€½ ο€½ ο€½ ο€½ ο€½ ( ( ( ), ( ( , ))), ) ( ( ( ), ( )), )

read mapread read mapread

p map K map map K

map K I map tr x x I map map K I map I I ο€½

slide-46
SLIDE 46

… But there are arrays#:

  • Restricted theory using I.
  • Then:
  • Theory of arrays# is decidable.

( ) . ( , , ) . ( [ ], [ ], [ ]) ( , ) .( [ ] [ ]) .

ite

K v j v map a b c j ite a j b j c j map a b j a j b j I j j    

ο€½

ο€½ ο€½ ο€½ ο€½ ο€½

( , , ) ( ( ( ), ), ( ), )

ite

write a i v map map K i I K v a

ο€½

ο€½

slide-47
SLIDE 47

Last combinator for the road…

  • Can I access a default array value?

( ) ( ( )) ( ( , )) ( ( ), ( )) ( ( , , )) ( )

f

a default K v v map a b f a b write a i v a        ο€­ ο€½ ο€½ ο€½

Only sound for infinite domains

slide-48
SLIDE 48

Let’s use CAL:

  • Simple set and bag operations:
  • But not cardinality |A|, power-set 2A, …

min

(0) ( ) { } ( , ,1) { } ( , , ) ( , ) [ ] [ ] ( , ) ( , ) ( , ) ( , ) ( ) ( ( ) 0) ( ) ( ( ) )

Bag Bag

K K false a write a a write a true mult a A A a a A A a A B map A B A B map A B A B map A B A B map A B finite A A finite A A false  

 οƒš 

    οƒŽ οƒ… οƒˆ   ο€½ ο€½

slide-49
SLIDE 49

CAL: Arrays as Combinators

  • McCarthy Arrays:

store/select

  • Array

combinators:

  • Takeaway: A common procedure for Array

Combinators

π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑑𝑒𝑝𝑠𝑓 𝑏, 𝑗, 𝑀 , 𝑗) = 𝑀 𝑗 β‰  π‘˜ β‡’ π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑑𝑒𝑝𝑠𝑓 𝑏, 𝑗, 𝑀 , π‘˜) = π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑏, π‘˜) 𝑑𝑒𝑝𝑠𝑓 𝑏, 𝑗, 𝑀 ∢= πœ‡π‘˜. π’‹π’ˆ 𝑗 = π‘˜ π’–π’Šπ’‡π’ 𝑀 π’‡π’Žπ’•π’‡ π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑏, π‘˜) π‘‘π‘π‘œπ‘‘π‘’ 𝑀 ≔ πœ‡π‘—. 𝑀 π‘›π‘π‘žπ‘” 𝑏, 𝑐 ≔ πœ‡π‘—. 𝑔(π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑏, 𝑗 , π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑐, 𝑗 )

slide-50
SLIDE 50

A reduction-based approach

( )?

Array

Sat T οͺ  ( ( ) )?

Equality Array

Sat T Closure οͺ οͺ  

Use saturation rules to reduce arrays to the theory of un-interpreted functions Extract models for arrays as finite graphs

slide-51
SLIDE 51

Deciding store

For every sub-term 𝑑𝑒𝑝𝑠𝑓(𝑏, 𝑗, 𝑀), every index π‘˜ in πœ’, add equation to πœ’:

π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑑𝑒𝑝𝑠𝑓 𝑏, 𝑗, 𝑀 , π‘˜ = π’‹π’ˆ 𝑗 = π‘˜ π’–π’Šπ’‡π’ 𝑀 π’‡π’Žπ’•π’‡ π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑏, π‘˜

EUF model of πœ’ => Array Model: For each array a define

𝑁𝑏𝑠𝑠𝑏𝑧 𝑏 ∢= { 𝑁(𝑗) β†’ 𝑁(π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑏, 𝑗)), π‘“π‘šπ‘‘π‘“ β†’ 𝑡𝒃 }

where select(a,i) occurs in πœ’.

slide-52
SLIDE 52

Deciding store

For each array a in πœ’ define

𝑁𝑏𝑠𝑠𝑏𝑧 𝑏 ∢= { 𝑁(𝑗) β†’ 𝑁(π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑏, 𝑗)), π‘“π‘šπ‘‘π‘“ β†’ 𝑡𝒃 }

Does M satisfy axioms for store?

𝑁(𝑑𝑒𝑝𝑠𝑓(𝑏, 𝑗, 𝑀)) = πœ‡ π‘˜. π’‹π’ˆ 𝑁(𝑗) = π‘˜ π’–π’Šπ’‡π’ 𝑁(𝑀) π’‡π’Žπ’•π’‡ 𝑁(π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑏, π‘˜)) Recall, we added π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑑𝑒𝑝𝑠𝑓 𝑏, 𝑗, 𝑀 , π‘˜ = π’‹π’ˆ 𝑗 = π‘˜ π’–π’Šπ’‡π’ 𝑀 π’‡π’Žπ’•π’‡ π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑏, π‘˜ Thus, 𝑁(π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑑𝑒𝑝𝑠𝑓 𝑏, 𝑗, 𝑀 , π‘˜ ) = 𝑁 π’‹π’ˆ 𝑗 = π‘˜ π’–π’Šπ’‡π’ 𝑀 π’‡π’Žπ’•π’‡ π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑏, π‘˜ = π’‹π’ˆ 𝑁(𝑗) = 𝑁(π‘˜) π’–π’Šπ’‡π’ 𝑁(𝑀) π’‡π’Žπ’•π’‡ 𝑁(π‘‘π‘“π‘šπ‘“π‘‘π‘’(𝑏, π‘˜))

slide-53
SLIDE 53

Extesionality

βˆ€π‘, 𝑐 βˆ€π‘— . π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑏, 𝑗 = π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑐, 𝑗 β‡’ 𝑏 = 𝑐

Not automatically satisfied by basic decision procedure. Skolemized:

βˆ€π‘, 𝑐 π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑏, πœ€(𝑏, 𝑐) = π‘‘π‘“π‘šπ‘“π‘‘π‘’ 𝑐, πœ€(𝑏, 𝑐) β‡’ 𝑏 = 𝑐

Add instance for every pair a, b.

slide-54
SLIDE 54

More Efficiently Deciding store

  • a~b – a and b are equal in current context
  • a≑t – a is a name for the term t
slide-55
SLIDE 55

What makes it more Efficient?

  • Axioms for store are only added

by the model induced by EUF

slide-56
SLIDE 56

Bottlenecks

  • Extensionality axiom

is instantiated on every pair of array variables.

  • Upwards propagation

distributes index over all modifications of same array.

slide-57
SLIDE 57

Bottlenecks and

Bottleneck: Extensionality axiom is instantiated on every pair of array variables.

Optimization: Restrict to variables asserted different, or shared.

slide-58
SLIDE 58

Bottlenecks and

  • Bottleneck: Upwards

propagation distributes index over all modifications of same array.

  • Optimization: Only use

 for updates where ancestor has multiple

  • children. Formulas from

programs are well- behaved.

slide-59
SLIDE 59

Saturating K, map, 

slide-60
SLIDE 60

Algebraic Data types

slide-61
SLIDE 61

Scalars, Tuples and Composites

Fruit = Apple | Orange | Banana Person = { name : String, age : Int, sex : M | F } IntOption = Some of { ofSome : Int } | None

slide-62
SLIDE 62

Recursive and Mutual Recursive types

List = Nil | Cons of { head : Int, tail : List } Ping = DropP | WinP | Pi of { pong : Pong } Pong = WinP | DropP | Po of { ping : Pong }

slide-63
SLIDE 63

ADTs: Algebraic Data-types

  • Constructors are injective:

– head(cons(x,xs)) = x – tail(cons(x,xs)) = xs

  • Terms are well-founded:

– 𝑦𝑑 β‰  π‘‘π‘π‘œπ‘‘ 𝑦, 𝑦𝑑 – 𝑦𝑑 β‰  π‘‘π‘π‘œπ‘‘(𝑦, π‘‘π‘π‘œπ‘‘ 𝑧, 𝑦𝑑 ) – 𝑦𝑑 β‰  π‘‘π‘π‘œπ‘‘(𝑦, π‘‘π‘π‘œπ‘‘ 𝑧, π‘‘π‘π‘œπ‘‘(𝑨, 𝑦𝑑 )) – 𝑦𝑑 β‰  π‘‘π‘π‘œπ‘‘(𝑦, π‘‘π‘π‘œπ‘‘ 𝑧, π‘‘π‘π‘œπ‘‘(𝑨, π‘‘π‘π‘œπ‘‘(𝑣, 𝑦𝑑 )))

slide-64
SLIDE 64

ADTs

  • Outline of a decision Procedure:

– Force injectivity:

  • For cons(t1,t2) add lemmas:

– head(cons(t1,t2)) = t1 – tail(cons(t1,t2)) = t2

– Build pre-model for constants of data-type sort.

  • x = Nil y = Nil z = Nil

– Perform occurs check in each equivalence class.

  • Q: can there be two constructors in an equivalence

class?