Built-in Module BOOL. Lecture Note 01a

Size: px
Start display at page:

Download "Built-in Module BOOL. Lecture Note 01a"

Transcription

1 Built-in Module BOOL Lecture Note 01a

2 Topics! Built-in Boolean Algebra module BOOL and the equivalence of two boolean expressions (or SAT problems)! Study important concepts about CafeOBJ system through BOOL built-in module

3 Boolean data type in CafeOBJ! Boolean data type (or Boolean Algebra) is the most fundamental data type of CafeOBJ.! It defines propositional calculus which plays the central role in any logical argument. BOOL is the name of a CafeOBJ built-in module which defines Boolean Algebra. BOOL is set to be imported automatically to any module.

4 Signature of BOOL (ADJ diagram) _and_, _xor_, _or_, _implies_, _iff_ true, false Bool not_

5 Signature of BOOL (integral part) [ Bool ] -- two constants ops true false : -> Bool { constr } -- two implicit constructors for Boolean expressions with variables --- op _ and _ : Bool Bool -> Bool { assoc comm prec: 55 r-assoc } op _ xor _ : Bool Bool -> Bool { assoc comm prec: 57 r-assoc } op _ or _ : Bool Bool -> Bool { assoc comm prec: 59 r-assoc } op not _ : Bool -> Bool { strat: (0 1) prec: 53 } op _ implies _ : Bool Bool -> Bool { strat: (0 1 2) prec: 61 r-assoc } op _ iff _ : Bool Bool -> Bool { strat: (0 1 2) prec: 63 r-assoc } Key words inside braces ({ and }) declare attributes of each operator: constr -> constructor assoc -> associative comm -> commutative prec -> precedence r-assoc -> right associative strat -> strategy

6 Operator Attribute: constr (constructor) ops true false : -> Bool { constr } is same as op true : -> Bool { constr } op false : -> Bool { constr } Any term of a sort S is reduced to a term that is composed only of the constructors of the sort S. In current implementation of CafeOBJ, the constructor attribute does not affect the system behavior in any way; it is just comment.

7 Standard operator declaration -- An operator (a name of operation) is declared as standard or mixfix Standard Operator Declaration op and : Bool Bool -> Bool {assoc comm}. -- no _ symbols in standard operator! BOOL> red and(and(and(b1,b2),and(b3,b4)),b5). and(and(and(b1,b2),and(b3,b4)),b5) : Bool BOOL> red and(and(and(b1,b2),and(b3,b4)),b5) = and(and(b5,b3),and(and(b1,b4),b2)). true : Bool A standard way of writing function applications and terms! Little danger in parsing.

8 Mixfix operator declaration -- An operator (a name of operation) is declared as standard or mixfix Mixfix (infix) Operator Declaration -- op _and_ : Bool Bool -> Bool {assoc comm prec: 55 r-assoc} BOOL> red (((b1 and b2) and (b3 and b4)) and b5). b1 and b2 and b3 and b4 and b5 : Bool BOOL> red (((b1 and b2) and (b3 and b4)) and b5) = ((b5 and b3) and ((b1 and b4) and b2)). true : Bool Flexible in writing expressions. Much danger in parsing. Put parentheses properly; a good practice is put parentheses fully!

9 Operator Attributes: assoc (associative), comm (commutative) (1) op _and_ : Bool Bool -> Bool { assoc comm prec: 55 r-assoc } Attribute assoc declares that the operator _and_ satisfy an equation: vars A B C : Bool. eq (A and B) and C = A and (B and C). Attribute comm declares that the operator _and_ satisfy an equation: vars A B : Bool. eq A and B = B and A. This equation makes an infinite loop if used as a rewriting rule.

10 Operator Attributes: assoc (associative), comm (commutative) (2) Attributes assoc and comm together mean that order of arguments connected by _and_ operators does not affect the equivalence of two expressions. BOOL> open EQL - for using _=_ %EQL> ops b1 b2 b3 b4 b5 : -> Bool reduce in %EQL: (b1 and b2 and b3 and b4 and b5) = (b5 and b2 and b1 and b3 and b4) true : Bool

11 Operator Attributes for Parsing: prec (precedence) and r-assoc (right associative) (1) op _and_ : Bool Bool -> Bool { assoc comm prec: 55 r-assoc } op _xor_ : Bool Bool -> Bool { assoc comm prec: 57 r-assoc }! An operator of a higher precedence (an operator with a lower prec: number) binds tighter: that is, encloses its arguments with parentheses ( ( and ) ) first.! An operator with r-assoc is declared to associate to right.

12 Operator Attributes for Parsing: prec (precedence) and r-assoc (right associative) (2) BOOL> set verbose on BOOL> parse b1 xor b2 and b3 and b4 xor b5. (b1 xor ((b2 and (b3 and b4)) xor b5)) : Bool _xor_:bool / \ b1:bool _xor_:bool / \ _and_:bool b5:bool / \ b2:bool _and_:bool / \ b3:bool b4:bool

13 Default precedence of operators! Standard operators have precedence 0. Hence the term of the form f(a) connects strongest.! When an operator is mixfix, if the operator symbol does not start or end with ``_'', that is, no argument appears outside the term construct, the precedence is zero. An example is a singleton operator ``{_}'';! If it is a prefix unary operator, the precedence is 15. The unary ``-_'' offers an example;! Otherwise, the precedence is 41. (Description from the CafeOBJ Manual )

14 Default precedence of operators: Examples mod! MIXfix { [ Nat ] op 0 : -> Nat. -- 0: constant/standard op s _ : Nat -> Nat :prefix/mixfix op _! : Nat -> Nat :postfix/mixfix op _+_ : Nat Nat -> Nat. - 41:infix/mixfix } -- _! and _+_ have the precedence of s_ has the precedence of confirm this with the CafeOBJ system -- by using a command of describe op (_!) etc. Do not use precedence attribute without understanding well. Design simple and transparent syntax and put parentheses properly. Do not play with the parser of the system too much.

15 Axioms of BOOL (the integral part) vars A B C : Bool -- _and_ eq false and A = false. eq true and A = A. eq A and A = A. eq A and (B xor C) = (A and B) xor (A and C). -- _xor_ eq false xor A = A. eq A xor A = false. -- _or_ eq false or A = A. eq true or A = true. eq A or A = A. eq A or B = (A and B) xor A xor B. -- not_ eq not A = A xor true. -- _implies_ eq A implies B = (A and B) xor A xor true. -- _iff_ eq A iff B = A xor B xor true. Value Tables for Operators implied from the Axioms (true and true) = true (true and false) = false (false and false) = false (true xor true) = false (true xor false) = true (false xor false) = false (true or true) = true (true or false) = true (false or false) = false (not true) = false (not false) = true

16 Axioms for _and_ vars A B C : Bool. eq false and A = false. eq true and A = A. eq A and A = A. eq A and (B xor C) = (A and B) xor (A and C). Value Table for _and_ (true and true) = true (true and false) = false (false and true) = false (false and false) = false

17 Axioms for _xor_ var A : Bool. eq false xor A = A. eq A xor A = false. Value Table for _or_ (true xor true) = alse (true xor false) = true (false xor true) = true (false xor false) = false

18 Axioms for _or_ vars A B : Bool eq false or A = A. eq true or A = true. eq A or A = A. eq A or B = (A and B) xor A xor B. Value Table for _or_ (true or true) = true (true or false) = true (false or true) = true (false or false) = false

19 Axioms for not_ var A : Bool. eq not A = A xor true. Value Table for not_ (not true) = false (not false) = true

20 Axioms for not_implies_ var A B : Bool eq A implies B = (A and B) xor A xor true. Value Table for _implies_ (true implies true) = true (true implies false) = false (false implies true) = true (false implies false) = true

21 Axioms for_iff_ vars A B : Bool eq A iff B = A xor B xor true. Value Table for _or_ (true iff true) = true (true iff false) = false (false iff true) = false (false iff false) = true

22 Operator attribute: strat: (strategy) op not_ : Bool -> Bool { strat: (0 1) prec: 53 } op _implies_ : Bool Bool -> Bool { strat: (0 1 2) prec: 61 r-assoc } op _iff_ : Bool Bool -> Bool { strat: (0 1 2) prec: 63 r-assoc } The integer list after the key word strart: indicates the order in which the system try to reduce the term. 0 indicate the whole term with the specified operator on the top. i {1,2, <the number of argument>} indicates the term at the i-th argument. The number with minus sign indicates to delay the reduction until needed. You can find strategy of an operator by describe op <operator> command.

23 Default strategy of operators vars A B C : Bool. eq false and A = false. eq true and A = A. eq A and A = A. eq A and (B xor C) = (A and B) xor (A and C). The CafeOBJ system calculate the default strategy for each operator based on the equations for the operator. The principle for the calculation is reduce the argument needed to decide whether a term matches to a left hand side of the equations. The above set of equations suggest the strategy of ( ) for operator _and_, because _and_ is commutative, the final strategy is determined to be (1 2 0).

24 xor-and normal form of Boolean expressions (with variables) 1. By using the axioms (equations) of BOOL as rewriting rules, operators other than and and xor (i.e. or, not, implies, iff) are erased from Boolean expressions by keeping equivalence. 2. Any Boolean expression composed only with two operators of xor and and is reduced to (i.e. is equivalent to) the xor-and normal form by the equation: 3. X and (Y xor Z) = (X and Y) xor (X and Z). The module BOOL is designed to adopt exclusive-or (xor) normal forms for Boolean expressions (propositional expressions). That is, any Boolean expression is reduced to an expression containing only two kinds of boolean operators of xor and and.

25 xor-and normal form A Boolean expression is in xor-and normal form if it is expressed as: c 1 xor c 2 xor xor c m (if m=0 then false) without any dupulication of c i (i.e. c j = c k does not hold for any different j,k) and each c l (l=1 m) is expressed as: b l and b 2 and... and b n(l) (if n(l)=0 then true) for Boolean variables b i (i = 1 n(l)) without any duplication (i.e. b j =b k does not hold for any different j,k). Examples of terms in xor-and normal form b1 xor b2 and b3 and b4 xor b5 and b6 = (b1 xor ((b2 and (b3 and b4)) xor (b5 and b6))

26 Uniqueness of xor-and normal form (1) Any two Boolean expression are defined to be equivalent if they are equivalent as Boolean functions, i.e. the two expressions evaluate to the same value (true or false) for any assignment of Boolean values (true or false) to all Boolean variables in the expressions. Equations of BOOL define this equivalence of Boolean expressions.

27 Uniqueness of xor-and normal form (2) [xor-and uniqueness] Any two Boolean expressions in xor-and normal form are equivalent if and only if they are the same expression modulo assoc and comm of _xor_ and _and_.! Proof sketch) If part is trivial. For proving only if part, it is enough to show that for two different Boolean expressions e1 and e2 in xor-and normal form there is an assignment which makes (e1 iff e2) false. (e1 xor e2) can not be false because e1 and e2 are different. Therefore, by the following lemma, there is an assignment which makes (e1 xor e2) true and makes (e1 xor e2 xor true)=(e1 iff e2) false. [qed]

28 Lemma for [xor-and uniqueness] [Lemma] If the Boolean expression e in xor-and normal form is not false, there is an assignment which makes e true. Proof sketch) By induction w.r.t. the number n(e) of variables contained in the expression e. If n(e) is zero, then e should be true, and any assignment works. Let n(e) > 0 and e contain variable b1. (case 1) if e is of the form true xor e1, then make b1= false then the expression (true xor e1) [b1<-false] can not be false and contains smaller number of variables. (case 2) if e does not contain true, make b1=true then the expression e[b1<-true] can not be false and contains smaller number of variables. [qed]

29 BOOL provides a decision procedure for equivalance of boolean expressions Let exp1, exp2, and exp be any boolean expressions exp1:bool is equivalent to exp2:bool if and only if (red exp1 = exp2.) returns true if and only if (red exp1 iff exp2.) returns true BOOL can solve SAT problems exp:bool is satisfiable (there is at least one assignment which make exp true) if and only if (red exp.) does not return false

30 Examples of Equivalence %EQL> -- equivalence of two boolean expressions %EQL> red ((b1 implies b2) and (b2 implies b1)) = (b1 iff b2). -- reduce in %EQL : ((b1 implies b2) and (b2 implies b1)) = (b1 iff b2) true : Bool (0.000 sec for parse, 22 rewrites(0.000 sec), 178 matches) %EQL> red (not (b1 and b2)) = ((not b1) or (not b2)). -- reduce in %EQL : (not (b1 and b2)) = (not b1 or not b2) true : Bool (0.000 sec for parse, 11 rewrites(0.000 sec), 76 matches) %EQL> red (b1 implies b2) = ((not b1) or b2). -- reduce in %EQL : (b1 implies b2) = (not b1 or b2) true : Bool (0.000 sec for parse, 8 rewrites(0.000 sec), 57 matches)

31 Examples of Satisfiability %EQL> -- satisfiable boolean expressions red (b1 implies b2) iff (b1 iff b2). %EQL> -- reduce in %EQL : b1 implies b2 iff (b1 iff b2) b1 and b2 xor true xor b2 : Bool (0.000 sec for parse, 5 rewrites(0.000 sec), 28 matches) %EQL> red not((b1 implies b2) iff (b1 iff b2)). -- reduce in %EQL : not (b1 implies b2 iff (b1 iff b2)) b1 and b2 xor b2 : Bool (0.000 sec for parse, 8 rewrites(0.000 sec), 38 matches)

Computing Fundamentals 2 Introduction to CafeOBJ

Computing Fundamentals 2 Introduction to CafeOBJ Computing Fundamentals 2 Introduction to CafeOBJ Lecturer: Patrick Browne Lecture Room: K408 Lab Room: A308 Based on work by: Nakamura Masaki, João Pascoal Faria, Prof. Heinrich Hußmann. See notes on slides

More information

CafeOBJ. CafeOBJ. Starting CafeOBJ. Wolfgang Schreiner 1. A Quick Overview. 2.

CafeOBJ. CafeOBJ. Starting CafeOBJ. Wolfgang Schreiner 1. A Quick Overview. 2. CafeOBJ Wolfgang Schreiner Wolfgang.Schreiner@risc.uni-linz.ac.at 1. A Quick Overview Research Institute for Symbolic Computation (RISC) Johannes Kepler University, Linz, Austria http://www.risc.uni-linz.ac.at

More information

CS422 - Programming Language Design

CS422 - Programming Language Design 1 CS422 - Programming Language Design From SOS to Rewriting Logic Definitions Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign In this chapter we show how SOS language

More information

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic 3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax

More information

Dorel LUCANU. University Al.I.Cuza of Iaşi Department of Computer Science Berthelot Iaşi, Romania

Dorel LUCANU. University Al.I.Cuza of Iaşi Department of Computer Science Berthelot Iaşi, Romania Dorel LUCANU University Al.I.Cuza of Iaşi Department of Computer Science Berthelot 16 6600-Iaşi, Romania e-mail: dlucanu@infoiasi.ro Understanding CafeOBJ by examples (Introduction to concurrent object-oriented

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Chapter 2.1-2.7 p. 1/27 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

type classes & locales

type classes & locales Content Rough timeline Intro & motivation, getting started [1] COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray type classes & locales

More information

An Introduction to Programming and Proving in Agda (incomplete draft)

An Introduction to Programming and Proving in Agda (incomplete draft) An Introduction to Programming and Proving in Agda (incomplete draft) Peter Dybjer January 29, 2018 1 A first Agda module Your first Agda-file is called BoolModule.agda. Its contents are module BoolModule

More information

3.1 IMP: A Simple Imperative Language

3.1 IMP: A Simple Imperative Language Int = the domain of (unbounded) integer numbers, with usual operations on them Bool = the domain of Booleans Id = standard identifiers AExp = Int Id AExp +AExp AExp /AExp BExp = Bool AExp

More information

Operators. Java operators are classified into three categories:

Operators. Java operators are classified into three categories: Operators Operators are symbols that perform arithmetic and logical operations on operands and provide a meaningful result. Operands are data values (variables or constants) which are involved in operations.

More information

Inductive Definitions, continued

Inductive Definitions, continued 1 / 27 Inductive Definitions, continued Assia Mahboubi Jan 7th, 2016 2 / 27 Last lecture Introduction to Coq s inductive types: Introduction, elimination and computation rules; Twofold implementation :

More information

BOBJ: A Quickstart for Software Engineers

BOBJ: A Quickstart for Software Engineers BOBJ: A Quickstart for Software Engineers Lutz Hamel Dept. of Computer Science and Statistics University of Rhode Island Kingston, RI 02881 hamel@cs.uri.edu DRAFT 12/7/03 Getting Started BOBJ is a specification

More information

Efficient Monitoring of Safety Properties

Efficient Monitoring of Safety Properties Software Tools for Technology Transfer manuscript No. (will be inserted by the editor) Efficient Monitoring of Safety Properties Klaus Havelund 1, Grigore Roşu 2 1 Kestrel Technology NASA Ames Research

More information

Lecture 2: Big-Step Semantics

Lecture 2: Big-Step Semantics Lecture 2: Big-Step Semantics 1 Representing Abstract Syntax These are examples of arithmetic expressions: 2 * 4 1 + 2 + 3 5 * 4 * 2 1 + 2 * 3 We all know how to evaluate these expressions in our heads.

More information

First-Class Type Classes

First-Class Type Classes First-Class Type Classes Matthieu Sozeau Joint work with Nicolas Oury LRI, Univ. Paris-Sud - Démons Team & INRIA Saclay - ProVal Project Gallium Seminar November 3rd 2008 INRIA Rocquencourt Solutions for

More information

Data types for mcrl2

Data types for mcrl2 Data types for mcrl2 Aad Mathijssen April 5, 2018 We provide a syntax for the standard data types of the mcrl2 language. This syntax is intended to be a practical mix between standard mathematical notation

More information

i217 Functional Programming 7. Multisets

i217 Functional Programming 7. Multisets I217: Functional Programming 7. Kazuhiro Ogata i217 Functional Programming 7. 2 Roadmap the Mutex Protocol Simulator i217 Functional Programming 7. 3 Collections such that multiple occurrences of elements

More information

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1

HOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1 LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon

More information

LECTURE 17. Expressions and Assignment

LECTURE 17. Expressions and Assignment LECTURE 17 Expressions and Assignment EXPRESSION SYNTAX An expression consists of An atomic object, e.g. number or variable. An operator (or function) applied to a collection of operands (or arguments)

More information

c constructor P, Q terms used as propositions G, H hypotheses scope identifier for a notation scope M, module identifiers t, u arbitrary terms

c constructor P, Q terms used as propositions G, H hypotheses scope identifier for a notation scope M, module identifiers t, u arbitrary terms Coq quick reference Meta variables Usage Meta variables Usage c constructor P, Q terms used as propositions db identifier for a hint database s string G, H hypotheses scope identifier for a notation scope

More information

Coq quick reference. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ :=

Coq quick reference. Category Example Description. Inductive type with instances defined by constructors, including y of type Y. Inductive X : Univ := Coq quick reference Category Example Description Meta variables Usage Meta variables Usage c constructor P, Q terms used as propositions db identifier for a hint database s string G, H hypotheses scope

More information

RSL Reference Manual

RSL Reference Manual RSL Reference Manual Part No.: Date: April 6, 1990 Original Authors: Klaus Havelund, Anne Haxthausen Copyright c 1990 Computer Resources International A/S This document is issued on a restricted basis

More information

Lesson 4 Typed Arithmetic Typed Lambda Calculus

Lesson 4 Typed Arithmetic Typed Lambda Calculus Lesson 4 Typed Arithmetic Typed Lambda 1/28/03 Chapters 8, 9, 10 Outline Types for Arithmetic types the typing relation safety = progress + preservation The simply typed lambda calculus Function types

More information

Natural Numbers. We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general.

Natural Numbers. We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general. Natural Numbers We will use natural numbers to illustrate several ideas that will apply to Haskell data types in general. For the moment we will ignore that fact that each type in Haskell includes possible

More information

1 Lexical Considerations

1 Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2013 Handout Decaf Language Thursday, Feb 7 The project for the course is to write a compiler

More information

Programming Language Semantics A Rewriting Approach

Programming Language Semantics A Rewriting Approach Programming Language Semantics A Rewriting Approach Grigore Roșu University of Illinois at Urbana-Champaign 2.2 Basic Computability Elements In this section we recall very basic concepts of computability

More information

Functional Programming. Overview. Topics. Recall λ-terms. Examples

Functional Programming. Overview. Topics. Recall λ-terms. Examples Topics Functional Programming Christian Sternagel Harald Zankl Evgeny Zuenko Department of Computer Science University of Innsbruck WS 2017/2018 abstract data types, algebraic data types, binary search

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p. CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections 10.1-10.3 p. 1/106 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer

More information

Parsing. Zhenjiang Hu. May 31, June 7, June 14, All Right Reserved. National Institute of Informatics

Parsing. Zhenjiang Hu. May 31, June 7, June 14, All Right Reserved. National Institute of Informatics National Institute of Informatics May 31, June 7, June 14, 2010 All Right Reserved. Outline I 1 Parser Type 2 Monad Parser Monad 3 Derived Primitives 4 5 6 Outline Parser Type 1 Parser Type 2 3 4 5 6 What

More information

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.1

CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.1 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Section 17.1 Instructor: Carlos Varela Rensselaer Polytechnic Institute Spring 2018 CSCI.6962/4962

More information

Induction in Coq. Nate Foster Spring 2018

Induction in Coq. Nate Foster Spring 2018 Induction in Coq Nate Foster Spring 2018 Review Previously in 3110: Functional programming in Coq Logic in Coq Curry-Howard correspondence (proofs are programs) Today: Induction in Coq REVIEW: INDUCTION

More information

CS 320: Concepts of Programming Languages

CS 320: Concepts of Programming Languages CS 320: Concepts of Programming Languages Wayne Snyder Computer Science Department Boston University Lecture 04: Basic Haskell Continued o Polymorphic Types o Type Inference with Polymorphism o Standard

More information

Program analysis parameterized by the semantics in Maude

Program analysis parameterized by the semantics in Maude Program analysis parameterized by the semantics in Maude A. Riesco (joint work with I. M. Asăvoae and M. Asăvoae) Universidad Complutense de Madrid, Madrid, Spain Workshop on Logic, Algebra and Category

More information

7. Introduction to Denotational Semantics. Oscar Nierstrasz

7. Introduction to Denotational Semantics. Oscar Nierstrasz 7. Introduction to Denotational Semantics Oscar Nierstrasz Roadmap > Syntax and Semantics > Semantics of Expressions > Semantics of Assignment > Other Issues References > D. A. Schmidt, Denotational Semantics,

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Fall 2005 Handout 6 Decaf Language Wednesday, September 7 The project for the course is to write a

More information

Denotational Semantics. Domain Theory

Denotational Semantics. Domain Theory Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning

More information

CS 440: Programming Languages and Translators, Spring 2019 Mon

CS 440: Programming Languages and Translators, Spring 2019 Mon Haskell, Part 4 CS 440: Programming Languages and Translators, Spring 2019 Mon 2019-01-28 More Haskell Review definition by cases Chapter 6: Higher-order functions Revisit currying map, filter Unnamed

More information

Mathematically Rigorous Software Design Review of mathematical prerequisites

Mathematically Rigorous Software Design Review of mathematical prerequisites Mathematically Rigorous Software Design 2002 September 27 Part 1: Boolean algebra 1. Define the Boolean functions and, or, not, implication ( ), equivalence ( ) and equals (=) by truth tables. 2. In an

More information

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 1 Tuesday, January 29, 2013 1 Intro to semantics What is the meaning of a program? When we write a program, we use

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

Functional Programming. Pure Functional Languages

Functional Programming. Pure Functional Languages Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure

More information

Lecture 19: Functions, Types and Data Structures in Haskell

Lecture 19: Functions, Types and Data Structures in Haskell The University of North Carolina at Chapel Hill Spring 2002 Lecture 19: Functions, Types and Data Structures in Haskell Feb 25 1 Functions Functions are the most important kind of value in functional programming

More information

CSC Discrete Math I, Spring Sets

CSC Discrete Math I, Spring Sets CSC 125 - Discrete Math I, Spring 2017 Sets Sets A set is well-defined, unordered collection of objects The objects in a set are called the elements, or members, of the set A set is said to contain its

More information

THE AGDA STANDARD LIBRARY

THE AGDA STANDARD LIBRARY THE AGDA STANDARD LIBRARY N. P. STRICKLAND 1. Introduction In this document we give a survey of the structure, organisation and contents of the Agda standard library. We will mostly ignore foundational

More information

Logic Haskell Exercises

Logic Haskell Exercises Logic Haskell Exercises Young W. Lim 2018-09-15 Sat Young W. Lim Logic Haskell Exercises 2018-09-15 Sat 1 / 36 Outline 1 Based on 2 Logic Using TAMO.hs Young W. Lim Logic Haskell Exercises 2018-09-15 Sat

More information

A Small Interpreted Language

A Small Interpreted Language A Small Interpreted Language What would you need to build a small computing language based on mathematical principles? The language should be simple, Turing equivalent (i.e.: it can compute anything that

More information

Outline Mousavi: ADT

Outline Mousavi: ADT Outline Abstract Data Types Mohammad Mousavi Eindhoven University of Technology, The Netherlands Requirement Analysis and Design Verification (RADV) Outline Outline Basic Concepts Booleans Standard Data

More information

Algebraic specification and verification with CafeOBJ Part 1 Introduction

Algebraic specification and verification with CafeOBJ Part 1 Introduction Algebraic specification and verification with CafeOBJ Part 1 Introduction Norbert Preining ESSLLI 2016 Bozen, August 2016 Algebraic specification and verification with CafeOBJ [5pt]Part 1 Introduction

More information

Lexical Considerations

Lexical Considerations Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.035, Spring 2010 Handout Decaf Language Tuesday, Feb 2 The project for the course is to write a compiler

More information

Evaluation Trees for Proposition Algebra

Evaluation Trees for Proposition Algebra Evaluation Trees for Proposition Algebra Alban Ponse joined work with Jan A. Bergstra section Theory of Computer Science Informatics Institute, University of Amsterdam https://staff.fnwi.uva.nl/a.ponse/

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

Types Summer School Gothenburg Sweden August Dogma oftype Theory. Everything has a type

Types Summer School Gothenburg Sweden August Dogma oftype Theory. Everything has a type Types Summer School Gothenburg Sweden August 2005 Formalising Mathematics in Type Theory Herman Geuvers Radboud University Nijmegen, NL Dogma oftype Theory Everything has a type M:A Types are a bit like

More information

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,,

Definition: A context-free grammar (CFG) is a 4- tuple. variables = nonterminals, terminals, rules = productions,, CMPSCI 601: Recall From Last Time Lecture 5 Definition: A context-free grammar (CFG) is a 4- tuple, variables = nonterminals, terminals, rules = productions,,, are all finite. 1 ( ) $ Pumping Lemma for

More information

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic.

Overview. CS389L: Automated Logical Reasoning. Lecture 6: First Order Logic Syntax and Semantics. Constants in First-Order Logic. Overview CS389L: Automated Logical Reasoning Lecture 6: First Order Logic Syntax and Semantics Işıl Dillig So far: Automated reasoning in propositional logic. Propositional logic is simple and easy to

More information

Introduction to Computer Architecture

Introduction to Computer Architecture Boolean Operators The Boolean operators AND and OR are binary infix operators (that is, they take two arguments, and the operator appears between them.) A AND B D OR E We will form Boolean Functions of

More information

ISR 2014 Strategies. Hélène KIRCHNER Inria. August Topics, Objectives, Contents. Hélène KIRCHNER Inria ISR 2014 Strategies 1 / 48

ISR 2014 Strategies. Hélène KIRCHNER Inria. August Topics, Objectives, Contents. Hélène KIRCHNER Inria ISR 2014 Strategies 1 / 48 ISR 2014 Strategies Hélène KIRCHNER Inria August 2014 Topics, Objectives, Contents Hélène KIRCHNER Inria ISR 2014 Strategies 1 / 48 Computation, Deduction and Strategies Series of workshops since 1997

More information

Programming Languages Fall 2014

Programming Languages Fall 2014 Programming Languages Fall 2014 Lecture 7: Simple Types and Simply-Typed Lambda Calculus Prof. Liang Huang huang@qc.cs.cuny.edu 1 Types stuck terms? how to fix it? 2 Plan First I For today, we ll go back

More information

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Design

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Design CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS422 Programming Language Design Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and tools,

More information

Introduction to dependent types in Coq

Introduction to dependent types in Coq October 24, 2008 basic use of the Coq system In Coq, you can play with simple values and functions. The basic command is called Check, to verify if an expression is well-formed and learn what is its type.

More information

Programming Languages Third Edition

Programming Languages Third Edition Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand

More information

Haskell Scripts. Yan Huang

Haskell Scripts. Yan Huang Haskell Scripts Yan Huang yh33@indiana.edu Last Quiz Objectives Writing Haskell programs in.hs files Note some differences between programs typed into GHCi and programs written in script files Operator

More information

Functional Programming. Pure Functional Languages

Functional Programming. Pure Functional Languages Functional Programming Pure functional PLs S-expressions cons, car, cdr Defining functions read-eval-print loop of Lisp interpreter Examples of recursive functions Shallow, deep Equality testing 1 Pure

More information

CS 440: Programming Languages and Translators, Spring 2019 Mon 2/4

CS 440: Programming Languages and Translators, Spring 2019 Mon 2/4 Haskell, Part 5 CS 440: Programming Languages and Translators, Spring 2019 Mon 2/4 More Haskell Miscellaneous topics Simple I/O, do blocks, actions Modules data vs type declaration Instances of classtypes

More information

LASER 2011 Summerschool Elba Island, Italy Basics of COQ

LASER 2011 Summerschool Elba Island, Italy Basics of COQ LASER 2011 Summerschool Elba Island, Italy Basics of COQ Christine Paulin-Mohring September 2, 2011 Contents 1 First steps in COQ 2 1.1 Launching COQ....................................... 2 1.2 Syntax

More information

Inductive data types (I)

Inductive data types (I) 5th Asian-Pacific Summer School on Formal Methods August 5-10, 2013, Tsinghua University, Beijing, China Inductive data types (I) jean-jacques.levy@inria.fr 2013-8-6 http://sts.thss.tsinghua.edu.cn/coqschool2013

More information

CIS 500: Software Foundations

CIS 500: Software Foundations CIS 500: Software Foundations Midterm I October 4, 2016 Name (printed): Username (PennKey login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic

More information

Data-Oriented System Development

Data-Oriented System Development Data-Oriented System Development Prof. Martin Wirsing 30.10.2002 Refinement Technics The Refinement-Concept: Refinement through Inclusion of Model Classes 2 Goals Refinement of functional requirements:

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.

More information

Autosubst Manual. May 20, 2016

Autosubst Manual. May 20, 2016 Autosubst Manual May 20, 2016 Formalizing syntactic theories with variable binders is not easy. We present Autosubst, a library for the Coq proof assistant to automate this process. Given an inductive

More information

Verifying the Correctness of Compile Imperative Programming Language. Supervisor: Professor Futatsugi Koki of Information, Master Course

Verifying the Correctness of Compile Imperative Programming Language. Supervisor: Professor Futatsugi Koki of Information, Master Course JAIST Reposi https://dspace.j Title Verifying the Correctness of Compile Imperative Programming Language Author(s)Trinh, Bao Ngoc Quoc Citation Issue Date 2011-03 Type Thesis or Dissertation Text version

More information

Analysis of dependent types in Coq through the deletion of the largest node of a binary search tree

Analysis of dependent types in Coq through the deletion of the largest node of a binary search tree Analysis of dependent types in Coq through the deletion of the largest node of a binary search tree Sneha Popley and Stephanie Weirich August 14, 2008 Abstract Coq reflects some significant differences

More information

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics

CMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End

More information

Principles of Programming Languages COMP251: Syntax and Grammars

Principles of Programming Languages COMP251: Syntax and Grammars Principles of Programming Languages COMP251: Syntax and Grammars Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology Hong Kong, China Fall 2007

More information

Softwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008

Softwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008 Softwaretechnik Lecture 03: Types and Type Soundness Peter Thiemann University of Freiburg, Germany SS 2008 Peter Thiemann (Univ. Freiburg) Softwaretechnik SWT 1 / 35 Table of Contents Types and Type correctness

More information

3 Pairs and Lists. 3.1 Formal vs. Informal Proofs

3 Pairs and Lists. 3.1 Formal vs. Informal Proofs 3 Pairs and Lists 3.1 Formal vs. Informal Proofs The question of what, exactly, constitutes a proof of a mathematical claim has challenged philosophers throughout the ages. A rough and ready definition,

More information

Data Abstraction. An Abstraction for Inductive Data Types. Philip W. L. Fong.

Data Abstraction. An Abstraction for Inductive Data Types. Philip W. L. Fong. Data Abstraction An Abstraction for Inductive Data Types Philip W. L. Fong pwlfong@cs.uregina.ca Department of Computer Science University of Regina Regina, Saskatchewan, Canada Introduction This lecture

More information

Software Verification : Introduction

Software Verification : Introduction Software Verification : Introduction Ranjit Jhala, UC San Diego April 4, 2013 What is Algorithmic Verification? Algorithms, Techniques and Tools to ensure that Programs Don t Have Bugs (What does that

More information

F28PL1 Programming Languages. Lecture 11: Standard ML 1

F28PL1 Programming Languages. Lecture 11: Standard ML 1 F28PL1 Programming Languages Lecture 11: Standard ML 1 Imperative languages digital computers are concrete realisations of von Neumann machines stored program memory associations between addresses and

More information

Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions

Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions Recursion and Induction: Haskell; Primitive Data Types; Writing Function Definitions Greg Plaxton Theory in Programming Practice, Spring 2005 Department of Computer Science University of Texas at Austin

More information

CSE-321 Programming Languages 2010 Midterm

CSE-321 Programming Languages 2010 Midterm Name: Hemos ID: CSE-321 Programming Languages 2010 Midterm Score Prob 1 Prob 2 Prob 3 Prob 4 Total Max 15 30 35 20 100 1 1 SML Programming [15 pts] Question 1. [5 pts] Give a tail recursive implementation

More information

Using big-step and small-step semantics in Maude to perform declarative debugging

Using big-step and small-step semantics in Maude to perform declarative debugging Using big-step and small-step semantics in Maude to perform declarative debugging Adrián Riesco Universidad Complutense de Madrid, Madrid, Spain FLOPS 2014, Kanazawa June 4, 2014 A. Riesco (UCM) Using

More information

The Maude 2.0 System. M. Clavel F. Durán S. Eker P. Lincoln. N. Martí-Oliet J. Meseguer C. Talcott

The Maude 2.0 System. M. Clavel F. Durán S. Eker P. Lincoln. N. Martí-Oliet J. Meseguer C. Talcott The Maude 2.0 System M. Clavel F. Durán S. Eker P. Lincoln N. Martí-Oliet J. Meseguer C. Talcott 1 Overview Maude is a language based on rewriting logic. Type system is based on membership equation logic.

More information

Infinite Objects and Proofs 1

Infinite Objects and Proofs 1 Infinite Objects and Proofs 1 Pierre Castéran Beijing, August 2009 1 This lecture corresponds to the chapter 13 : Infinite Objects and Proofs of the book. In this lecture, we shall see how to represent

More information

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program 1 By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program variables. Apply C++ syntax rules to declare variables, initialize

More information

Exercise 1 (2+2+2 points)

Exercise 1 (2+2+2 points) 1 Exercise 1 (2+2+2 points) The following data structure represents binary trees only containing values in the inner nodes: data Tree a = Leaf Node (Tree a) a (Tree a) 1 Consider the tree t of integers

More information

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation

CS /534 Compiler Construction University of Massachusetts Lowell. NOTHING: A Language for Practice Implementation CS 91.406/534 Compiler Construction University of Massachusetts Lowell Professor Li Xu Fall 2004 NOTHING: A Language for Practice Implementation 1 Introduction NOTHING is a programming language designed

More information

Expr_annotated.v. Expr_annotated.v. Printed by Zach Tatlock

Expr_annotated.v. Expr_annotated.v. Printed by Zach Tatlock Oct 05, 16 8:02 Page 1/14 * Lecture 03 Include some useful libraries. Require Import Bool. Require Import List. Require Import String. Require Import ZArith. Require Import Omega. List provides the cons

More information

n n Try tutorial on front page to get started! n spring13/ n Stack Overflow!

n   n Try tutorial on front page to get started! n   spring13/ n Stack Overflow! Announcements n Rainbow grades: HW1-6, Quiz1-5, Exam1 n Still grading: HW7, Quiz6, Exam2 Intro to Haskell n HW8 due today n HW9, Haskell, out tonight, due Nov. 16 th n Individual assignment n Start early!

More information

Control Flow February 9, Lecture 7

Control Flow February 9, Lecture 7 Chapter 6 Control Flow February 9, Lecture 7 Expressions A simple object Literal constant Named variable Constant Or a function applied to arguments For built-in functions we use the term operator (like

More information

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators Course Name: Advanced Java Lecture 2 Topics to be covered Variables Operators Variables -Introduction A variables can be considered as a name given to the location in memory where values are stored. One

More information

The Maude LTL LBMC Tool Tutorial

The Maude LTL LBMC Tool Tutorial The Maude LTL LBMC Tool Tutorial Kyungmin Bae 1, Santiago Escobar 2, and José Meseguer 1 1 University of Illinois at Urbana-Champaign, IL, USA 2 Universidad Politécnica de Valencia, Spain Abstract. A concurrent

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Lambda Calculus and Type Inference

Lambda Calculus and Type Inference Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type

More information

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics

[Ch 6] Set Theory. 1. Basic Concepts and Definitions. 400 lecture note #4. 1) Basics 400 lecture note #4 [Ch 6] Set Theory 1. Basic Concepts and Definitions 1) Basics Element: ; A is a set consisting of elements x which is in a/another set S such that P(x) is true. Empty set: notated {

More information

The ITP Tool s Manual

The ITP Tool s Manual The ITP Tool s Manual Manuel Clavel and Miguel Palomino Departamento de Sistemas Informáticos y Programación Universidad Complutense de Madrid clavel@sip.ucm.es miguelpt@sip.ucm.es April 12, 2005 Abstract

More information

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER COMPILERS ANSWERS. Time allowed TWO hours

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER COMPILERS ANSWERS. Time allowed TWO hours The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER 2009 2010 COMPILERS ANSWERS Time allowed TWO hours Candidates may complete the front cover of their answer book

More information

More Untyped Lambda Calculus & Simply Typed Lambda Calculus

More Untyped Lambda Calculus & Simply Typed Lambda Calculus Concepts in Programming Languages Recitation 6: More Untyped Lambda Calculus & Simply Typed Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky,

More information

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS

This is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS 1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be

More information

CA4003 Compiler Construction Assignment Language Definition

CA4003 Compiler Construction Assignment Language Definition CA4003 Compiler Construction Assignment Language Definition David Sinclair 2017-2018 1 Overview The language is not case sensitive. A nonterminal, X, is represented by enclosing it in angle brackets, e.g.

More information

A Rewriting Logic Approach to Operational Semantics

A Rewriting Logic Approach to Operational Semantics A Rewriting Logic Approach to Operational Semantics Traian Florin Şerbănuţă, Grigore Roşu and José Meseguer Department of Computer Science, University of Illinois at Urbana-Champaign. {tserban2,grosu,meseguer}@cs.uiuc.edu

More information