Revisiting Auxiliary Variables Stephan Merz joint work with Leslie - - PowerPoint PPT Presentation

revisiting auxiliary variables
SMART_READER_LITE
LIVE PREVIEW

Revisiting Auxiliary Variables Stephan Merz joint work with Leslie - - PowerPoint PPT Presentation

Revisiting Auxiliary Variables Stephan Merz joint work with Leslie Lamport Inria & LORIA, Nancy, France IFIP Working Group 2.2 Bordeaux, September 2017 Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 1 / 24 Specifications


slide-1
SLIDE 1

Revisiting Auxiliary Variables

Stephan Merz joint work with Leslie Lamport

Inria & LORIA, Nancy, France

IFIP Working Group 2.2

Bordeaux, September 2017

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 1 / 24

slide-2
SLIDE 2

Specifications of State Machines

Standard way of describing algorithms

◮ initial condition, next-state relation express what may happen ◮ fairness / liveness conditions assert what must happen

Part of the state may be hidden

◮ do not expose implementation details ◮ delimit observable behavior that should be implemented

Concrete syntax: TLA+

∃ ∃ ∃ ∃ ∃ ∃ x : Init ∧ [Next]vars ∧ L

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 2 / 24

slide-3
SLIDE 3

Refinement of State Machines

From high-level specification to concrete implementation

◮ executions of lower-level state machine coherent with specification ◮ formally: inclusion of set of (observable) state sequences

(∃ ∃ ∃ ∃ ∃ ∃ y : Impl) ⇒ (∃ ∃ ∃ ∃ ∃ ∃ x : Spec)

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 3 / 24

slide-4
SLIDE 4

Refinement of State Machines

From high-level specification to concrete implementation

◮ executions of lower-level state machine coherent with specification ◮ formally: inclusion of set of (observable) state sequences

(∃ ∃ ∃ ∃ ∃ ∃ y : Impl) ⇒ (∃ ∃ ∃ ∃ ∃ ∃ x : Spec)

Standard proof technique: refinement mapping

◮ reconstruct high-level internal state from low-level state

Impl ⇒ Spec { f/x }

◮ pointwise computation of internal state components Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 3 / 24

slide-5
SLIDE 5

Example: Compute the Maximum Input Value

First specification: store the set of all inputs

Init1

= inp = {} ∧ lastinp = −∞ ∧ max = −∞ Input1(x)

= inp′ = inp ∪ {x} ∧ lastinp′ = x ∧ max′ = Max(inp′) Next1

= ∃x ∈ Int : Input1(x) Spec1

= ∃ ∃ ∃ ∃ ∃ ∃ inp, lastinp : Init1 ∧ [Next1]inp,lastinp,max

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 4 / 24

slide-6
SLIDE 6

Example: Compute the Maximum Input Value

First specification: store the set of all inputs

Init1

= inp = {} ∧ lastinp = −∞ ∧ max = −∞ Input1(x)

= inp′ = inp ∪ {x} ∧ lastinp′ = x ∧ max′ = Max(inp′) Next1

= ∃x ∈ Int : Input1(x) Spec1

= ∃ ∃ ∃ ∃ ∃ ∃ inp, lastinp : Init1 ∧ [Next1]inp,lastinp,max

Second specification: store just the maximum value

Init2

= lastinp = −∞ ∧ max = −∞ Input2(x)

= lastinp′ = x ∧ max′ = IF x > max THEN x ELSE max Next2

= ∃x ∈ Int : Input2(x) Spec2

= ∃ ∃ ∃ ∃ ∃ ∃ lastinp : Init2 ∧ [Next2]lastinp,max

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 4 / 24

slide-7
SLIDE 7

Example: Compute the Maximum Input Value

First specification: store the set of all inputs

Init1

= inp = {} ∧ lastinp = −∞ ∧ max = −∞ Input1(x)

= inp′ = inp ∪ {x} ∧ lastinp′ = x ∧ max′ = Max(inp′) Next1

= ∃x ∈ Int : Input1(x) Spec1

= ∃ ∃ ∃ ∃ ∃ ∃ inp, lastinp : Init1 ∧ [Next1]inp,lastinp,max

Second specification: store just the maximum value

Init2

= lastinp = −∞ ∧ max = −∞ Input2(x)

= lastinp′ = x ∧ max′ = IF x > max THEN x ELSE max Next2

= ∃x ∈ Int : Input2(x) Spec2

= ∃ ∃ ∃ ∃ ∃ ∃ lastinp : Init2 ∧ [Next2]lastinp,max

What is the formal relationship between the two specifications?

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 4 / 24

slide-8
SLIDE 8

Proving Refinement

The two specifications are equivalent

◮ they generate same externally visible behaviors (variable max) Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 5 / 24

slide-9
SLIDE 9

Proving Refinement

The two specifications are equivalent

◮ they generate same externally visible behaviors (variable max)

Spec1 refines Spec2

1

prove invariant max = Max(inp)

2

use identical refinement mapping for variable lastinp Spec1 ∧ (max = Max(inp)) ⇒ Init2 ∧ [Next2]lastinp,max

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 5 / 24

slide-10
SLIDE 10

Proving Refinement

The two specifications are equivalent

◮ they generate same externally visible behaviors (variable max)

Spec1 refines Spec2

1

prove invariant max = Max(inp)

2

use identical refinement mapping for variable lastinp Spec1 ∧ (max = Max(inp)) ⇒ Init2 ∧ [Next2]lastinp,max

Spec2 refines Spec1

◮ holds semantically, but no refinement mapping ◮ cannot compute set of inputs given the maximum value Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 5 / 24

slide-11
SLIDE 11

Proving Refinement

The two specifications are equivalent

◮ they generate same externally visible behaviors (variable max)

Spec1 refines Spec2

1

prove invariant max = Max(inp)

2

use identical refinement mapping for variable lastinp Spec1 ∧ (max = Max(inp)) ⇒ Init2 ∧ [Next2]lastinp,max

Spec2 refines Spec1

◮ holds semantically, but no refinement mapping ◮ cannot compute set of inputs given the maximum value

Refinement mappings alone are incomplete

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 5 / 24

slide-12
SLIDE 12

Auxiliary Variables

Augment implementation, then construct refinement mapping

1

specific rules justifying auxiliary variables: Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ a : Impla

2

augmented specification refines high-level: Impla ⇒ ∃ ∃ ∃ ∃ ∃ ∃ x : Spec

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 6 / 24

slide-13
SLIDE 13

Auxiliary Variables

Augment implementation, then construct refinement mapping

1

specific rules justifying auxiliary variables: Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ a : Impla

2

augmented specification refines high-level: Impla ⇒ ∃ ∃ ∃ ∃ ∃ ∃ x : Spec

Two particular kinds of auxiliary variables

◮ history variables: record information about previous states ◮ prophecy variables: predict information about future states Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 6 / 24

slide-14
SLIDE 14

Auxiliary Variables

Augment implementation, then construct refinement mapping

1

specific rules justifying auxiliary variables: Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ a : Impla

2

augmented specification refines high-level: Impla ⇒ ∃ ∃ ∃ ∃ ∃ ∃ x : Spec

Two particular kinds of auxiliary variables

◮ history variables: record information about previous states ◮ prophecy variables: predict information about future states

Classic reference

  • M. Abadi, L. Lamport. The Existence of Refinement Mappings. TCS (1991).

◮ introduces history and prophecy variables ◮ proves completeness under certain conditions ◮ closely related: forward / backward simulations Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 6 / 24

slide-15
SLIDE 15

Outline

1

Refinement Mappings

2

History Variables

3

Simple Prophecy Variables

4

Arrays of Auxiliary Variables

5

Stuttering Variables

6

Establishing Completeness

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 7 / 24

slide-16
SLIDE 16

Record Information About Past States

Update history variable at every transition

Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Spec ∧ h = h0 ∧ [vars′ = vars ∧ h′ = f(h)]vars,h

◮ variable h does not occur in Spec, vars or h0 ◮ term f(h) does not contain h′ ◮ h0 is the initial value of the history variable ◮ f represents the update function applied at every observable step Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 8 / 24

slide-17
SLIDE 17

Record Information About Past States

Update history variable at every transition

Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Spec ∧ h = h0 ∧ [vars′ = vars ∧ h′ = f(h)]vars,h

◮ variable h does not occur in Spec, vars or h0 ◮ term f(h) does not contain h′ ◮ h0 is the initial value of the history variable ◮ f represents the update function applied at every observable step

Example: step counter

Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Spec ∧ h = 0 ∧ [vars′ = vars ∧ h′ = h + 1]vars,h

◮ similar: record the input values during executions of Spec2 Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 8 / 24

slide-18
SLIDE 18

Parameterized Refinement Mappings

Idea: many refinement mappings are better than one

1

introduce parameterized specification equivalent to low-level spec Impl ≡ ∃β ∈ S : PImpl(β)

2

define separate refinement mappings per parameter value ∀β ∈ S : PImpl(β) ⇒ Spec { f(β)/x }

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 9 / 24

slide-19
SLIDE 19

Parameterized Refinement Mappings

Idea: many refinement mappings are better than one

1

introduce parameterized specification equivalent to low-level spec Impl ≡ ∃β ∈ S : PImpl(β)

2

define separate refinement mappings per parameter value ∀β ∈ S : PImpl(β) ⇒ Spec { f(β)/x }

Example: introduce a downward counter

Impl

= n = 0 ∧ [n′ = n + 1]n ∧ ♦[n′ = n]n Spec

= n = 0 ∧ k ∈ N ∧ [k > 0 ∧ n′ = n + 1 ∧ k′ = k − 1]k,n Prove Impl ⇒ ∃ ∃ ∃ ∃ ∃ ∃ k : Spec

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 9 / 24

slide-20
SLIDE 20

Parameterized Refinement Mappings

Idea: many refinement mappings are better than one

1

introduce parameterized specification equivalent to low-level spec Impl ≡ ∃β ∈ S : PImpl(β)

2

define separate refinement mappings per parameter value ∀β ∈ S : PImpl(β) ⇒ Spec { f(β)/x }

Example: introduce a downward counter

Impl

= n = 0 ∧ [n′ = n + 1]n ∧ ♦[n′ = n]n Spec

= n = 0 ∧ k ∈ N ∧ [k > 0 ∧ n′ = n + 1 ∧ k′ = k − 1]k,n Prove Impl ⇒ ∃ ∃ ∃ ∃ ∃ ∃ k : Spec

1

  • bserve

Impl ≡ ∃m ∈ N : Impl ∧ (n ≤ m)

2

prove ∀m ∈ N : Impl ∧ (n ≤ m) ⇒ Spec { m − n/k }

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 9 / 24

slide-21
SLIDE 21

Completeness: Assume Impl ⇒ ∃

∃ ∃ ∃ ∃ ∃ x : Spec

1

Introduce a step counter h as a history variable

Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Implh

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 10 / 24

slide-22
SLIDE 22

Completeness: Assume Impl ⇒ ∃

∃ ∃ ∃ ∃ ∃ x : Spec

1

Introduce a step counter h as a history variable

Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Implh

2

Define parameterized low-level specification

PImpl(β)

= Implh ∧ (vars = β[h])

◮ β : sequence of states that “predicts” actual execution ◮

Impl ≡ ∃β ∈ [N → St] : PImpl(β) semantic reasoning

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 10 / 24

slide-23
SLIDE 23

Completeness: Assume Impl ⇒ ∃

∃ ∃ ∃ ∃ ∃ x : Spec

1

Introduce a step counter h as a history variable

Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Implh

2

Define parameterized low-level specification

PImpl(β)

= Implh ∧ (vars = β[h])

◮ β : sequence of states that “predicts” actual execution ◮

Impl ≡ ∃β ∈ [N → St] : PImpl(β) semantic reasoning

3

Define parameterized refinement mapping

◮ fix β ∈ [N → St] such that PImpl(β) holds ◮ because of refinement, there exists γβ ∈ [N → X] satisfying Spec Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 10 / 24

slide-24
SLIDE 24

Completeness: Assume Impl ⇒ ∃

∃ ∃ ∃ ∃ ∃ x : Spec

1

Introduce a step counter h as a history variable

Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Implh

2

Define parameterized low-level specification

PImpl(β)

= Implh ∧ (vars = β[h])

◮ β : sequence of states that “predicts” actual execution ◮

Impl ≡ ∃β ∈ [N → St] : PImpl(β) semantic reasoning

3

Define parameterized refinement mapping

◮ fix β ∈ [N → St] such that PImpl(β) holds ◮ because of refinement, there exists γβ ∈ [N → X] satisfying Spec ◮ conclude

∀β ∈ [N → St] : PImpl(β) ⇒ Spec { γβ[h] / x }

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 10 / 24

slide-25
SLIDE 25

Completeness: Assume Impl ⇒ ∃

∃ ∃ ∃ ∃ ∃ x : Spec

1

Introduce a step counter h as a history variable

Impl ≡ ∃ ∃ ∃ ∃ ∃ ∃ h : Implh

2

Define parameterized low-level specification

PImpl(β)

= Implh ∧ (vars = β[h])

◮ β : sequence of states that “predicts” actual execution ◮

Impl ≡ ∃β ∈ [N → St] : PImpl(β) semantic reasoning

3

Define parameterized refinement mapping

◮ fix β ∈ [N → St] such that PImpl(β) holds ◮ because of refinement, there exists γβ ∈ [N → X] satisfying Spec ◮ conclude

∀β ∈ [N → St] : PImpl(β) ⇒ Spec { γβ[h] / x }

Related to Hesselink’s eternity variables

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 10 / 24

slide-26
SLIDE 26

Outline

1

Refinement Mappings

2

History Variables

3

Simple Prophecy Variables

4

Arrays of Auxiliary Variables

5

Stuttering Variables

6

Establishing Completeness

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 11 / 24

slide-27
SLIDE 27

Abadi-Lamport Prophecy Variables

Similar to history variables, with “time running backwards”

S = {} IsFiniteSet(S) Spec ⇒ (∀y ∈ S : f(y) ∈ S) Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ p : Spec ∧ (p ∈ S) ∧ [vars′ = vars ∧ p = f(p′)]vars,p

◮ variable p does not occur in Spec, vars or S ◮ f(y) does not contain p Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 12 / 24

slide-28
SLIDE 28

Abadi-Lamport Prophecy Variables

Similar to history variables, with “time running backwards”

S = {} IsFiniteSet(S) Spec ⇒ (∀y ∈ S : f(y) ∈ S) Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ p : Spec ∧ (p ∈ S) ∧ [vars′ = vars ∧ p = f(p′)]vars,p

◮ variable p does not occur in Spec, vars or S ◮ f(y) does not contain p

Differences to rule for history variables

◮ invariant “type condition” replaces initialization ◮ finiteness of S required for soundness (K¨

  • nig’s lemma)

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 12 / 24

slide-29
SLIDE 29

Abadi-Lamport Prophecy Variables

Similar to history variables, with “time running backwards”

S = {} IsFiniteSet(S) Spec ⇒ (∀y ∈ S : f(y) ∈ S) Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ p : Spec ∧ (p ∈ S) ∧ [vars′ = vars ∧ p = f(p′)]vars,p

◮ variable p does not occur in Spec, vars or S ◮ f(y) does not contain p

Differences to rule for history variables

◮ invariant “type condition” replaces initialization ◮ finiteness of S required for soundness (K¨

  • nig’s lemma)

Rule found to be difficult to apply in practice

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 12 / 24

slide-30
SLIDE 30

Prophesize Next Occurrence of an Action

Consider a system that repeatedly produces integer values

Init

= val = {} Prod(n)

= n / ∈ val ∧ val′ = val ∪ {n} Spec

= Init ∧ [∃n ∈ N : Prod(n)]val

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 13 / 24

slide-31
SLIDE 31

Prophesize Next Occurrence of an Action

Consider a system that repeatedly produces integer values

Init

= val = {} Prod(n)

= n / ∈ val ∧ val′ = val ∪ {n} Spec

= Init ∧ [∃n ∈ N : Prod(n)]val

Now predict the next value to be produced

Spec ⇒ ∃ ∃ ∃ ∃ ∃ ∃ p : Init ∧ p ∈ N ∧ [Prod(p) ∧ p′ ∈ N]val,p

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 13 / 24

slide-32
SLIDE 32

Prophesize Next Occurrence of an Action

Consider a system that repeatedly produces integer values

Init

= val = {} Prod(n)

= n / ∈ val ∧ val′ = val ∪ {n} Spec

= Init ∧ [∃n ∈ N : Prod(n)]val

Now predict the next value to be produced

Spec ⇒ ∃ ∃ ∃ ∃ ∃ ∃ p : Init ∧ p ∈ N ∧ [Prod(p) ∧ p′ ∈ N]val,p

Note: one need not be able to construct a prophecy variable

◮ prophecy variables are used in proofs ◮ the augmented specification need not be implementable Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 13 / 24

slide-33
SLIDE 33

Simple Prophecy Variables: Introduction Rule

Predict the parameter of next occurrence of given action

S = {} Spec ⇒ [∀x : A(x) ⇒ x ∈ S]vars Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ p : ∧ Spec ∧ p ∈ S ∧ [∧ vars′ = vars ∧ IF ∃x : A(x) THEN A(p) ∧ p′ ∈ S ELSE p′ = p]vars,p

◮ A(x) an action without occurrences of p ◮ p predicts for which value A will occur next ◮ other actions leave p unchanged ◮ variant: predict which action will be performed next Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 14 / 24

slide-34
SLIDE 34

Simple Prophecy Variables: Introduction Rule

Predict the parameter of next occurrence of given action

S = {} Spec ⇒ [∀x : A(x) ⇒ x ∈ S]vars Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ p : ∧ Spec ∧ p ∈ S ∧ [∧ vars′ = vars ∧ IF ∃x : A(x) THEN A(p) ∧ p′ ∈ S ELSE p′ = p]vars,p

◮ A(x) an action without occurrences of p ◮ p predicts for which value A will occur next ◮ other actions leave p unchanged ◮ variant: predict which action will be performed next

Simple soundness proof

◮ suitable value for p determined at next occurrence of A ◮ if A doesn’t occur anymore, the value of p doesn’t matter Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 14 / 24

slide-35
SLIDE 35

Outline

1

Refinement Mappings

2

History Variables

3

Simple Prophecy Variables

4

Arrays of Auxiliary Variables

5

Stuttering Variables

6

Establishing Completeness

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 15 / 24

slide-36
SLIDE 36

Auxiliary Functions

Aggregate auxiliary variables in an array

S = {} ∀x ∈ S : Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ y : (y ∈ T) ∧ [v = v]y ∧ ASpec(x, y) Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ f : (f ∈ [S → T]) ∧ [v = v] f ∧ ∀x ∈ S : ASpec(x, f[x])

◮ y, f do not occur in v ◮ similar to introducing a Skolem function in predicate logic ◮ premise will be established by previous rules Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 16 / 24

slide-37
SLIDE 37

Auxiliary Functions

Aggregate auxiliary variables in an array

S = {} ∀x ∈ S : Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ y : (y ∈ T) ∧ [v = v]y ∧ ASpec(x, y) Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ f : (f ∈ [S → T]) ∧ [v = v] f ∧ ∀x ∈ S : ASpec(x, f[x])

◮ y, f do not occur in v ◮ similar to introducing a Skolem function in predicate logic ◮ premise will be established by previous rules

Generic principle for combining auxiliary variables

◮ natural application: parameterized verification problems ◮ can be used to justify original rule for prophecy variables Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 16 / 24

slide-38
SLIDE 38

Example

Extend the producer system by an explicit output action

Init

= val = {} ∧ out = none Prod(n)

= n / ∈ val ∧ val′ = val ∪ {n} ∧ out′ = out Out

= out′ ∈ val ∧ val′ = val \ {out′} Next

= (∃n ∈ N : Prod(n)) ∨ Out Spec

= Init ∧ [Next]val,out

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 17 / 24

slide-39
SLIDE 39

Example

Extend the producer system by an explicit output action

Init

= val = {} ∧ out = none Prod(n)

= n / ∈ val ∧ val′ = val ∪ {n} ∧ out′ = out Out

= out′ ∈ val ∧ val′ = val \ {out′} Next

= (∃n ∈ N : Prod(n)) ∨ Out Spec

= Init ∧ [Next]val,out

Now add the possibility of “undoing” production

Undo(n)

= val′ = val \ {n} ∧ out′ = out NextU

= Next ∨ ∃n ∈ N : Undo(n) SpecU

= Init ∧ [NextU]val,out

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 17 / 24

slide-40
SLIDE 40

Example

Extend the producer system by an explicit output action

Init

= val = {} ∧ out = none Prod(n)

= n / ∈ val ∧ val′ = val ∪ {n} ∧ out′ = out Out

= out′ ∈ val ∧ val′ = val \ {out′} Next

= (∃n ∈ N : Prod(n)) ∨ Out Spec

= Init ∧ [Next]val,out

Now add the possibility of “undoing” production

Undo(n)

= val′ = val \ {n} ∧ out′ = out NextU

= Next ∨ ∃n ∈ N : Undo(n) SpecU

= Init ∧ [NextU]val,out

Prove equivalence of ∃ ∃ ∃ ∃ ∃ ∃ val : SpecU and ∃ ∃ ∃ ∃ ∃ ∃ val : Spec

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 17 / 24

slide-41
SLIDE 41

Proving SpecU ⇒ ∃

∃ ∃ ∃ ∃ ∃ val : Spec

For every k ∈ N, predict if it will be output or not

Initp

= Init ∧ p ∈ {“out”, “undo”} Prodp(n)

= Prod(n) ∧ IF n = k THEN p′ ∈ {“out”, “undo”} ELSE p′ = p Outp

= Out ∧ (out′ = k ⇒ p = “out”) ∧ p′ = p Undop(n)

= Undo ∧ (n = k ⇒ p = “undo”) ∧ p′ = p NextUp

= Outp ∨ (∃n ∈ N : Prodp(n) ∨ Undop(n)) SpecUp

= Initp ∧ [NextUp]val,out,p

◮ use simple prophecy rule to prove ∀k ∈ N : SpecU ≡ ∃

∃ ∃ ∃ ∃ ∃ p : SpecUp

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 18 / 24

slide-42
SLIDE 42

Proving SpecU ⇒ ∃

∃ ∃ ∃ ∃ ∃ val : Spec

For every k ∈ N, predict if it will be output or not

Initp

= Init ∧ p ∈ {“out”, “undo”} Prodp(n)

= Prod(n) ∧ IF n = k THEN p′ ∈ {“out”, “undo”} ELSE p′ = p Outp

= Out ∧ (out′ = k ⇒ p = “out”) ∧ p′ = p Undop(n)

= Undo ∧ (n = k ⇒ p = “undo”) ∧ p′ = p NextUp

= Outp ∨ (∃n ∈ N : Prodp(n) ∨ Undop(n)) SpecUp

= Initp ∧ [NextUp]val,out,p

◮ use simple prophecy rule to prove ∀k ∈ N : SpecU ≡ ∃

∃ ∃ ∃ ∃ ∃ p : SpecUp

Use array rule to combine these predictions

SpecU ≡ ∃ ∃ ∃ ∃ ∃ ∃ f : (f ∈ [N → {“out”, “undo”}]) ∧ . . .

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 18 / 24

slide-43
SLIDE 43

Proving SpecU ⇒ ∃

∃ ∃ ∃ ∃ ∃ val : Spec

For every k ∈ N, predict if it will be output or not

Initp

= Init ∧ p ∈ {“out”, “undo”} Prodp(n)

= Prod(n) ∧ IF n = k THEN p′ ∈ {“out”, “undo”} ELSE p′ = p Outp

= Out ∧ (out′ = k ⇒ p = “out”) ∧ p′ = p Undop(n)

= Undo ∧ (n = k ⇒ p = “undo”) ∧ p′ = p NextUp

= Outp ∨ (∃n ∈ N : Prodp(n) ∨ Undop(n)) SpecUp

= Initp ∧ [NextUp]val,out,p

◮ use simple prophecy rule to prove ∀k ∈ N : SpecU ≡ ∃

∃ ∃ ∃ ∃ ∃ p : SpecUp

Use array rule to combine these predictions

SpecU ≡ ∃ ∃ ∃ ∃ ∃ ∃ f : (f ∈ [N → {“out”, “undo”}]) ∧ . . .

Finally, define suitable refinement mapping

SpecU f ⇒ Spec { (val \ {k ∈ N : f[k] = “undo”}) / val }

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 18 / 24

slide-44
SLIDE 44

Outline

1

Refinement Mappings

2

History Variables

3

Simple Prophecy Variables

4

Arrays of Auxiliary Variables

5

Stuttering Variables

6

Establishing Completeness

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 19 / 24

slide-45
SLIDE 45

Stuttering Steps and Refinement

Adjust for different granularity of atomic actions

◮ typically, refinement introduces lower-level detail ◮ low-level transitions are invisible at higher level ◮ TLA+ bakes stuttering invariance into the language Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 20 / 24

slide-46
SLIDE 46

Stuttering Steps and Refinement

Adjust for different granularity of atomic actions

◮ typically, refinement introduces lower-level detail ◮ low-level transitions are invisible at higher level ◮ TLA+ bakes stuttering invariance into the language

Occasionally, the high-level specification may take more steps

◮ toy example: clock specified with invisible seconds display ◮ more realistic: thread completes operation on behalf of another

Introduce explicit stuttering for defining refinement mapping

◮ Abadi-Lamport: stuttering combined with prophecy variables ◮ here: separate category of stuttering variables Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 20 / 24

slide-47
SLIDE 47

Proof Rule

Add stuttering steps in between visible transitions

s0 ∈ Nat

  • i∈I Spec ⇒ (sti ∈ N)

Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ s : Inits ∧

  • Dec ∨

i∈I As i

  • v,s ∧ L

◮ original specification

Spec ≡ Init ∧

i∈I Ai

  • v ∧ L

◮ initial stuttering

Inits

= Init ∧ s = s0

◮ stuttering after transition

As

i

= Ai ∧ s = 0 ∧ s′ = sti

◮ decrement variable s

Dec

= s > 0 ∧ s′ = s − 1 ∧ v′ = v

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 21 / 24

slide-48
SLIDE 48

Proof Rule

Add stuttering steps in between visible transitions

s0 ∈ Nat

  • i∈I Spec ⇒ (sti ∈ N)

Spec ≡ ∃ ∃ ∃ ∃ ∃ ∃ s : Inits ∧

  • Dec ∨

i∈I As i

  • v,s ∧ L

◮ original specification

Spec ≡ Init ∧

i∈I Ai

  • v ∧ L

◮ initial stuttering

Inits

= Init ∧ s = s0

◮ stuttering after transition

As

i

= Ai ∧ s = 0 ∧ s′ = sti

◮ decrement variable s

Dec

= s > 0 ∧ s′ = s − 1 ∧ v′ = v

Obvious generalizations

◮ allow for jumps instead of just counting down ◮ variable taking values in set with well-founded ordering Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 21 / 24

slide-49
SLIDE 49

Outline

1

Refinement Mappings

2

History Variables

3

Simple Prophecy Variables

4

Arrays of Auxiliary Variables

5

Stuttering Variables

6

Establishing Completeness

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 22 / 24

slide-50
SLIDE 50

Two Completeness Proofs

1

Predict low-level execution

◮ add a step counter to low-level specification ◮ use simple prophecy variables to predict n-th state ◮ combine these into function predicting low-level behavior ◮ choose high-level behavior and define refinement mapping 2

Predict high-level behavior

◮ use history variable to record finite prefixes of low-level behavior ◮ predict prefixes of high-level behavior compatible with all

low-level prefixes, then define refinement mapping

Remarks

◮ second approach: reasoning about finite prefixes suffices . . . ◮ . . . but “internal continuity” is necessary ◮ cf. AL’91: no machine closure or finite internal non-determinism Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 23 / 24

slide-51
SLIDE 51

Wrapping Up

New look at an old problem

◮ refinement mappings are very successful, but incomplete ◮ generalization to parameterized refinement mappings ◮ auxiliary variables can yield completeness results ◮ simple prophecy variables + arrays easier to apply ?

Validation of the approach

◮ catalogue of directly applicable TLA+ rules ◮ applied to toy examples and linearizability proofs ◮ formalization in Isabelle/HOL ongoing

Lamport, M.: Auxiliary Variables in TLA+. arXiv, 2017.

Stephan Merz Revisiting Auxiliary Variables WG 2.2, 2017-09 24 / 24