Towards Coinductive Theory Exploration Katya Komendantskaya (joint - - PowerPoint PPT Presentation

towards coinductive theory exploration
SMART_READER_LITE
LIVE PREVIEW

Towards Coinductive Theory Exploration Katya Komendantskaya (joint - - PowerPoint PPT Presentation

Towards Coinductive Theory Exploration Katya Komendantskaya (joint work with Yue Li, Henning Basold, John Power et al.) Workshop WAIT18, 29 June 2018 Outline Problem statement Solution Technical details FOL, Coinductively Any theory


slide-1
SLIDE 1

Towards Coinductive Theory Exploration

Katya Komendantskaya (joint work with Yue Li, Henning Basold, John Power et al.) Workshop WAIT’18, 29 June 2018

slide-2
SLIDE 2

Outline

Problem statement Solution Technical details

slide-3
SLIDE 3

FOL, Coinductively

◮ Any theory expressed in FOL may be seen inductively or

coinductively,

◮ Depending on the chosen semantics

For example...

slide-4
SLIDE 4

Given a theory in Horn Clause syntax:

G ::= ⊤ | A | G ∧G | G ∨G | ∃Var G D ::= A | G ⊃ D | D ∧D | ∀Var D

slide-5
SLIDE 5

Given a theory in Horn Clause syntax:

G ::= ⊤ | A | G ∧G | G ∨G | ∃Var G D ::= A | G ⊃ D | D ∧D | ∀Var D

Coinductive models of theories in Horn Clause logic

◮ Take the sets of (finite and/or infinite) ground terms ◮ The coinductive model is the largest set of such terms such that it

satisfies the given theory

◮ (The Inductive model is the smallest such set) ◮ Usually these models are given by fixed point (Knaster-Tarski)

construction

slide-6
SLIDE 6

Given a theory in Horn Clause syntax:

G ::= ⊤ | A | G ∧G | G ∨G | ∃Var G D ::= A | G ⊃ D | D ∧D | ∀Var D

Coinductive models of theories in Horn Clause logic

◮ Take the sets of (finite and/or infinite) ground terms ◮ The coinductive model is the largest set of such terms such that it

satisfies the given theory

◮ (The Inductive model is the smallest such set) ◮ Usually these models are given by fixed point (Knaster-Tarski)

construction least fixed point greatest fixed point finite terms Least Herbrand models Greatest Herbrand models finite and infi- nite terms Least Complete Herbrand models Greatest Complete Herbrand models

slide-7
SLIDE 7

Example 1

◮ Both inductive and coinductive semantics may suit

Example

κ1 : ∀x,nat x ⊃ nat (s x) κ2 : nat 0

least fixed point greatest fixed point finite terms {nat 0,nat(s 0),...} {nat 0,nat(s 0),...} finite and infinite terms {nat 0,nat(s 0),...} {nat 0,nat(s 0),...,sω}

slide-8
SLIDE 8

Example 2

◮ ... only coinductive semantics may suit

Example

κ1 : ∀x,streamZ x ⊃ streamZ (scons 0 x)

least fixed point greatest fixed point finite terms / / finite and infinite terms / {streamZ(scons 0(scons 0 ...))}

slide-9
SLIDE 9

Example 3

◮ Either semantics may work well for certain fragment of the

theory

Example

κ1 : ∀x,nat x ⊃ nat (s x) κ2 : nat 0 κ3 : ∀x,nat x ∧streamN y ⊃ streamN (scons x y)

least fixed point greatest fixed point finite terms {nat 0,nat(s 0),...} {nat 0,nat(s 0),...} finite and infinite terms {nat 0,nat(s 0),...} {nat 0,nat(s 0),...,sω, streamN(scons 0(scons 0 ...)), streamN(scons 0(scons 1 ...)), streamN(scons 1(scons 0 ...)), streamN(scons 1(scons 1 ...)), ...}

slide-10
SLIDE 10

Operational semantics:

◮ State of the art is automated invariant discovery by means of

loop detection

Example

∀x,streamZ x ⊃ streamZ (scons 0 x) Resolution-based search: streamZ x x/(scons 0 x′) streamZ x′

◮ Terminate the loop with x = (scons 0 x). ◮ It is the coinductive invariant.

slide-11
SLIDE 11

Operational semantics:

◮ State of the art is automated invariant discovery by means of

loop detection

Example

∀x,streamZ x ⊃ streamZ (scons 0 x) Resolution-based search: streamZ x x/(scons 0 x′) streamZ x′

◮ Terminate the loop with x = (scons 0 x). ◮ It is the coinductive invariant.

Recall:

least fixed point greatest fixed point finite terms / / finite and infinite terms / {streamZ(scons 0(scons 0 ...))}

slide-12
SLIDE 12

However, loop detection

◮ ... is not a very satisfactory solution

slide-13
SLIDE 13

Why unsatisfactory?

1 it fails too often

Example

∀x,from (s x) y ⊃ from x (scons x y) Resolution-based search: from 0 x x/(scons 0 x′) from (s 0) x′

◮ No unifier exists, ◮ loop detection fails to find coinductive invariant

slide-14
SLIDE 14

Why unsatisfactory?

1 it fails too often

Example

∀x,from (s x) y ⊃ from x (scons x y) Resolution-based search: from 0 x x/(scons 0 x′) from (s 0) x′

◮ No unifier exists, ◮ loop detection fails to find coinductive invariant

least fixed point greatest fixed point finite terms / / finite and infinite terms / {from 0(scons 0(scons (s0) ...))}

slide-15
SLIDE 15

Why unsatisfactory?

2 it is a bad indicator for coinductive meaning of the theory (Works well with existential, but not universal coinductive models )

slide-16
SLIDE 16

Universal Coinductive Models

Example

κ1 : ∀x,p(f x) ⊃ p x

least fixed point greatest fixed point finite terms / {p a,p(f a),p(f f a),...} finite and infinite terms / {p a,p(f a),p(f f a),... p f ω }

slide-17
SLIDE 17

Universal Coinductive Models

Example

κ1 : ∀x,p(f x) ⊃ p x

least fixed point greatest fixed point finite terms / {p a,p(f a),p(f f a),...} finite and infinite terms / {p a,p(f a),p(f f a),... p f ω }

Invariant search: p x → p(f x) → p(f f x) → ...

◮ The answer is: x = f x. ◮ However, f ω is not all that there is in the model!

slide-18
SLIDE 18

Universal Coinductive Models

Example

κ1 : ∀x,p(f x) ⊃ p x

least fixed point greatest fixed point finite terms / {p a,p(f a),p(f f a),...} finite and infinite terms / {p a,p(f a),p(f f a),... p f ω }

Invariant search: p x → p(f x) → p(f f x) → ...

◮ The answer is: x = f x. ◮ However, f ω is not all that there is in the model!

p a → p(f a) → p(f f a) → ...

◮ fails to find a loop

slide-19
SLIDE 19

Outline

Problem statement Solution Technical details

slide-20
SLIDE 20

Solution?

◮ Recast the problem of invariant search as a problem of

coinductive theory exploration

slide-21
SLIDE 21

Example 1

Example

∀x,streamZ x ⊃ streamZ (scons 0 x) Resolution-based search: streamZ x x/(scons 0 x′) streamZ x′

✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭✭ ✭

Terminate the loop with x = (scons 0 x).

✭✭✭✭✭✭✭✭✭✭✭✭✭ ✭

It is the coinductive invariant.

◮ Find and prove streamZ(zstream) ◮ for zstream = fixλ x.scons 0 x

slide-22
SLIDE 22

Example 2

Example

κ1 : ∀x,p(f x) ⊃ p x p a → p(f a) → ...

◮ ✭✭✭✭✭✭✭✭

fails to find a loop

◮ Find and prove ∀ x, p x ◮ Get p a as a corollary

slide-23
SLIDE 23

Outline

Problem statement Solution Technical details

slide-24
SLIDE 24

Uniform proofs [Miller et al.]

◮ give proof-theoretic interpretation to goal-oriented proof

search

◮ Uniform: – one rule applies at every stage of the proof ◮ Proven to be a fragment of intuitionistic logic

slide-25
SLIDE 25

Uniform proofs [Miller et al.]

◮ give proof-theoretic interpretation to goal-oriented proof

search

◮ Uniform: – one rule applies at every stage of the proof ◮ Proven to be a fragment of intuitionistic logic

FOHH and HOHH

G ::= ⊤ | A | G ∧G | G ∨G | ∃Var G | D ⊃ G | ∀Var G D ::= A | G ⊃ D | D ∧D | ∀Var D

FOHC and HOHC

G ::= ⊤ | A | G ∧G | G ∨G | ∃Var G D ::= A | G ⊃ D | D ∧D | ∀Var D

slide-26
SLIDE 26

Logical rules

Σ;P − → ⊤ ⊤R Σ;P − → G1 Σ;P − → G2 Σ;P − → G1 ∧G2 ∧R Σ;P − → G1 Σ;P − → G1 ∨G2 ∨R Σ;P − → G2 Σ;P − → G1 ∨G2 ∨R Σ;P,D − → G Σ;P − → D ⊃ G ⊃R c : τ,Σ;P − → G [x := c] Σ;P − → ∀τx G ∀R Σ;P − → G [x := N] Σ;P − → ∃τx G ∃R

slide-27
SLIDE 27

Backchaining (resolution) rules

. . . Σ;P

D

− → A Σ;P − → A Decide Σ;P

D

− → A Σ;P − → G Σ;P G⊃D − → A ⊃ L Σ;P

D[x:=N]

− → A Σ, / 0 ⊢ N : τ Σ;P ∀τx D − → A ∀L

slide-28
SLIDE 28

COFIX rule for uniform proofs

Σ;P,M − → M Σ;P M cofix

slide-29
SLIDE 29

COFIX rule for uniform proofs

Σ;P,M − → M Σ;P M cofix the guarding modality M must be discharged to get M (this can be done if M is resolved (= pattern matched) against a clause in P). The successful proof ends with Σ;P,M − → M.

slide-30
SLIDE 30

Lucky case: trivial coinductive invariant

Example

κ1 : ∀x,p x ⊃ p x Find invariant for: p a − → p a − → ...?

slide-31
SLIDE 31

Lucky case: trivial coinductive invariant

Example

κ1 : ∀x,p x ⊃ p x Find invariant for: p a − → p a − → ...?

least fixed point greatest fixed point finite terms / {p a} finite and infinite terms / {p a}

slide-32
SLIDE 32

Lucky case: trivial coinductive invariant

Example

κ1 : ∀x,p x ⊃ p x Find invariant for: p a − → p a − → ...?

Initial

P;p a

p a

− → p a

Initial

P;p a

p a

− → p a

⊃ L

P;p a

p a⊃p a

− → p a

∀L

P;p a

∀x,p x⊃p x

− → p a

DECIDE

P;p a − → p a

COFIX

P p a

slide-33
SLIDE 33

Lucky case: trivial coinductive invariant

Example

κ1 : ∀x,p x ⊃ p x Find invariant for: p a − → p a − → ...?

Initial

P;p a

p a

− → p a

Initial

P;p a

p a

− → p a

⊃ L

P;p a

p a⊃p a

− → p a

∀L

P;p a

∀x,p x⊃p x

− → p a

DECIDE

P;p a − → p a

COFIX

P p a

QUIZ: which logic does this coinductive hypothesis and prove live in?

slide-34
SLIDE 34

Not so lucky case: universal coinductive invariant

Example

κ1 : ∀x,p(f x) ⊃ p x Find invariant for: p(a) − → p(f a) − → p(f f a) − → ...?

slide-35
SLIDE 35

Not so lucky case: universal coinductive invariant

Example

κ1 : ∀x,p(f x) ⊃ p x Find invariant for: p(a) − → p(f a) − → p(f f a) − → ...?

Initial

P;p a

p a

− → p(a)

???

P;p a − → p(f a)

⊃ L

P;p a

p(f a)⊃p a

− → p a

∀L

P;p a

∀x,p(f x)⊃p x

− → p a

DECIDE

P;p a − → p a

COFIX

P p a

slide-36
SLIDE 36

Not so lucky case: universal coinductive invariant

Example

κ1 : ∀x,p(f x) ⊃ p x Find invariant for: p a − → p(f a) − → ...?

Initial

P;∀x,p x

p a

− → p a

Initial

P;∀x,p x

p (f a)

− → p (f a)

∀L

P;∀x,p x

∀x,p x

− → p (f a)

DECIDE

P;∀x,p x − → p (f a)

⊃ L

P;∀x,p x

p (f a)⊃p a

− → p a

∀L

P;∀x,p x

∀x,p(f (x))⊃p x

− → p a

DECIDE

P;∀x,p x − → p a

∀R

P;∀x,p x − → ∀x,p x

co-fix

P ∀x,p x

slide-37
SLIDE 37

Not so lucky case: universal coinductive invariant

Example

κ1 : ∀x,p(f x) ⊃ p x Find invariant for: p a − → p(f a) − → ...?

Initial

P;∀x,p x

p a

− → p a

Initial

P;∀x,p x

p (f a)

− → p (f a)

∀L

P;∀x,p x

∀x,p x

− → p (f a)

DECIDE

P;∀x,p x − → p (f a)

⊃ L

P;∀x,p x

p (f a)⊃p a

− → p a

∀L

P;∀x,p x

∀x,p(f (x))⊃p x

− → p a

DECIDE

P;∀x,p x − → p a

∀R

P;∀x,p x − → ∀x,p x

co-fix

P ∀x,p x

Finally, get (p a) as a corollary. ... QUIZ!

slide-38
SLIDE 38

Unlucky case: implicative coinductive invariant

Example

κ1 : ∀x,p(f x)∧q x ⊃ p x κ2 : q(a); κ3 : ∀x,q x ⊃ q(f x) Find invariant for: p a

apply κ1

− → p(f a)∧q a

apply κ2

− → p(f a)

apply κ1

− → p(f f a)∧q(f a)

apply κ3

− → p(f f a)∧q a − → ...?

slide-39
SLIDE 39

Unlucky case: implicative coinductive invariant

Example

κ1 : ∀x,p(f x)∧q x ⊃ p x κ2 : q(a); κ3 : ∀x,q x ⊃ q(f x) Find invariant for: p a

apply κ1

− → p(f a)∧q a

apply κ2

− → p(f a)

apply κ1

− → p(f f a)∧q(f a)

apply κ3

− → p(f f a)∧q a − → ...?

least fixed point greatest fixed point finite terms {q a,q(f a), q(f f a),...} {p a,p (f a),p(f f a),... q a,q(f a), q(f f a),...} finite and infinite terms {q a,q(f a), q(f f a),...} {p a,p (f a),p(f f a),... p(f ω),q a,q(f a), q(f f a), ...q f ω }

slide-40
SLIDE 40

Unlucky case: implicative coinductive invariant

Example

κ1 : ∀x,p(f x)∧q x ⊃ p x κ2 : q(a); κ3 : ∀x,q x ⊃ q(f x) Find invariant for: p a

apply κ1

− → p(f a)∧q a

apply κ2

− → p(f a)

apply κ1

− → p(f f a)∧q(f a)

apply κ3

− → p(f f a)∧q a − → ...?

least fixed point greatest fixed point finite terms {q a,q(f a), q(f f a),...} {p a,p (f a),p(f f a),... q a,q(f a), q(f f a),...} finite and infinite terms {q a,q(f a), q(f f a),...} {p a,p (f a),p(f f a),... p(f ω),q a,q(f a), q(f f a), ...q f ω }

The only working coinductive invariant is ∀x,q x ⊃ p x, QUIZ!!!

slide-41
SLIDE 41

Final example

◮ frStr = fix λ f x.scons x (f (s x)) = fix λ f x.[ x,(f (s x))] INIT

P;CH

from C [C,frStr(s C)]

− → from C [C,frStr(s C)]

INIT

P;CH

from (s C) (frStr(s C))

− → from(s C) (frStr(s C))

∀L

P;CH CH − → from (s C)(frStr(s C))

DECIDE

P;CH − → from (s C) (frStr(s C))

⊃ L

P;CH

from (s C) (frStr(s C))⊃from C [C,frStr(s C)]

− → from C [C,frStr(s C)]

∀L

P;CH

∀x y,from(s x) y⊃from x [x,y]

− → from C [C,frStr(s C)]

DECIDE

P;CH − → from C [C,frStr(s C)]

fixβ-conversion

P;CH − → from C(frStr C)

∀R

P;CH − → ∀x,from x, (frStr x)

cofix

P − → ∀x,from x (frStr x)

slide-42
SLIDE 42

Final example

◮ frStr = fix λ f x.scons x (f (s x)) = fix λ f x.[ x,(f (s x))] INIT

P;CH

from C [C,frStr(s C)]

− → from C [C,frStr(s C)]

INIT

P;CH

from (s C) (frStr(s C))

− → from(s C) (frStr(s C))

∀L

P;CH CH − → from (s C)(frStr(s C))

DECIDE

P;CH − → from (s C) (frStr(s C))

⊃ L

P;CH

from (s C) (frStr(s C))⊃from C [C,frStr(s C)]

− → from C [C,frStr(s C)]

∀L

P;CH

∀x y,from(s x) y⊃from x [x,y]

− → from C [C,frStr(s C)]

DECIDE

P;CH − → from C [C,frStr(s C)]

fixβ-conversion

P;CH − → from C(frStr C)

∀R

P;CH − → ∀x,from x, (frStr x)

cofix

P − → ∀x,from x (frStr x)

◮ get from 0 (frStr 0) as a corollary

QUIZ!!!

slide-43
SLIDE 43

Current progress:

Analysis of coinductive properties of theories based on the language in which their coinductive invariants are expressed:

slide-44
SLIDE 44

Current progress:

Analysis of coinductive properties of theories based on the language in which their coinductive invariants are expressed:

Miller and Nadathur:

HOHH: Higher-order Hereditary Harrop Logic FOHH: First-order Hereditary Harrop Logic HOHH: Higher-order Horn Clause Logic FOHC: First-order Horn clause logic

slide-45
SLIDE 45

Current progress:

Analysis of coinductive properties of theories based on the language in which their coinductive invariants are expressed:

co-HOHH: Coinductive Higher-order Hereditary Harrop Logic co-FOHH: Coinductive First-order Hereditary Harrop Logic co-HOHC: Coinductive Higher-order Horn Clause Logic co-FOHC: Coinductive First-order Horn clause logic

slide-46
SLIDE 46

Coinductive Theory exploration

Universal Implicative shape with fixpoint terms 2018, Work in progress Universal implicative shape, no fixpoint terms [Fu et al., 2016] Atomic formula with fixpoint terms Loop detection [Guptaet al.,2007 ] Trivial shape E.g. p a [Lammel& Peyton Jones, 2005 ]

slide-47
SLIDE 47

Coinductive Theory exploration

Universal Implicative shape with fixpoint terms 2018, Work in progress Universal implicative shape, no fixpoint terms [Fu et al., 2016] Atomic formula with fixpoint terms Loop detection [Guptaet al.,2007 ] Trivial shape E.g. p a [Lammel& Peyton Jones, 2005 ]

  • QUIZ: where CoHipster’s lemmas would live?
slide-48
SLIDE 48

Thanks for your attention!