OBJ first-order functional language based on equational logic

Slides:



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

Substitution & Evaluation Order cos 441 David Walker.
Cs7120 (Prasad)L22-MetaPgm1 Meta-Programming
Semantics Static semantics Dynamic semantics attribute grammars
Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal.
Rigorous Software Development CSCI-GA Instructor: Thomas Wies Spring 2012 Lecture 11.
INF 212 ANALYSIS OF PROG. LANGS Type Systems Instructors: Crista Lopes Copyright © Instructors.
Fall Semantics Juan Carlos Guzmán CS 3123 Programming Languages Concepts Southern Polytechnic State University.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
Computing Fundamentals 1 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K308 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal.
Functional Design and Programming Lecture 1: Functional modeling, design and programming.
1 Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications.
Solving Partial Order Constraints for LPO termination.
ML: a quasi-functional language with strong typing Conventional syntax: - val x = 5; (*user input *) val x = 5: int (*system response*) - fun len lis =
Computing Fundamentals 1 Lecture 1 Lecturer: Patrick Browne Room K308 Based on Chapter 1. A Logical approach to Discrete.
Sparkle A theorem prover for the functional language Clean Maarten de Mol University of Nijmegen February 2002.
Operational Semantics Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Computing Fundamentals 2 CafeOBJ. Equational logic State is a list of variables with associated values. Evaluation of an expression E in a state is performed.
Abstract Data Types and Encapsulation Concepts
3-3 Solving Multiplication Equations. Solve Solution GOAL Find the value of the variable that makes the equation TRUE. The value that makes the equation.
2.5 Reasoning in Algebra and Geometry
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
Mathematical Modeling and Formal Specification Languages CIS 376 Bruce R. Maxim UM-Dearborn.
Computing Fundamentals 1 Equations and Reduction in CafeOBJ
Semantics. Semantics is a precise definition of the meaning of a syntactically and type-wise correct program. Ideas of meaning: –Operational Semantics.
SE424 Languages with Context A Block Structured Language.
CSE Winter 2008 Introduction to Program Verification January 31 proofs through simplification.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Objective: To prove and apply theorems about angles Proving Angles Congruent (2-6)
Operational Semantics Mooly Sagiv Tel Aviv University Textbook: Semantics with Applications Chapter.
Lesson 3: Properties Algebra 1 CP Mrs.Mongold. Identity and Equality Properties Additive Identity- any number plus zero equals that number.
Operational Semantics Mooly Sagiv Tel Aviv University Sunday Scrieber 8 Monday Schrieber.
Process Algebra (2IF45) Basic Process Algebra Dr. Suzana Andova.
2.5 Reasoning in Algebra and Geometry Algebraic properties of equality are used in Geometry. –Will help you solve problems and justify each step. In Geometry,
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Operational Semantics Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson
Certifying and Synthesizing Membership Equational Proofs Patrick Lincoln (SRI) joint work with Steven Eker (SRI), Jose Meseguer (Urbana) and Grigore Rosu.
Algebra 1 Notes: Lesson 1-4: Identity and Equality Properties.
Describing Syntax and Semantics
Axiomatic Number Theory and Gödel’s Incompleteness Theorems
Principles of programming languages 8: Types
Properties of Equality and Solving One-Step Equations
2.5 and 2.6 Properties of Equality and Congruence
CS 326 Programming Languages, Concepts and Implementation
Boolean Algebra A Boolean algebra is a set B of values together with:
Jared Davis The University of Texas at Austin April 6, 2006
Proving Statements about Segments
Algebraic Specification
2.5 Reasoning in Algebra and Geometry
Lecture 15 (Notes by P. N. Hilfinger and R. Bodik)

Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
Number Properties Magic Book Foldable
Programming Languages and Compilers (CS 421)
CSCE 314: Programming Languages Dr. Dylan Shell
13.9 Day 2 Least Squares Regression
Number Properties Magic Book Foldable
Solving Absolute Value Equations
Formal Methods in software development
CASL-Common Algebraic Specification Language
Sub-system interfaces
Proving Statements about Segments
Compilers Principles, Techniques, & Tools Taught by Jing Zhang
Program correctness Axiomatic semantics
Programming Languages and Compilers (CS 421)
Generics, Lambdas and Reflection
11.1 The Concept of Abstraction
Presentation transcript:

OBJ first-order functional language based on equational logic parameterized programming supports declarative style that facilitates verification and allows OBJ to be used as a theorem-prover can include LISP code provides flexible environment – convenient for specification and rapid prototyping

Equational Calculus calculus of replacing terms by equal terms. Equational calculus derives (proves) a term equation from a conditional-equational axiom set.

Equational Calculus The deduction rules in this calculus are: Reflexivity: Any term is provably equal to itself (t = t). Transitivity: If t1 is provably equal to t2 and t2 is provably equal to t3, then t1 is provably equal to t3. Symmetry: If t1 is provably equal to t2, then t2 is provably equal to t1. Congruence: If t1 is provably equal to t2, then any two terms are provably equal which consist of some context built around t1 and t2.

Three kinds of top-level entities objects object encapsulates executable code theories theory defines properties that may or may not be satisfied by another object or theory views a view is binding of the entities declared in the theory Objects and theories are called modules

The most important OBJ unit is the Object, which encapsulates executable code. Syntactically, an object begins with the key word obj and ends with endo. The name of the object occurs immediately after obj keyword; following this comes is, and then body of the object. obj <ModID> is … endo

obj <ModID> is … endo For parameterized objects, the name is a simple identifier, such as STACK-OF-INT, PHRASE, or OBJ14. Parameterized objects have an interface specification in place of a simple name. obj <ModID> is … endo

Sorts declared with the syntax sorts <SortIDList> sorts Nat Int Rat . sort <SortID> sort Int .

Order Sorted Algebra (OSA) designed to handle cases where things of one sort are also of another sort For example, natural numbers are also integers Where operators or expressions have several different sorts Provides subsort partial ordering among sorts supports multiple inheritance

Subsort Example obj BITS1 is sorts BIT Bits . subsorts Bit < Bits . ops 0 1 : -> Bits . ops -- : Bit Bits -> Bits . endo

Equations and Semantics Denotational semantics based upon OSA Operational semantics based upon order sorted term rewriting Semantics of an object are determined by its equations Equations are written declaratively and interpreted operationally

Equations and Semantics Rewrite rules substitute instances of left side by corresponding substitution instances on the right side eq M + s N = s(M + N) . M and N are variables, + and s are operator symbols eq introduces the equation = separates the left and right side of the equation

Operational Semantics in Reduction obj LIST-OF-INT is sort List . protecting INT . subsort Int < List . op -- : Int List -> List . op length_ : List -> Int . var I : Int . var L : List . eq length I = 1; eq length(I L) = 1 + length(L) endo

term evaluation reduce [in <ModExp> :] <Term> Reduce command is executed by matching the given term with the left sides of the equations and then replacing the matched subterm with the corresponding right side. This is called application of rewrite rules

Term Evaluation The operational semantics for a conditional rewrite rule is as follows: first find a match for the left side then evaluate the condition after substituting the binding determined by the match if it evaluates to true then do the replacement by the right side, again using the values for the variables determined by the match. Evaluating the condition could require non-trivial further rewriting the cases.

reduce length(17 -4 329) . =========================================== reduce in LIST-OF-INT : length (17 (-4 329)) rewrites: 5 result NzNat: 3

reduce length(17 -4 329) . length(17 -4 329) => 1 + length(-4 329) => 1+ (1 + length 329) => 1 + 2 => 3 We call it a trace of the computation.