What s in Main. Tobias Nipkow. December 5, Abstract

Similar documents
Standard prelude. Appendix A. A.1 Classes

Theorem Proving Principles, Techniques, Applications Recursion

Functional Programming and Modeling

Lecture 4: Higher Order Functions

Shell CSCE 314 TAMU. Higher Order Functions

(ii) Define a function ulh that takes a list xs, and pairs each element with all other elements in xs.

MLW. Henk Barendregt and Freek Wiedijk assisted by Andrew Polonsky. March 26, Radboud University Nijmegen

Watch out for the arrows. Recollecting Haskell, Part V. A start on higher types: Mapping, 1. A start on higher types: Mapping, 2.

CSCE 314 Programming Languages

PROGRAMMING IN HASKELL. Chapter 5 - List Comprehensions

Data types for mcrl2

A general introduction to Functional Programming using Haskell

CSCE 314 TAMU Fall CSCE 314: Programming Languages Dr. Flemming Andersen. Haskell Functions

Haskell Overview II (2A) Young Won Lim 9/26/16

Haskell through HUGS THE BASICS

General Computer Science (CH ) Fall 2016 SML Tutorial: Practice Problems

Inductive datatypes in HOL. lessons learned in Formal-Logic Engineering

Exercises on ML. Programming Languages. Chanseok Oh

Programming Languages 3. Definition and Proof by Induction

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics

CS 457/557: Functional Languages

Overview. A Compact Introduction to Isabelle/HOL. Tobias Nipkow. System Architecture. Overview of Isabelle/HOL

A list is a finite sequence of elements. Elements may appear more than once

CSc 372. Comparative Programming Languages. 11 : Haskell Higher-Order Functions. Department of Computer Science University of Arizona

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

CSc 520 Principles of Programming Languages. Currying Revisited... Currying Revisited. 16: Haskell Higher-Order Functions

Higher-Order Functions

CSCE 314 Programming Languages

Pattern Matching and Abstract Data Types

It is better to have 100 functions operate one one data structure, than 10 functions on 10 data structures. A. Perlis

2 Programming and Proving

Programming Language Concepts: Lecture 14

Denotational Semantics. Domain Theory

Isabelle s meta-logic. p.1

Introduction to SML Basic Types, Tuples, Lists, Trees and Higher-Order Functions

EDAF40. 2nd June :00-19:00. WRITE ONLY ON ONE SIDE OF THE PAPER - the exams will be scanned in and only the front/ odd pages will be read.

Haske k ll An introduction to Functional functional programming using Haskell Purely Lazy Example: QuickSort in Java Example: QuickSort in Haskell

A tour of the Haskell Prelude

CS 320: Concepts of Programming Languages

GADTs. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 7. [Faculty of Science Information and Computing Sciences]

GADTs. Wouter Swierstra. Advanced functional programming - Lecture 7. Faculty of Science Information and Computing Sciences

CSc 372 Comparative Programming Languages

An introduction introduction to functional functional programming programming using usin Haskell

Chapter 3 Linear Structures: Lists

GADTs. Alejandro Serrano. AFP Summer School. [Faculty of Science Information and Computing Sciences]

Specification, Verification, and Interactive Proof

CSc 372. Comparative Programming Languages. 8 : Haskell Function Examples. Department of Computer Science University of Arizona

CS 440: Programming Languages and Translators, Spring 2019 Mon

Lecture 5: Lazy Evaluation and Infinite Data Structures

02157 Functional Programming. Michael R. Ha. Disjoint Unions and Higher-order list functions. Michael R. Hansen

Lecture 2: List algorithms using recursion and list comprehensions

CITS3211 FUNCTIONAL PROGRAMMING. 6. Folding operators

CSci 4223 Principles of Programming Languages

CSE 3302 Programming Languages Lecture 8: Functional Programming

Basic Foundations of Isabelle/HOL

Chapter 3 Linear Structures: Lists

Haskell Overview II (2A) Young Won Lim 8/9/16

CSE-321 Programming Languages 2012 Midterm

Haskell: Lists. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Friday, February 24, Glenn G.

Programming with Universes, Generically

Mathematics for Computer Scientists 2 (G52MC2)

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

Datatype declarations

CSE-321 Programming Languages 2010 Midterm

Logic - CM0845 Introduction to Haskell

INTRODUCTION TO HASKELL

Haskell Overview II (2A) Young Won Lim 8/23/16

Lambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6

1 The smallest free number

IFAD. VDMTools Validated. Design through Modelling. Overview of VDM -SL/++ IFAD. IFAD A/S Forskerparken 10 DK-5230 Odense M Denmark.

Programming and Proving in Isabelle/HOL

Static Contract Checking for Haskell

Functional Programming for Logicians - Lecture 1

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

Tentamen Functioneel Programmeren 2001 Informatica, Universiteit Utrecht Docent: Wishnu Prasetya

10 Years of Partiality and General Recursion in Type Theory

CSE399: Advanced Programming. Handout 2

Lists. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca

Practical Haskell. An introduction to functional programming. July 21, Practical Haskell. Juan Pedro Villa-Isaza. Introduction.

Cryptol version 2 Syntax

SML A F unctional Functional Language Language Lecture 19

The Ruby Interpreter. Graham Hutton Chalmers University of Technology Göteborg, Sweden

Efficient Mergesort. Christian Sternagel. August 28, 2014

a brief introduction to (dependent) type theory

A Third Look At ML. Chapter Nine Modern Programming Languages, 2nd ed. 1

Shell CSCE 314 TAMU. Haskell Functions

Programming in Omega Part 1. Tim Sheard Portland State University

Haskell 98 in short! CPSC 449 Principles of Programming Languages

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

CSCI-GA Final Exam

COMP4161: Advanced Topics in Software Verification. fun. Gerwin Klein, June Andronick, Ramana Kumar S2/2016. data61.csiro.au

Programming Languages Fall 2013

CSE 130 [Winter 2014] Programming Languages

Functional Programming - 2. Higher Order Functions

CSE341: Programming Languages Lecture 9 Function-Closure Idioms. Dan Grossman Fall 2011

Higher-Order Logic. Specification and Verification with Higher-Order Logic

Haskell Refresher Informatics 2D

Functional Programming. Overview. Topics. Definition n-th Fibonacci Number. Graph

Efficient Mergesort. Christian Sternagel. October 11, 2017

An Overview of Miranda

Transcription:

What s in Main Tobias Nipkow December 5, 2013 Abstract This document lists the main types, functions and syntax provided by theory Main. It is meant as a quick overview of what is available. For infix operators and their precedences see the final section. The sophisticated class structure is only hinted at. For details see http://isabelle.in.tum.de/library/ HOL/. HOL The basic logic: x = y, True, False, P, P Q, P Q, P Q, x. P, x. P,!x. P, THE x. P. undefined :: a default :: a x y (x = y) (~=) P Q P = Q if x then y else z If x y z let x = e 1 in e 2 Let e 1 (λx. e 2 ) Orderings A collection of classes defining basic orderings: preorder, partial order, linear order, dense linear order and wellorder. op :: a a bool (<=) op < :: a a bool Least :: ( a bool) a min :: a a a max :: a a a 1

top :: a bot :: a mono :: ( a b) bool strict-mono :: ( a b) bool x y y x (>=) x > y y < x x y. P x. x y P x y. P x. x y P Similarly for <, and > LEAST x. P Least (λx. P) Lattices Classes semilattice, lattice, distributive lattice and complete lattice (the latter in theory Set). inf :: a a a sup :: a a a Inf :: a set a Sup :: a set a Available by loading theory Lattice- in directory Library. x y x y x y x < y x y inf x y x y sup x y A Sup A A Inf A top bot Set {} :: a set insert :: a a set a set Collect :: ( a bool) a set op :: a a set bool (:) op :: a set a set a set (Un) op :: a set a set a set (Int) 2

UNION :: a set ( a b set) b set INTER :: a set ( a b set) b set Union :: a set set a set Inter :: a set set a set Pow :: a set a set set UNIV :: a set op :: ( a b) a set b set Ball :: a set ( a bool) bool Bex :: a set ( a bool) bool {a 1,...,a n } insert a 1 (... (insert a n {})...) a / A (x A) A B A B A B A < B A B B A A B B < A {x. P} Collect (λx. P) {t x 1... x n. P} {v. x 1... x n. v = t P} x I. A UNION I (λx. A) (UN) x. A UNION UNIV (λx. A) x I. A INTER I (λx. A) (INT) x. A INTER UNIV (λx. A) x A. P Ball A (λx. P) x A. P Bex A (λx. P) range f f UNIV Fun id :: a a op :: ( a b) ( c a) c b (o) inj-on :: ( a b) a set bool inj :: ( a b) bool surj :: ( a b) bool bij :: ( a b) bool bij-betw :: ( a b) a set b set bool fun-upd :: ( a b) a b a b f (x := y) fun-upd f x y f (x 1 :=y 1,...,x n :=y n ) f (x 1 :=y 1 )...(x n :=y n ) 3

Hilbert Choice Hilbert s selection (ε) operator: SOME x. P. inv-into :: a set ( a b) b a inv inv-into UNIV Fixed Points Theory: Inductive. Least and greatest fixed points in a complete lattice a: lfp :: ( a a) a gfp :: ( a a) a Note that in particular sets ( a bool) are complete lattices. Sum Type Type constructor +. Inl :: a a + b Inr :: a b + a op <+> :: a set b set ( a + b) set Product Type Types unit and. () :: unit Pair :: a b a b fst :: a b a snd :: a b b split :: ( a b c) a b c curry :: ( a b c) a b c Sigma :: a set ( a b set) ( a b) set (a, b) Pair a b λ(x, y). t split (λx y. t) A B Sigma A (λ. B) (<*>) Pairs may be nested. Nesting to the right is printed as a tuple, e.g. (a, b, c) is really (a, (b, c)). Pattern matching with pairs and tuples extends to all binders, e.g. 4

(x, y) A. P, {(x, y). P}, etc. Relation converse :: ( a b) set ( b a) set op O :: ( a b) set ( b c) set ( a c) set op :: ( a b) set a set b set inv-image :: ( a a) set ( b a) ( b b) set Id-on :: a set ( a a) set Id :: ( a a) set Domain :: ( a b) set a set Range :: ( a b) set b set Field :: ( a a) set a set refl-on :: a set ( a a) set bool refl :: ( a a) set bool sym :: ( a a) set bool antisym :: ( a a) set bool trans :: ( a a) set bool irrefl :: ( a a) set bool total-on :: a set ( a a) set bool total :: ( a a) set bool r 1 converse r (^-1) Type synonym a rel = ( a a) set Equiv Relations equiv :: a set ( a a) set bool op // :: a set ( a a) set a set set congruent :: ( a a) set ( a b) bool congruent2 :: ( a a) set ( b b) set ( a b c) bool f respects r congruent r f f respects2 r congruent2 r r f 5

Transitive Closure rtrancl :: ( a a) set ( a a) set trancl :: ( a a) set ( a a) set reflcl :: ( a a) set ( a a) set acyclic :: ( a a) set bool op ˆˆ :: ( a a) set nat ( a a) set r rtrancl r (^*) r + trancl r (^+) r = reflcl r (^=) Algebra Theories Groups, Rings, Fields and Divides define a large collection of classes describing common algebraic structures from semigroups up to fields. Everything is done in terms of overloaded operators: 0 :: a 1 :: a op + :: a a a op :: a a a uminus :: a a (-) op :: a a a inverse :: a a op / :: a a a abs :: a a sgn :: a a op dvd :: a a bool op div :: a a a op mod :: a a a x abs x Nat datatype nat = 0 Suc nat op + op op op ˆ op div op mod op dvd op op < min max Min Max of-nat :: nat a op ˆˆ :: ( a a) nat a a 6

Int Type int op + op uminus op op ˆ op div op mod op dvd op op < min max Min Max abs sgn nat :: int nat of-int :: int a Z :: a set (Ints) int of-nat Finite Set finite :: a set bool card :: a set nat Finite-Set.fold :: ( a b b) b a set b setsum :: ( a b) a set b setprod :: ( a b) a set b A setsum (λx. x) A (SUM) x A. t setsum (λx. t) A x P. t x P. t Similarly for instead of (PROD) Wellfounded wf :: ( a a) set bool acc :: ( a a) set a set measure :: ( a nat) ( a a) set op < lex > :: ( a a) set ( b b) set (( a b) a b) set op < mlex > :: ( a nat) ( a a) set ( a a) set less-than :: (nat nat) set pred-nat :: (nat nat) set Set Interval 7

lessthan :: a a set atmost :: a a set greaterthan :: a a set atleast :: a a set greaterthanlessthan :: a a a set atleastlessthan :: a a a set greaterthanatmost :: a a a set atleastatmost :: a a a set {..<y} lessthan y {..y} atmost y {x <..} greaterthan x {x..} atleast x {x <..<y} greaterthanlessthan x y {x..<y} atleastlessthan x y {x <..y} greaterthanatmost x y {x..y} atleastatmost x y i n. A i {..n}. A i<n. A i {..<n}. A Similarly for instead of x = a..b. t setsum (λx. t) {a..b} x = a..<b. t setsum (λx. t) {a..<b} x b. t setsum (λx. t) {..b} x<b. t setsum (λx. t) {..<b} Similarly for instead of Power op ˆ :: a nat a Option datatype a option = None Some a the :: a option a Option.map :: ( a b) a option b option Option.set :: a option a set Option.bind :: a option ( a b option) b option List datatype a list = [] op # a ( a list) 8

op @ :: a list a list a list butlast :: a list a list concat :: a list list a list distinct :: a list bool drop :: nat a list a list dropwhile :: ( a bool) a list a list filter :: ( a bool) a list a list List.find :: ( a bool) a list a option fold :: ( a b b) a list b b foldr :: ( a b b) a list b b foldl :: ( a b a) a b list a hd :: a list a last :: a list a length :: a list nat lenlex :: ( a a) set ( a list a list) set lex :: ( a a) set ( a list a list) set lexn :: ( a a) set nat ( a list a list) set lexord :: ( a a) set ( a list a list) set listrel :: ( a b) set ( a list b list) set listrel1 :: ( a a) set ( a list a list) set lists :: a set a list set listset :: a set list a list set listsum :: a list a list-all2 :: ( a b bool) a list b list bool list-update :: a list nat a a list map :: ( a b) a list b list measures :: ( a nat) list ( a a) set op! :: a list nat a remdups :: a list a list removeall :: a a list a list remove1 :: a a list a list replicate :: nat a a list rev :: a list a list rotate :: nat a list a list rotate1 :: a list a list set :: a list a set sort :: a list a list sorted :: a list bool splice :: a list a list a list sublist :: a list nat set a list take :: nat a list a list 9

takewhile :: ( a bool) a list a list tl :: a list a list upt :: nat nat nat list upto :: int int int list zip :: a list b list ( a b) list [x 1,...,x n ] x 1 #... # x n # [] [m..<n] upt m n [i..j ] upto i j [e. x xs] map (λx. e) xs [x xs. b] filter (λx. b) xs xs[n := x] list-update xs n x x xs. e listsum (map (λx. e) xs) List comprehension: [e. q 1,..., q n ] where each qualifier q i pat e or a guard, i.e. boolean expression. is either a generator Map Maps model partial functions and are often used as finite tables. However, the domain of a map may be infinite. Map.empty :: a b option op ++ :: ( a b option) ( a b option) a b option op m :: ( a b option) ( c a option) c b option op :: ( a b option) a set a b option dom :: ( a b option) a set ran :: ( a b option) b set op m :: ( a b option) ( a b option) bool map-of :: ( a b) list a b option map-upds :: ( a b option) a list b list a b option Map.empty λx. None m(x y) m(x:=some y) m(x 1 y 1,...,x n y n ) m(x 1 y 1 )...(x n y n ) [x 1 y 1,...,x n y n ] Map.empty(x 1 y 1,...,x n y n ) m(xs [ ] ys) map-upds m xs ys 10

Infix operators in Main Operator precedence associativity Meta-logic = 1 right 2 Logic 35 right 30 right, 25 right =, 50 left Orderings, <,, > 50 Sets,,, 50, / 50 70 left 65 left Functions and Relations 55 left 90 right O 75 right 90 right Numbers +, 65 left, / 70 left div, mod 70 left ˆ 80 right ˆˆ 80 right dvd 50 Lists #, @ 65 right! 100 left 11