Interactive Proof for Diagrammatic Languages Aleks Kissinger - - PowerPoint PPT Presentation

interactive proof for diagrammatic languages
SMART_READER_LITE
LIVE PREVIEW

Interactive Proof for Diagrammatic Languages Aleks Kissinger - - PowerPoint PPT Presentation

Interactive Proof for Diagrammatic Languages Aleks Kissinger SamsonFest 2013 June 3, 2013 So monoids... So monoids... Consider a monoid ( A , , e ) : ( a b ) c = a ( b c ) a e = a = e a and So monoids... Consider


slide-1
SLIDE 1

Interactive Proof for Diagrammatic Languages

Aleks Kissinger

SamsonFest 2013

June 3, 2013

slide-2
SLIDE 2
slide-3
SLIDE 3
slide-4
SLIDE 4
slide-5
SLIDE 5

So monoids...

slide-6
SLIDE 6

So monoids...

◮ Consider a monoid (A, ·, e):

(a · b) · c = a · (b · c) and a · e = a = e · a

slide-7
SLIDE 7

So monoids...

◮ Consider a monoid (A, ·, e):

(a · b) · c = a · (b · c) and a · e = a = e · a

◮ Normally, an automated theorem prover would use these

equations as rewrite rules, e.g. (a · b) · c a · (b · c) a · e a e · a a

slide-8
SLIDE 8

So monoids...

◮ Consider a monoid (A, ·, e):

(a · b) · c = a · (b · c) and a · e = a = e · a

◮ Normally, an automated theorem prover would use these

equations as rewrite rules, e.g. (a · b) · c a · (b · c) a · e a e · a a

◮ It is also possible to write these equations as trees:

= a b c b c a = = a a a

slide-9
SLIDE 9

Monoids

◮ Since these equations are (left- and right-) linear in the free

variables, we can drop them: = a b c b c a ⇒ =

slide-10
SLIDE 10

Monoids

◮ Since these equations are (left- and right-) linear in the free

variables, we can drop them: = a b c b c a ⇒ =

◮ The role of variables is replaced by the notion that the LHS

and RHS have a shared boundary

slide-11
SLIDE 11

Diagram substitution

◮ One could apply the rule “(a · b) · c → a · (b · c)” using the

usual “instantiate, match, replace” style: w · ((x · (y · e)) · z) → w · (x · ((y · e) · z))

slide-12
SLIDE 12

Diagram substitution

◮ One could apply the rule “(a · b) · c → a · (b · c)” using the

usual “instantiate, match, replace” style: w · ((x · (y · e)) · z) → w · (x · ((y · e) · z))

◮ ...or by cutting the LHS directly out of the tree and gluing

in the RHS: w x y z x z w y ⇒ z w x y ⇒

slide-13
SLIDE 13

Diagram substitution

◮ One could apply the rule “(a · b) · c → a · (b · c)” using the

usual “instantiate, match, replace” style: w · ((x · (y · e)) · z) → w · (x · ((y · e) · z))

◮ ...or by cutting the LHS directly out of the tree and gluing

in the RHS: w x y z x z w y ⇒ z w x y ⇒

◮ This treats inputs and outputs symmetrically

slide-14
SLIDE 14

Algebra and coalgebra

◮ Coalgebra: algebraic structures “upside-down”

slide-15
SLIDE 15

Algebra and coalgebra

◮ Coalgebra: algebraic structures “upside-down” ◮ An example is a comonoid, which has a comultiplication

  • peration

and a counit satisfying: = = =

slide-16
SLIDE 16

Algebra and coalgebra

◮ Coalgebra: algebraic structures “upside-down” ◮ An example is a comonoid, which has a comultiplication

  • peration

and a counit satisfying: = = =

◮ Monoids and comonoids can interact in interesting ways,

for instance: Frobenius algebras: = Bialgebras: =

slide-17
SLIDE 17

Equational reasoning with diagram substitution

◮ As before, we can use graphical identities to perform

substitutions, but on graphs, rather than trees =

slide-18
SLIDE 18

Equational reasoning with diagram substitution

◮ As before, we can use graphical identities to perform

substitutions, but on graphs, rather than trees =

◮ For example:

⇒ ⇒

slide-19
SLIDE 19

Equational reasoning with diagram substitution

◮ As before, we can use graphical identities to perform

substitutions, but on graphs, rather than trees =

◮ For example:

⇒ ⇒

◮ This style of rewriting is sound and complete w.r.t. to

traced symmetric monoidal categories

slide-20
SLIDE 20

Diagrams with repetition

◮ In practice, many proofs concern infinite families of

expressions

slide-21
SLIDE 21

Diagrams with repetition

◮ In practice, many proofs concern infinite families of

expressions

◮ As an example, define the (m, n)-fold

multiplication/comultiplication as follows: ... ... := ... ...

slide-22
SLIDE 22

Diagrams with repetition

◮ In practice, many proofs concern infinite families of

expressions

◮ As an example, define the (m, n)-fold

multiplication/comultiplication as follows: ... ... := ... ...

◮ An equivalent axiomitisation of (commutative) Frobenius

algebras is: ... = ... ... ... ... ...

slide-23
SLIDE 23

!-boxes

◮ We can formalise this “meta” diagram using some

graphical syntax: ⇒ ... ...

slide-24
SLIDE 24

!-boxes

◮ We can formalise this “meta” diagram using some

graphical syntax: ⇒ ... ...

◮ The blue boxes are called !-boxes. A graph with !-boxes is

called a !-graph. Can be interpreted as a set of concrete graphs: = · · · , , , , , ,

slide-25
SLIDE 25

!-boxes

◮ The diagrams represented by a !-graph are all those

  • btained by performing EXPAND and KILL operations on

!-boxes

EXPANDb

= ⇒

KILLb

= ⇒

slide-26
SLIDE 26

!-boxes

◮ The diagrams represented by a !-graph are all those

  • btained by performing EXPAND and KILL operations on

!-boxes

EXPANDb

= ⇒

KILLb

= ⇒

◮ We can also introduce equations involving !-boxes:

... = ... ... ... ... ... ⇒ =

slide-27
SLIDE 27

!-boxes: matching

◮ !-boxes on the LHS are in 1-to-1 correspondence with RHS

=

slide-28
SLIDE 28

!-boxes: matching

◮ !-boxes on the LHS are in 1-to-1 correspondence with RHS

=

◮ EXPAND and KILL operations applied to both sides

simultaneously

slide-29
SLIDE 29

!-boxes: matching

◮ !-boxes on the LHS are in 1-to-1 correspondence with RHS

=

◮ EXPAND and KILL operations applied to both sides

simultaneously

◮ Rewriting concrete graphs: instantiate rule with EXPAND

and KILL, then rewriting as usual

slide-30
SLIDE 30

!-boxes: matching

◮ !-boxes on the LHS are in 1-to-1 correspondence with RHS

=

◮ EXPAND and KILL operations applied to both sides

simultaneously

◮ Rewriting concrete graphs: instantiate rule with EXPAND

and KILL, then rewriting as usual

◮ Sound and complete, in the absence of “wild” !-boxes

slide-31
SLIDE 31

!-boxes: exact matching

◮ What about using !-graph equations to rewrite other

!-graphs?

slide-32
SLIDE 32

!-boxes: exact matching

◮ What about using !-graph equations to rewrite other

!-graphs?

◮ Define an exact matching between !-graphs as an

embedding that respects the !-boxes: ֒ →

slide-33
SLIDE 33

!-boxes: exact matching

◮ What about using !-graph equations to rewrite other

!-graphs?

◮ Define an exact matching between !-graphs as an

embedding that respects the !-boxes: ֒ →

◮ However, there are other situations where one !-graph

generalises another

slide-34
SLIDE 34

!-boxes: inference rules

◮ Inference rules make new equations from old. Two

  • bvious ones:

G = H EXPANDb(G = H)exp G = H KILLb(G = H)kill

slide-35
SLIDE 35

!-boxes: inference rules

◮ Inference rules make new equations from old. Two

  • bvious ones:

G = H EXPANDb(G = H)exp G = H KILLb(G = H)kill

◮ ...and some less obvious ones:

G = H COPYb(G = H)cp G = H MERGEb,b′(G = H)mrg . . .

slide-36
SLIDE 36

Induction Principle for !-Graphs

◮ Let FIXb(G = H) be the same as G = H, but !-box b cannot

be expanded KILLb(G = H) FIXb(G = H) = ⇒ EXPANDb(G = H) G = H ind

slide-37
SLIDE 37

Induction Principle for !-Graphs

◮ Let FIXb(G = H) be the same as G = H, but !-box b cannot

be expanded

◮ Using FIX, we can define induction

KILLb(G = H) FIXb(G = H) = ⇒ EXPANDb(G = H) G = H ind

slide-38
SLIDE 38

Induction example

◮ Suppose we have these three equations:

= = =

(empty)

slide-39
SLIDE 39

Induction example

◮ Suppose we have these three equations:

= = =

(empty)

◮ ...then we can prove this using induction:

=

slide-40
SLIDE 40

Induction example

◮ First (reverse) apply induction to get two sub-goals:

= = (empty) = = ⇒ =

slide-41
SLIDE 41

Induction example

◮ First (reverse) apply induction to get two sub-goals:

= = (empty) = = ⇒ =

◮ The base case is an assumption, step case by rewriting:

=

assm assm

=

i.h.

=

slide-42
SLIDE 42

Constructing a diagrammatic proof assistant

◮ Why?

slide-43
SLIDE 43

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

slide-44
SLIDE 44

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

slide-45
SLIDE 45

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

◮ More expressive types of graphical languages ⇒ new proof

styles and techniques.

slide-46
SLIDE 46

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

◮ More expressive types of graphical languages ⇒ new proof

styles and techniques.

◮ Unique from an HCI perspective. Possibly unexpected

results.

slide-47
SLIDE 47

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

◮ More expressive types of graphical languages ⇒ new proof

styles and techniques.

◮ Unique from an HCI perspective. Possibly unexpected

results.

◮ Why not use terms?

slide-48
SLIDE 48

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

◮ More expressive types of graphical languages ⇒ new proof

styles and techniques.

◮ Unique from an HCI perspective. Possibly unexpected

results.

◮ Why not use terms?

◮ There is a term language, using ◦, ⊗, swap maps, etc.

slide-49
SLIDE 49

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

◮ More expressive types of graphical languages ⇒ new proof

styles and techniques.

◮ Unique from an HCI perspective. Possibly unexpected

results.

◮ Why not use terms?

◮ There is a term language, using ◦, ⊗, swap maps, etc. ◮ Many congruences

slide-50
SLIDE 50

Constructing a diagrammatic proof assistant

◮ Why?

◮ Diagrams are easier to understand, but easier to make

mistakes

◮ Want several layers of definition/abstraction (ex: quantum

circuits and error-correcting encodings)

◮ More expressive types of graphical languages ⇒ new proof

styles and techniques.

◮ Unique from an HCI perspective. Possibly unexpected

results.

◮ Why not use terms?

◮ There is a term language, using ◦, ⊗, swap maps, etc. ◮ Many congruences ◮ Simplest decision procedure: “draw the diagrams and

compare”

slide-51
SLIDE 51

Quantomatic: the good stuff

◮ Create, load, and save diagrams and rewrite rules

slide-52
SLIDE 52

Quantomatic: the good stuff

◮ Create, load, and save diagrams and rewrite rules ◮ Apply rewrite rules manually, or normalise w.r.t. subsets

  • f rewrite rules
slide-53
SLIDE 53

Quantomatic: the good stuff

◮ Create, load, and save diagrams and rewrite rules ◮ Apply rewrite rules manually, or normalise w.r.t. subsets

  • f rewrite rules

◮ Rewrites happen live, so proofs are easy to show off

slide-54
SLIDE 54

Quantomatic: the good stuff

◮ Create, load, and save diagrams and rewrite rules ◮ Apply rewrite rules manually, or normalise w.r.t. subsets

  • f rewrite rules

◮ Rewrites happen live, so proofs are easy to show off ◮ Education: Quantomatic-based labs for two years in

conjunction with Categorical Quantum Mechanics course at Oxford

slide-55
SLIDE 55

Quantomatic: limitations

◮ Once a proof is done, it’s gone. Only the result is left.

slide-56
SLIDE 56

Quantomatic: limitations

◮ Once a proof is done, it’s gone. Only the result is left. ◮ Only does rewriting, i.e. the purely equational part.

slide-57
SLIDE 57

Quantomatic: limitations

◮ Once a proof is done, it’s gone. Only the result is left. ◮ Only does rewriting, i.e. the purely equational part. ◮ Rewrite rules are used naively. No search/normalisation

strategies or Knuth-Bendix.

slide-58
SLIDE 58

The Quanto2013 Projects

◮ Quantomatic is a (fairly) thin GUI built on QuantoCore, an

ML based rewriting engine

◮ Starting this year, we are working on new projects based

  • n QuantoCore:

◮ QuantoDerive – graphical derivation editor, essentially the

successor to Quantomatic GUI

◮ QuantoCosy – conjecture synthesis for diagrams ◮ QuantoTactic – Quantomatic/Isabelle integration

slide-59
SLIDE 59

QuantoCosy

◮ Often, we have a concrete set of generators (e.g. a

particular example of some algebraic structure), and we would like to derive the axioms

◮ Take a set of generators:

, , , , , , , , , , ,

slide-60
SLIDE 60

QuantoCosy

◮ Often, we have a concrete set of generators (e.g. a

particular example of some algebraic structure), and we would like to derive the axioms

◮ Take a set of generators:

, , , , , , , , , , ,

◮ For each disconnected graph, enumerate all of the ways it

can be “plugged together”:

slide-61
SLIDE 61

QuantoCosy

◮ Often, we have a concrete set of generators (e.g. a

particular example of some algebraic structure), and we would like to derive the axioms

◮ Take a set of generators:

, , , , , , , , , , ,

◮ For each disconnected graph, enumerate all of the ways it

can be “plugged together”: →

slide-62
SLIDE 62

QuantoCosy

◮ Often, we have a concrete set of generators (e.g. a

particular example of some algebraic structure), and we would like to derive the axioms

◮ Take a set of generators:

, , , , , , , , , , ,

◮ For each disconnected graph, enumerate all of the ways it

can be “plugged together”: →

slide-63
SLIDE 63

QuantoCosy

◮ If we have concrete values for generators (e.g. as matrices),

we can define an evaluation function − on diagrams

slide-64
SLIDE 64

QuantoCosy

◮ If we have concrete values for generators (e.g. as matrices),

we can define an evaluation function − on diagrams

◮ We can organise diagrams into equivalence classes

G ≡ H ⇔ G = H

slide-65
SLIDE 65

QuantoCosy

◮ If we have concrete values for generators (e.g. as matrices),

we can define an evaluation function − on diagrams

◮ We can organise diagrams into equivalence classes

G ≡ H ⇔ G = H

◮ If we define a metric on graphs, some equivalences G ≡ H

will become redexes G H

slide-66
SLIDE 66

QuantoCosy

◮ If we have concrete values for generators (e.g. as matrices),

we can define an evaluation function − on diagrams

◮ We can organise diagrams into equivalence classes

G ≡ H ⇔ G = H

◮ If we define a metric on graphs, some equivalences G ≡ H

will become redexes G H

◮ In the ’Cosy style, we can use these redexes to cut down

the search space by only enumerating irreducible expressions

slide-67
SLIDE 67

QuantoCosy

slide-68
SLIDE 68

LCF-style Theorem Provers

◮ Theorem provers are large and complex. How can we be

(fairly) confident they fit our mathematical models?

slide-69
SLIDE 69

LCF-style Theorem Provers

◮ Theorem provers are large and complex. How can we be

(fairly) confident they fit our mathematical models?

◮ In 1972, Milner came up with the LCF approach to

automated theorem proving.

slide-70
SLIDE 70

LCF-style Theorem Provers

◮ Theorem provers are large and complex. How can we be

(fairly) confident they fit our mathematical models?

◮ In 1972, Milner came up with the LCF approach to

automated theorem proving.

◮ The idea: write a kernel that is dumb (simple logic + a few

inference rules) but sound

slide-71
SLIDE 71

LCF-style Theorem Provers

◮ Theorem provers are large and complex. How can we be

(fairly) confident they fit our mathematical models?

◮ In 1972, Milner came up with the LCF approach to

automated theorem proving.

◮ The idea: write a kernel that is dumb (simple logic + a few

inference rules) but sound

◮ Don’t touch it! But tell it what to do with tactics, which are

  • smart. The kernel is the “gatekeeper” of soundness.
slide-72
SLIDE 72

QuantoTactic

◮ The idea: formalise equivalence up to diagrammatic

equations in Isabelle: ∃R, R′ R ∈ axioms ∧ instance-of(R, R′) ∧ valid-rewrite(R′, G, H) = ⇒ (G ≡ H)

slide-73
SLIDE 73

QuantoTactic

◮ The idea: formalise equivalence up to diagrammatic

equations in Isabelle: ∃R, R′ R ∈ axioms ∧ instance-of(R, R′) ∧ valid-rewrite(R′, G, H) = ⇒ (G ≡ H)

◮ Wrap QuantoCore matching and rewriting capabilities in

tactics, which do the hard stuff (e.g. finding witnesses R, R′ for the implication above)

slide-74
SLIDE 74

QuantoTactic

QuantoTactic is (or rather, will be...) three things:

  • 1. A theory of diagrams and rewriting formalised in Isabelle
slide-75
SLIDE 75

QuantoTactic

QuantoTactic is (or rather, will be...) three things:

  • 1. A theory of diagrams and rewriting formalised in Isabelle
  • 2. A tactic invoked by the prover, hooking the (powerful)

Quantomatic core up to the (sound) Isabelle kernel

slide-76
SLIDE 76

QuantoTactic

QuantoTactic is (or rather, will be...) three things:

  • 1. A theory of diagrams and rewriting formalised in Isabelle
  • 2. A tactic invoked by the prover, hooking the (powerful)

Quantomatic core up to the (sound) Isabelle kernel

  • 3. Language extensions and GUI support for inline graphical

notation in proof documents

slide-77
SLIDE 77

Thanks!

◮ Joint work with Lucas Dixon, Alex Merry, Ross Duncan,

Vladimir Zamdzhiev, David Quick, and others

◮ See: sites.google.com/site/quantomatic