June 21, 20041 Reasoning about explicit strictness in a lazy language using mixed lazy/strict semantics Marko van Eekelen Maarten de Mol Nijmegen University,

Slides:



Advertisements
Similar presentations
Automated Theorem Proving Lecture 1. Program verification is undecidable! Given program P and specification S, does P satisfy S?
Advertisements

ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
An Abstract Interpretation Framework for Refactoring P. Cousot, NYU, ENS, CNRS, INRIA R. Cousot, ENS, CNRS, INRIA F. Logozzo, M. Barnett, Microsoft Research.
- Vasvi Kakkad.  Formal -  Tool for mathematical analysis of language  Method for precisely designing language  Well formed model for describing and.
1 How to transform an analyzer into a verifier. 2 OUTLINE OF THE LECTURE a verification technique which combines abstract interpretation and Park’s fixpoint.
1 Logic Logic in general is a subfield of philosophy and its development is credited to ancient Greeks. Symbolic or mathematical logic is used in AI. In.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
© M. Winter COSC 4P41 – Functional Programming Testing vs Proving Testing –uses a set of “typical” examples, –symbolic testing, –may find errors,
CSE 425: Semantic Analysis Semantic Analysis Allows rigorous specification of a program’s meaning –Lets (parts of) programming languages be proven correct.
VIDE als voortzetting van Cocktail SET Seminar 11 september 2008 Dr. ir. Michael Franssen.
Copyright © 2006 Addison-Wesley. All rights reserved.1-1 ICS 410: Programming Languages Chapter 3 : Describing Syntax and Semantics Axiomatic Semantics.
ISBN Chapter 3 Describing Syntax and Semantics.
1 Semantic Description of Programming languages. 2 Static versus Dynamic Semantics n Static Semantics represents legal forms of programs that cannot be.
CS 355 – Programming Languages
School of Computing and Mathematics, University of Huddersfield CAS2545: WEEK 11 LECTURE: n The meaning of Algebraic Specifications TUTORIAL/PRACTICAL:
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
C. Varela; Adapted w/permission from S. Haridi and P. Van Roy1 Declarative Computation Model Defining practical programming languages Carlos Varela RPI.
CS5371 Theory of Computation
Presentation for Proof Assistant course by Nadya Kalabishka
TR1413: Discrete Mathematics For Computer Science Lecture 3: Formal approach to propositional logic.
CSE115/ENGR160 Discrete Mathematics 01/31/12 Ming-Hsuan Yang UC Merced 1.
1 Chapter 7 Propositional and Predicate Logic. 2 Chapter 7 Contents (1) l What is Logic? l Logical Operators l Translating between English and Logic l.
Knoweldge Representation & Reasoning
PSUCS322 HM 1 Languages and Compiler Design II Formal Semantics Material provided by Prof. Jingke Li Stolen with pride and modified by Herb Mayer PSU Spring.
Sparkle A theorem prover for the functional language Clean Maarten de Mol University of Nijmegen February 2002.
Chapter 14 Programming With Streams. Streams  A stream is an infinite sequence of values.  We could define a special data type for them: data Stream.
Proofs, Recursion and Analysis of Algorithms Mathematical Structures for Computer Science Chapter 2.1 Copyright © 2006 W.H. Freeman & Co.MSCS SlidesProofs,
Describing Syntax and Semantics
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
CAS LX 502 Semantics 3a. A formalism for meaning (cont ’ d) 3.2, 3.6.
A Brief Summary for Exam 1 Subject Topics Propositional Logic (sections 1.1, 1.2) –Propositions Statement, Truth value, Proposition, Propositional symbol,
MATH 224 – Discrete Mathematics
Cs7120 (Prasad)L9-RECUR-IND1 Recursion and Induction.
March 3, 2015Applied Discrete Mathematics Week 5: Mathematical Reasoning 1Arguments Just like a rule of inference, an argument consists of one or more.
1 Knowledge Representation. 2 Definitions Knowledge Base Knowledge Base A set of representations of facts about the world. A set of representations of.
ISBN Chapter 3 Describing Semantics -Attribute Grammars -Dynamic Semantics.
Formal Verification Lecture 9. Formal Verification Formal verification relies on Descriptions of the properties or requirements Descriptions of systems.
Induction Proof. Well-ordering A set S is well ordered if every subset has a least element. [0, 1] is not well ordered since (0,1] has no least element.
ARTIFICIAL INTELLIGENCE [INTELLIGENT AGENTS PARADIGM] Professor Janis Grundspenkis Riga Technical University Faculty of Computer Science and Information.
Copyright © Zeph Grunschlag, Induction Zeph Grunschlag.
Programming Languages and Design Lecture 3 Semantic Specifications of Programming Languages Instructor: Li Ma Department of Computer Science Texas Southern.
Syntax and Semantics CIS 331 Syntax: the form or structure of the expressions, statements, and program units. Semantics: the meaning of the expressions,
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
Specifying Languages Our aim is to be able to specify languages for use in the computer. The sketch of an FSA is easy for us to understand, but difficult.
Lecture 5 1 CSP tools for verification of Sec Prot Overview of the lecture The Casper interface Refinement checking and FDR Model checking Theorem proving.
Of 38 lecture 13: propositional logic – part II. of 38 propositional logic Gentzen system PROP_G design to be simple syntax and vocabulary the same as.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
Advanced Formal Methods Lecture 3: Simply Typed Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from.
1 First order theories (Chapter 1, Sections 1.4 – 1.5) From the slides for the book “Decision procedures” by D.Kroening and O.Strichman.
1 Use graphs and not pure logic Variables represented by nodes and dependencies by edges. Common in our language: “threads of thoughts”, “lines of reasoning”,
Principle of Programming Lanugages 3: Compilation of statements Statements in C Assertion Hoare logic Department of Information Science and Engineering.
1 Reasoning with Infinite stable models Piero A. Bonatti presented by Axel Polleres (IJCAI 2001,
CMSC 330: Organization of Programming Languages Operational Semantics.
Daniel Kroening and Ofer Strichman 1 Decision Procedures An Algorithmic Point of View Basic Concepts and Background.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
5 Lecture in math Predicates Induction Combinatorics.
CENG 424-Logic for CS Introduction Based on the Lecture Notes of Konstantin Korovin, Valentin Goranko, Russel and Norvig, and Michael Genesereth.
Chapter 7. Propositional and Predicate Logic
Sparkle a functional theorem prover
Spring 2017 Program Analysis and Verification
More Functional Programming
Revisiting Predicate Logic LN chapters 3,4
CSE 311: Foundations of Computing
Chapter 10: Mathematical proofs
A Brief Summary for Exam 1
On Kripke’s Alleged Proof of Church-Turing Thesis
Computer Security: Art and Science, 2nd Edition
Testing vs Proving Testing uses a set of “typical” examples,
Proving Statements about Segments
Presentation transcript:

June 21, Reasoning about explicit strictness in a lazy language using mixed lazy/strict semantics Marko van Eekelen Maarten de Mol Nijmegen University, NL Technical Report NIII-R0402 (Revised Version at Not NIII-R 0408, 0415, 0416, 0427, …

June 21, Lazy semantics need to be extended Overview The Sparkle project: integrating programming and theorem proving focus on functional programming Some lazy/strict reasoning principles with  The strictness gap: programmers versus theoreticians Some basic reasoning examples The basis of strictness constructs in lazy languages Mixed lazy/strict semantics Conclusions and Future work

June 21, The Sparkle Project: Theorem Proving for Programmers Clean Compiler Function(s) Properties Sparkle: dedicated proof assistant Program with proof certificate Semantic reasoning level is the semantics of the programming language

June 21, Extensionality: However, is in head normal form and is undefined: So, and are not equal. An extra condition is needed (Abramsky): Now: Since the meaning of both and is undefined. So, and are semantically equal for each.

June 21, Due to laziness an extra base step for the undefined case is required.  y  [A]: P (y) P(  ) P([])  x  A  xs  [A]: P (xs)  P([x:xs]) Without this extra step we could e.g. easily prove that every list is finite. Induction Furthermore, P has to be admissible (Paulson).

June 21, The strictness gap Theoreticians view on strictness: A derived formal property –Mathematical property of semantic function definitions –Undecidable property, approximated via a safe analysis using abstract interpretation, abstract reduction or some type inference system Programmers view on strictness: A programming decision –Essential for efficiency of data structures –Essential for efficiency of evaluation –Essential for enforcing the evaluation order in interfaces But programmer defined strictness has an effect on definedness.

June 21, Closing the gap Mathematical view on strictness: x =   f x =  Operational view on strictness: Reduce argument to weak head normal form before evaluating the function application Notation for Strictness: Merely annotation, no semantics Mixed semantics: Notationally strict => operationally strict => mathematically strict For reasoning a mixed strict/lazy graph rewriting semantics is needed

June 21, Reasoning about Clean functions: Strict equality:  == True is  True==  is  Lazy and:  && False is  False&&  is False Lazy or:  || True is  True||  is True Reasoning on the predicate level: Logical identity:   True is False True   is False Logical and:  True is ill-formed but used as shorthand for:  = True  True is False True   is False Logical or:  True is True True   is True Basic lazy-strict reasoning - 1

June 21, Basic lazy-strict reasoning - 2 Consider the following property It is not valid if both x and y are  ! What does hold is the following: Many properties do hold unconditionally, e.g:

June 21, A property of isMember x = , xs  [ ], p y = False x  , xs = [ , x], p y = False x = 2, xs = [2:xs], p y = False x = 2, xs = [3], p y = if (y == 2) True (p y)...

June 21, A case for which P does not hold x = 2, xs = [3], p y = if (y == 2) True (p y) Then: p x = True isMember x xs = False filter p xs = [  ] isMember x (filter p xs) =  So, P (x,xs,p) :=  = False && True Hence P does not hold in this case.

June 21, How to express this in Sparkle, which is first order?

June 21, Expressing Properties The auxiliary function to express finiteness of lists: Definedness of an object x: Totality of a predicate p: Finiteness of lists:

June 21, The basic construct: let! (partially) strict data structures user annotated function arguments unboxed arrays special primitives like seq or #! They can all be expressed easily with a single construct, the let!-construct: Lazy semantics must be extended to express the meaning of let!.

June 21, Launchbury’s semantics

June 21, Extra rule for mixed semantics

June 21, Basic Idea

June 21, Define Meaning Extra rule for mixed semantics: Lazy Semantics:

June 21, Proving Mixed Semantics Correctness Computational Adequacy

June 21, Folklore Strictness Knowledge A.Expressions that are bottom lazily, will also be bottom when we make something strict. B.When strictness is added to an expression that is non-bottom lazily, either the result stays the same or it becomes bottom. C.Expressions that are non-bottom using strictness will (after !-removal) also be non-bottom lazily with the same result.

June 21, Expressions: Switching from Mixed to Lazy Semantics Environments :

June 21, Formal Strictness Knowledge

June 21, Distinguishing different terms In Launchbury’s lazy semantics and have a different meaning but they can not be distinguished. With mixed semantics and are different and they can be distinguished.

June 21, Conclusions/Future Work Conclusions Mixed semantics are needed for reasoning in Haskell and Clean Mixed semantics essentially extend lazy semantics Future Work Extend mixed graph rewriting semantics extend the logic with single step semantics Full Integration of prover and language towards programming with proven properties