principles of robot autonomy iiweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf ·...

50
Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Upload: others

Post on 19-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Principles of Robot Autonomy IISpecifications, Model Checking, and Reactive Synthesis

Page 2: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Today’s itinerary

1/26/2020 AA 274B | Lecture 5 2

• Safety from the lens of formal methods

• Model checking & Reactive Synthesis

• Linear Temporal Logic

• Reactive synthesis from Linear Temporal Logic

• Limitations

Page 3: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Today’s itinerary

1/26/2020 AA 274B | Lecture 5 3

• Safety from the lens of formal methods

• Model checking & Reactive Synthesis

• Linear Temporal Logic

• Reactive synthesis from Linear Temporal Logic

• Limitations

Page 4: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

What does safety mean for Robotics?

Page 5: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis
Page 6: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Mathematically based technique for specification, development, and verification of

software and hardware systems.

Verification: Timing and Energy analysisSoftware: Embedded code

Formal Methods

Page 7: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Verification (model checking) :

Specification

Model

Verifier Yes / No

software

hardware

robot

Model satisfies specification?

Mathematically based technique for specification, development, and verification of

software and hardware systems.Robots?

Formal Methods

Page 8: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Formal methods(verification)

What does safety mean for robots?

Control Theory, Robotics, Machine Learning

+

Can we prove that autonomous cars are safe?

Page 9: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Church’s Problem• Alonzo Church at the “Summer Institute of Symbolic Logic”, Cornell

University, 1957:

“Given a requirement which a circuit is to satisfy, we may suppose the requirement expressed in some suitable logistic system which is an extension of restricted recursive arithmetic. The synthesis problem is then to find recursion equivalences representing a circuit that satisfies the given requirement (or alternatively, to determine that there is no such circuit).”

Alonzo Church (1903-1995)

Page 10: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Specification

Model

Verifier Yes / No

software

hardware

robot

Verification (model checking) :

Mathematically based technique for specification, development, and verification of

software and hardware systems.Robots?

Formal Methods

Page 11: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Specification

Model

Verifier Yes / No

software

hardware

robot

Mathematically based technique for specification, development, and verification of

software and hardware systems.Robots?

Reactive Synthesis (Church 1957):

Formal Methods

Page 12: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

ModelSpecificationReactiveSynthesis

Mathematically based technique for specification, development, and verification of

software and hardware systems.Robots?

Reactive Synthesis (Church 1957):

Formal Methods

Page 13: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Can we synthesize controller for autonomous cars are provably safe?

Formal methods(verification)

What does safety mean for robots?

Control Theory, Robotics, Machine Learning

+

Page 14: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Reactive Synthesis

• Automatically constructing correct systems from specifications from scratch.

1/26/2020 AA 274B | Lecture 4 14

Specification:Temporal behavior specified over input and output sequences

input

output

Reactive Synthesis

Reactive System/Controller

Reactive System:• Every step it reads

inputs and produces outputs synchronously

• Non-terminating behavior

Page 15: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Reactive Synthesis

Determine

• If there is a finite state system that realizes the specification (realizability).

• If a specification is realizable, how do you construct the system?

1/26/2020 AA 274B | Lecture 4 15

Page 16: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Reactive SynthesisChurch 1957:

• Introduced the reactive synthesis problem

Buchi + Landweber 1969:• Realizability is decidable.• If a winning strategy exists, then a finite state winning strategy exists.• Introduced a game view of the problem.

Rabin 1972: • Simpler solution to the game with Rabin Tree Automoton.

Pnueli + Rosner 1989: • Linear Temporal Logic Synthesis• GR1 Synthesis (Piterman, Pnueli, Sa’ar 2006)

1/26/2020 AA 274B | Lecture 4 16

Page 17: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Today’s itinerary

1/26/2020 AA 274B | Lecture 5 17

• Safety from the lens of formal methods

• Model checking & Reactive Synthesis

• Linear Temporal Logic

• Reactive synthesis from Linear Temporal Logic

• Limitations

Page 18: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Linear Temporal Logic𝜑 ∷= 𝑡𝑟𝑢𝑒 𝑎 𝜑1 ∧ 𝜑2 ¬𝜑 𝑿𝜑 | 𝜙1𝑼𝜑2

𝑎: atomic proposition

𝑿: 𝜑 is true at next step.

𝑼: 𝜑1 is true until 𝜑2 at some point becomes true.

1/26/2020 AA 274B | Lecture 4 18

…Atomic proposition:

arbitrary arbitrary arbitrary arbitrary

𝑎𝑎

…arbitrary arbitrary arbitrary arbitrary

𝑎𝑿𝑎Next step:

…𝑎 ∧ ¬𝑏 𝑎 ∧ ¬𝑏 𝑎 ∧ ¬𝑏 𝑏

arbitrary

𝑎 𝑼 𝑏Until:

Page 19: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Additional Operators𝑭 𝜑 ≔ 𝑡𝑟𝑢𝑒 𝑼 𝜑 𝜑 will become true at some point in the future.

𝑮 𝜑 ≔ ¬𝑭 ¬𝜑 𝜑 is always true.

1/26/2020 AA 274B | Lecture 4 19

Eventually/Future:

arbitrary

¬ 𝑎

𝑎

𝑭 𝑎

𝑮 𝑎Always/Globally:

¬ 𝑎 ¬ 𝑎 𝑎

𝑎 𝑎 𝑎 𝑎

Other combinations:• 𝑮𝑭 𝑎: infinitely often • 𝑭𝑮 𝑎: notion of stability• 𝑮 𝑎 → 𝑭 𝑏 : response

Page 20: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Linear Temporal Logic

‘Temporal’ refers to the underlying nature of time.• Linear temporal logic (LTL): each moment in time has a well-defined

successor moment.

• Branching temporal logic: reason about multiple possible time courses (parallelism) , e.g., computation tree logic (CTL).

1/26/2020 AA 274B | Lecture 4 20

Page 21: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Today’s itinerary

1/26/2020 AA 274B | Lecture 5 21

• Safety from the lens of formal methods

• Model checking & Reactive Synthesis

• Linear Temporal Logic

• Reactive synthesis from Linear Temporal Logic

• Limitations

Page 22: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Reactive Synthesis from Linear Temporal Logic𝐼 : input variables, 𝑂 : output variables

Game:

System chooses from 2𝑂.

Environment chooses from 2𝐼.

Infinite Play:𝑖0, 𝑖1, 𝑖2, …𝑜0, 𝑜1, 𝑜2, …

Infinite Behavior: 𝑖0 ∪ 𝑜0, 𝑖1 ∪ 𝑜1, 𝑖2 ∪ 𝑜2, …

Win: Behavior ⊨ spec

Specifications: LTL formula on 𝐼 ∪ 𝑂

Strategy: function 𝑓: 2𝐼 ∗ → 2𝑂

Amir Pnueli

Roni Rosner

Page 23: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

The Coffee Machine Problem:

“If the start button is pressed, then the system will immediately start grinding for the next two cycles and, then brewing for the next two cycles after that, coffee will be produced.”

The specification is unrealizable, because the environment can produce input that makes it impossible to satisfy both requirements at the same time.

Page 24: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Synthesizing Systems

Page 25: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis
Page 26: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

Given a formal specification, encoding the • objective, • environment model, synthesize a controller that is guaranteed to satisfy the specification.

GoalEnvironment Model

ControllerSynthesis

Page 27: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications:

ControllerSynthesis

At all times (something is true)

In the future (something is true)

- safety- some version of stability- surveillance (infinitely often)- fairness- response (if then else)

Page 28: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications

ControllerSynthesis

Page 29: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications

ControllerSynthesis

Non-deterministic Buchi Automoton

ExpTime

Page 30: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications

ControllerSynthesis

Non-deterministic Buchi Automoton

Determinize it

ExpTime

ExpTime

Page 31: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications

ControllerSynthesis

Non-deterministic Buchi Automoton

Determinize it

2-player game: system (what we control) & environment (all the thing that can go wrong)

ExpTime

ExpTime

Page 32: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications

ControllerSynthesis

Non-deterministic Buchi Automoton

Determinize it

2-player game: system (what we control) & environment (all the thing that can go wrong)

ExpTime

ExpTime

Polynomial Time

Page 33: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications

ControllerSynthesis

Non-deterministic Buchi Automoton

Determinize it

2-player game: system (what we control) & environment (all the thing that can go wrong)

ExpTime

ExpTime

Polynomial TimeProvably correct strategy

Counter-strategy

Page 34: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

Given a formal specification, encoding the • objective, • environment model, synthesize a controller that is guaranteed to satisfy the specification.

GoalEnvironment Model

ControllerSynthesis

Page 35: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis
Page 36: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

Given a formal specification, encoding the • objective, • environment model, • human modelsynthesize a controller that is guaranteed to satisfy the specification.

GoalEnvironment Model

ControllerSynthesis

Page 37: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Unrealizable

Realizable• Goal• Environment Model • Human Model

Temporal Logic Spec.

ControllerSynthesis

Page 38: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Unprotected Left Turn

S. Ghosh, D. Sadigh, P. Nuzzo, V. Raman, A. Donze, A. Sangiovanni-Vincentelli, S. Sastry, S. Seshia. Diagnosis and Repair for Synthesis from Signal Temporal Logic Specifications. HSCC 2016.

Page 39: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Unrealizable

MineAssumptions

𝜓𝑛𝑒𝑤 ≔ (𝜑 ∧ 𝜓𝑒𝑛𝑣) → 𝜓𝑠𝑦𝑠

φ

AssumptionMonitoring

auto = false

Realizable• Goal• Environment Model • Human Model

Temporal Logic Spec.

ControllerSynthesis

CounterstrategyGraph

𝝋

T

Wenchao Li

[TACAS’14]

Shromona Ghosh Vasu Raman

[HSCC’16]

Year: 2014

Page 40: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Today’s itinerary

1/26/2020 AA 274B | Lecture 5 40

• Safety from the lens of formal methods

• Model checking & Reactive Synthesis

• Linear Temporal Logic

• Reactive synthesis from Linear Temporal Logic

• Limitations

Page 41: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications:

ControllerSynthesis

1) Need discrete time and discrete space.

Page 42: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications:

ControllerSynthesis

1) Need discrete time and discrete space.

- Use Signal Temporal Logic Instead!

- Translate to Mixed-Integer Optimizations

Solution:

Page 43: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Controller Synthesis from Logic Specifications

GoalEnvironment Model

Temporal Logic Specifications:

ControllerSynthesis

1) Need discrete time and discrete space.2) Our human models were totally made-up!

Page 44: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Standard Critique

• Impractical:

2EXPTIME is a horrible complexity!

• Response:

2EXPTIME is just worst-case complexity.

Page 45: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Real Critique

• Algorithms not ready for practical implementation.

• Complete Specification- unrealistic.

• Construction from scratch- unrealistic.

Page 46: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Response

• Better algorithms.

• Incremental synthesis- with specification added incrementally.

• Compositional synthesis – synthesis from components.

Page 47: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Robotics Synthesis Tools: TuLiP(Caltech), LTLMoP(Cornell), RATSY, Lily (TU Graz), etc.Program Synthesis Tools: Sketch(MIT), Rosette(UW)Translation Tools: LTL2BA, Rabinizer(TU Munich)

Page 48: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Today’s itinerary

1/26/2020 AA 274B | Lecture 5 48

• Safety from the lens of formal methods

• Model checking & Reactive Synthesis

• Linear Temporal Logic

• Reactive synthesis from Linear Temporal Logic

• Limitations

Page 49: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Lots of stuff left out

1/26/2020 AA 274B | Lecture 4 49

• Metric temporal logic

• Combining optimization with reactive synthesis

• Probabilistic specifications

• Connection to task and motion planning

Page 50: Principles of Robot Autonomy IIweb.stanford.edu/class/cs237b/pdfs/lecture/lecture_6.pdf · Principles of Robot Autonomy II Specifications, Model Checking, and Reactive Synthesis

Next time

1/26/2020 AA 274B | Lecture 4 50

• More in depth discussion of model checking

• More in depth discussion of temporal logic

• Verification of Neural Networks