Soundness of Higher-order Frame Rules (How did category theory help me?) Hongseok Yang Seoul National University Joint work with Lars Birkedal and Noah.

Slides:



Advertisements
Similar presentations
Types and Programming Languages Lecture 13 Simon Gay Department of Computing Science University of Glasgow 2006/07.
Advertisements

An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
Techniques for proving programs with pointers A. Tikhomirov.
Techniques for Proving the Completeness of a Proof System Hongseok Yang Seoul National University Cristiano Calcagno Imperial College.
Semantics Static semantics Dynamic semantics attribute grammars
Proofs and Programs Wei Hu 11/01/2007. Outline  Motivation  Theory  Lambda calculus  Curry-Howard Isomorphism  Dependent types  Practice  Coq Wei.
ICE1341 Programming Languages Spring 2005 Lecture #6 Lecture #6 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Budapest University of Technology and EconomicsDagstuhl 2004 Department of Measurement and Information Systems 1 Towards Automated Formal Verification.
3-Valued Logic Analyzer (TVP) Tal Lev-Ami and Mooly Sagiv.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
Event structures Mauro Piccolo. Interleaving Models Trace Languages:  computation described through a non-deterministic choice between all sequential.
8. Introduction to Denotational Semantics. © O. Nierstrasz PS — Denotational Semantics 8.2 Roadmap Overview:  Syntax and Semantics  Semantics of Expressions.
Euler’s circles Some A are not B. All B are C. Some A are not C. Algorithm = a method of solution guaranteed to give the right answer.
ISBN Chapter 3 Describing Syntax and Semantics.
Logic in general Logics are formal languages for representing information such that conclusions can be drawn Syntax defines the sentences in the language.
Denotational Semantics Syntax-directed approach, generalization of attribute grammars: –Define context-free abstract syntax –Specify syntactic categories.
Logical Agents Chapter 7. Why Do We Need Logic? Problem-solving agents were very inflexible: hard code every possible state. Search is almost always exponential.
On the Relationship Between Concurrent Separation Logic and Assume-Guarantee Reasoning Xinyu Feng Yale University Joint work with Rodrigo Ferreira and.
Local Reasoning Peter O’Hearn John Reynolds Hongseok Yang.
Schemas as Toposes Steven Vickers Department of Pure Mathematics Open University Z schemas – specification1st order theories – logic geometric theories.
Describing Syntax and Semantics
Recursion. Definitions I A recursive definition is a definition in which the thing being defined occurs as part of its own definition Example: A list.
Meaning and Language Part 1.
1 Category Theory in a ( E,M ) -category Some aspects of category theory, in particular related to universality, can be developed in any finitely complete.
The Relationship between Topology and Logic Dr Christopher Townsend (Open University)
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Proof Systems KB |- Q iff there is a sequence of wffs D1,..., Dn such that Dn is Q and for each Di in the sequence: a) either Di is in KB or b) Di can.
Automatic Verification of Pointer Programs using Grammar-based Shape Analysis Hongseok Yang Seoul National University (Joint Work with Oukseh Lee and Kwangkeun.
Categories and Computer Science
Axiomatic Methods for Software Verification Hongseok Yang.
Logical Agents Logic Propositional Logic Summary
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Of 33 lecture 12: propositional logic – part I. of 33 propositions and connectives … two-valued logic – every sentence is either true or false some sentences.
Slide 1 Propositional Definite Clause Logic: Syntax, Semantics and Bottom-up Proofs Jim Little UBC CS 322 – CSP October 20, 2014.
Refinements to techniques for verifying shape analysis invariants in Coq Kenneth Roe GBO Presentation 9/30/2013 The Johns Hopkins University.
Key Concepts Representation Inference Semantics Discourse Pragmatics Computation.
Chapter 3 Part II Describing Syntax and Semantics.
Towards a General Theory of Local Actions Hongseok Yang Seoul National University Peter O’Hearn Queen Mary, University of London.
Separation and Information Hiding Peter W. O’Hearn (Queen Mary, University of London) John C. Reynolds (Carnegie Mellon University) Hongseok Yang (Seoul.
Balanced Category Theory Claudio Pisani Calais, June 2008.
The theory behind Functional Programming Functional: based on lambda calculus / combinators, recursion theory, category theory. By contrast with other.
LDK R Logics for Data and Knowledge Representation ClassL (Propositional Description Logic with Individuals) 1.
Computer Science CPSC 322 Lecture 22 Logical Consequences, Proof Procedures (Ch 5.2.2)
lamsweerde Chap.4: Formal Requirements Specification © 2009 John Wiley and Sons Fundamentals of RE Chapter 4 Requirements.
11 Artificial Intelligence CS 165A Thursday, October 25, 2007  Knowledge and reasoning (Ch 7) Propositional logic 1.
CMSC 330: Organization of Programming Languages Operational Semantics.
Higher / Int.2 Philosophy 12. Our Learning  Fallacy Reminder  Summary following Homework NAB  Class NAB.
1 Lecture 3 The Languages of K, T, B and S4. 2 Last time we extended the language PC to the language S5 by adding two new symbols ‘□’ (for ‘It is necessary.
Meaningless programs. K- Want to run meaningful program! Syntax matching programs Semantics matching programs.
Extension of Separation Logic for Stack Reasoning Jiang Xinyu.
March 3, 2016Introduction to Artificial Intelligence Lecture 12: Knowledge Representation & Reasoning I 1 Back to “Serious” Topics… Knowledge Representation.
PZ03CX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ03CX - Language semantics Programming Language Design.
Artificial Intelligence Logical Agents Chapter 7.
Copyright 2013, 2009, 2005, 2002 Pearson, Education, Inc.
March 23 rd. Four Additional Rules of Inference  Constructive Dilemma (CD): (p  q) (r  s) p v r q v s.
CS5205: Foundation in Programming Languages Type Reconstruction
Propositional Logic (a.k.a. Sentential Logic)
Solving Systems of Linear Equations in Three Variables
Knowledge Representation and Reasoning
Matching Logic An Alternative to Hoare/Floyd Logic
Graph-Based Operational Semantics
Combining Abstract Interpreters
Concurrent Separation Logic
Back to “Serious” Topics…
Concurrent Separation Logic
Concurrent Separation Logic
Symbolic Characterization of Heap Abstractions
Towards a Unified Theory of Operational and Axiomatic Semantics
CASL-Common Algebraic Specification Language
Representations & Reasoning Systems (RRS) (2.2)
Presentation transcript:

Soundness of Higher-order Frame Rules (How did category theory help me?) Hongseok Yang Seoul National University Joint work with Lars Birkedal and Noah Torp-Smith IT University, Copenhagen, Denmark

Toy Memory Manager alloc x = if (f=nil) then x:=new() else x:=f; f:=[f] free x = [x]:=f; f:=x alloc x free x Memory_Manager f nil A client can use the memory manager directly or indirectly. wrapper x = alloc x. alloc x ;[x]:=0 iclient x = wrapper x. wrapper x ;y:=x Can we hide list f from a client-side reasoning, for all direct and indirect clients?

Higher-order Frame Rule Second-order Frame Rule (AKA Hypothetical Frame Rule) {emp}alloc x {x -} ` {P}wrapper x (alloc x ){Q} {emp*lst f}alloc x {(x -)*lst f} ` {P*lst f}wrapper x (alloc x ){Q*lst f} Third-order Frame Rule ( 8 alloc x. {emp}alloc x {x -} ) {P}wrapper x (alloc x ){Q} ) ` {A}iClient x (wrapper x ){B} 8 alloc x. {emp*lst f}alloc x {x -*lst f} ) {P*lst f}wrapper x (alloc x ){Q*lst f} ` {A*lst f}iClient x (wrapper x ){B*lst f}

Goal of this Talk If we want to have the second-order frame, we need to be careful: when the rule is added to separation logic, the logic becomes faulty. Need to give up the conjunction rule. Question: what about the other higher-order rules? Answer: we can have them as long as we give up the conjunction rule. The goal of this talk is to see how the category theory can help us to get this answer.

Predicates s,t,… 2 States = Ints ! fin Nats a,b,p,q,… 2 Preds = P(States) Heap combining operator o: s o t = s [ tif dom(s) Å dom(t) = {} undefined otherwise Separating conjunction *: p*q = {s o t | s 2 p, t 2 q, dom(s) Å dom(t)={} } E.g. { [1 ! 0] } * { [1 ! 2], [3 ! 9] } = { [1 ! 0, 3 ! 9] }

Specified Programs Specification Types: ::= {P}-{Q} | £ | ! Typing Rules with Specification Types: x: ` M : ` x.M : ! ` M : ! ` N : ` M N : ` M : {p}-{q} ` M : {p*r}-{q*r} ` M : {p}-{q} ! {a}-{b} ` M : {p*r}-{q*r} ! {a*r}-{b*r} ` M : [{p}-{q} ! {a}-{b}] ! {c}-{d} ` M : [{p*r}-{q*r} ! {a*r}-{b*r}] ! {c*r}-{d*r} 2 nd -order Frame Rule 1 st -order Frame Rule 3 rd -order Frame Rule ! Intro ! Elim

Original Question, More Precisely Does the type system make a sense? ` skip : {p}-{false} only if p = false. Find a semantics for specified programs s.t. the interpretation of commands must coincide with the operational semantics. The most difficult part is to interpret higher- order functions correctly. The interpretation must validate, laws. The category theory tells what such an interpretation is.

Knowledge on Category Theory List of things to know to understand this talk: Category Functor Product Exponential Natural Transformation Functor Category Presheaf Category

Knowledge on Category Theory List of things to know to understand this talk: Category : Poset Functor : Monotone Function Product : Meet Exponential : Implication Natural Transformation : Order for Mono. Fns. Functor Category : Poset of Mono. Fns. Presheaf Category : No match This means that the talk is extremely hard to understand!

Basic Category Theory A category specifies an abstract typed programming language. A category consists of four kinds of data: objects X,Y,Z,…; typed morphisms f:X ! Y, g:Y ! Z, h:Z ! V; identity morphism id X :X ! X for each object X; and composition g o f for matching morphisms f and g such that o is associative and has id as an identity: (h o g) o f = h o (g o f) and (id o f) = (f o id) = f.

Example Categories Set: objects: sets morphisms: typed functions identity, and composition: usual ones. Preds: objects: predicates morphisms: p · q iff 9 r. p*r = q.

Categorical Semantics of a Typed Programming Language To give a categorical semantics of a language, 1. pick a category C; 2. interpret a type as an object in C; and 3. interpret a typed term as a morphism in C: « x: ` M: ¬ is a morphism from « ¬ to « ¬. Then, check whether the interpretation is good: 1. Coincide with the operational semantics? 2. Validate reasoning princinples? Picking a good C is the most important.

Good Category C for Our Goal Requirements for C: 1. C must validate the higher-order frame rules. 2. C must validate the, laws. We use a presheaf category C for this goal. 1. The higher-order frame rules can be built in C. 2. C always validates the, laws.

Functor A functor F:C ! D maps objects in C to objects in D, and morphisms in C to morphisms in D such that F preserves all data: typing of morphisms, identity, and composition. F:C ! D specifies a parameterized type: objects in C: possible parameters morphisms in C: subtyping between parameters

Natural Transformation A natural transformation :F ! G:C ! D maps each object X in C to a morphism X :F(X) ! G(X) such that for all f:X ! Y in C, specifies a parameterized program. X is instantiated with the parameter X. The condition says that comes from a single program. F(X) F(f) F(Y)G(Y) G(X) G(f) X Y

Category Set Preds Category Set Preds consists of the following data: object: functor from Preds to Sets morphism: natural transformation between such functors Question: what are identity and composition? In Set Preds, a functor means a parameterized set, and a nat. trans. a parameterized function. The parameter represents the modules internal state (especially, an invariant for it).

Interpretation in Set Preds « ¬ is a functor from Preds to Set. « k: ` M: ¬ is a natural trans. from « ¬ to « ¬. A program x in « ¬ a can internally access cells in a, but maintains the invariant a. Example: « {p}-{q} ¬ a = { f:p*a*T ! q*a*T | …… } « {p}-{q} ¬ (a · b)(f) = f| p*b

Interpretation of Higher-order Types Category theory says: in order to have, laws, « ! ¬ must be the exponential « ¬)« ¬ ; « £ ¬ must be the product of « ¬£« ¬. Category theory also gives the definition of exponential and product. « ! ¬ a = { 2 a · b ( « ¬ b !« ¬ b) | for all c ¸ b ¸ a, } « ¬ (b) b c « ¬ (c) « ¬ (b · c) « ¬ (b) « ¬ (b · c)

Higher-order Frame Rule Categorically, a higher-order frame rule means that for all F,G in Set Preds, : F(-) ! F(r*-) : {p}-{q}(r*-) ' {p*r}-{q*r}(-) : (F £ G)(r*-) ' F(r*-) £ G(r*-) : (F ) G)(r*-) ' (F(r*-) ) G(r*-)) exist. In Set Preds, all exist, but is not isomorphism. In our actual model, we used reflexive graph categories, and showed the existence of all above.

Conclusion How did the category theory help me? It taught me how I should interpret functions and pairs correctly. It made precise what I meant by higher-order frame rules and their soundness.