How to get an efficient yet verified arbitrary-precision integer library

Size: px
Start display at page:

Download "How to get an efficient yet verified arbitrary-precision integer library"

Transcription

1 How to get an efficient yet verified arbitrary-precision integer library Raphaël Rieu-Helft TrustInSoft Inria March 13, 2018 March 13, / 36

2 Context, motivation, goals goal: efficient and formally verified large-integer library GMP: widely-used, high-performance library safety-critical tested, but hard to ensure good coverage (unlikely branches) correctness bugs have been found in the past idea: 1 formally verify GMP algorithms with Why3 2 extract efficient C code March 13, / 36

3 Outline 1 Reimplementing GMP using Why3 2 Extracting to idiomatic C code 3 An example: schoolbook multiplication 4 Computational reflection in Why3 5 Impure programs as decision procedures 6 Benchmarks, conclusions March 13, / 36

4 Reimplementing GMP using Why3 Reimplementing GMP using Why3 March 13, / 36

5 Reimplementing GMP using Why3 Tool: the Why3 platform file.mlw Why3 file.ml file.c Alt-Ergo CVC4 Z3 etc. approach: implement the GMP algorithms in WhyML verify them with Why3 extract to C difficulties: preserve all GMP implementation tricks prove them correct extract to efficient C code March 13, / 36

6 Reimplementing GMP using Why3 An example: comparison large integer pointer to array of unsigned integers a 0... a n 1 called limbs value(a, n) = n 1 a i β i usually β = 2 64 i=0 type ptr a =... exception Return32 int32 let wmpn_cmp (x y: ptr uint64) (sz: int32): int32 = let i = ref sz in try while!i 1 do i :=!i - 1; let lx = x[!i] in let ly = y[!i] in if lx ly then if lx > ly then raise (Return32 1) else raise (Return32 (-1)) done; 0 with Return32 r r end March 13, / 36

7 Reimplementing GMP using Why3 Memory model simple memory model, more restrictive than C type ptr a = abstract { mutable data: array a ; offset: int } predicate valid (p:ptr a) (sz:int) = 0 sz 0 p.offset p.offset + sz plength p p.data p.offset }{{} valid(p,5) val malloc (sz:uint32) : ptr a (* malloc(sz * sizeof( a)) *)... val free (p:ptr a) : unit (* free(p) *)... no explicit address for pointers March 13, / 36

8 Reimplementing GMP using Why3 Alias control aliased C pointers point to the same memory object aliased Why3 pointers same data field only way to get aliased pointers: incr type ptr a = abstract { mutable data: array a ; offset: int } val incr (p:ptr a) (ofs:int32): ptr a (* p+ofs *) alias { result.data with p.data } ensures { result.offset = p.offset + ofs }... val free (p:ptr a) : unit requires { p.offset = 0 } writes { p.data } ensures { p.data.length = 0 } Why3 type system: all aliases are known statically no need to prove non-aliasing hypotheses March 13, / 36

9 Reimplementing GMP using Why3 Example specification: long multiplication specifications are defined in terms of value (** [wmpn_mul r x y sx sy] multiplies [(x, sx)] and [(y,sy)] and writes the result in [(r, sx+sy)]. [sx] must be greater than or equal to [sy]. Corresponds to [mpn_mul]. *) let wmpn_mul (r x y: ptr uint64) (sx sy: int32) : unit requires { 0 < sy sx } requires { valid x sx } requires { valid y sy } requires { valid r (sy + sx) } writes { r.data.elts } ensures { value r (sy + sx) = value x sx * value y sy } Why3 typing constraint: r cannot be aliased to x or y simplifies proofs : aliases are known statically we need another function for in-place multiplication March 13, / 36

10 Extracting to idiomatic C code Extracting to idiomatic C code March 13, / 36

11 Extracting to idiomatic C code Extraction mechanism goals: simple, straightforward extraction (trusted) performance: no added complexity, no closures or indirections inefficiencies caused by extraction must be optimizable by the compiler tradeoff: handle only a small, C-like fragment of WhyML loops references machine integers manual memory management polymorphism, abstract types higher order mathematical integers garbage collection March 13, / 36

12 Extracting to idiomatic C code Exceptions and return/break statements return and break are emulated by exceptions in WhyML recognize the patterns, extract as native return/break reject all other exceptions let f (args) =... ; try (* tail position *)... raise (R e)... with R v v end f ( args ) {...;...; return e;... } try while... do... raise B... done with B () end while... {... break ;... } March 13, / 36

13 Extracting to idiomatic C code Multiple return values WhyML uses tuples for functions that return multiple values extra pointer parameters for these functions, write the results there let f (a: int32) : (int32,int32) = let b = a+a in (a,b) let g () : int32 = let x = Int32.of_int 42 in let (y,z) = f x in z - y void f( int32_t * result, int32_t * result1, int32_t a) { int32_t b; b = (a + a); (* result ) = a; (* result1 ) = b; return ; } int32_t g() { int32_t y, z; f(&y, &z, 42); return (z - y); } March 13, / 36

14 Extracting to idiomatic C code Comparison: extracted C code let wmpn_cmp (x y: ptr uint64) (sz: int32): int32 = let i = ref sz in try while!i 1 do i :=!i - 1; let lx = x[!i] in let ly = y[!i] in if lx ly then if lx > ly then raise (Return32 1) else raise (Return32 (-1)) done; 0 with Return32 r r end int32_t wmpn_cmp ( uint64_t * x, uint64_t * y, int32_t sz) { int32_t i, o; uint64_t lx, ly; i = (sz ); while (i >= 1) { o = (i - 1); i = o; lx = (*( x+(i ))); ly = (*( y+(i ))); if (lx!= ly) { if ( lx > ly) return (1); else return ( -(1)); } } return (0); } March 13, / 36

15 An example: schoolbook multiplication An example: schoolbook multiplication March 13, / 36

16 An example: schoolbook multiplication Schoolbook multiplication simple algorithm, optimal for smaller sizes GMP switches to divide-and-conquer algorithms at 20 words mp_limb_t mpn_mul ( mp_ptr rp, mp_srcptr up, mp_size_t un, mp_srcptr vp, mp_size_t vn) { /* We first multiply by the low order limb. This result can be stored, not added, to rp. We also avoid a loop for zeroing this way. */ rp[ un] = mpn_mul_1 ( rp, up, un, vp [0]); /* Now accumulate the product of up [] and the next higher limb from vp []. */ } while (--vn >= 1) { rp += 1, vp += 1; rp[ un] = mpn_addmul_1 ( rp, up, un, vp [0]); } return rp[ un ]; March 13, / 36

17 An example: schoolbook multiplication Why3 implementation while!i < sy do invariant { value r (!i + sx) = value x sx * value y!i } ly := get_ofs y!i; let c = addmul_limb!rp x!ly sx in set_ofs!rp sx c; i :=!i + 1;!rp := C.incr!rp 1; done;... March 13, / 36

18 An example: schoolbook multiplication Why3 implementation while!i < sy do invariant { 0!i sy } invariant { value r (!i + sx) = value x sx * value y!i } invariant { (!rp).offset = r.offset +!i } invariant { plength!rp = plength r } invariant { pelts!rp = pelts r } variant { sy -!i } ly := get_ofs y!i; let c = addmul_limb!rp x!ly sx in value_sub_update_no_change (pelts r) ((!rp).offset + sx) r.offset (r.offset +!i) c; set_ofs!rp sx c; i :=!i + 1; value_sub_tail (pelts r) r.offset (r.offset + sx + k); value_sub_tail (pelts y) y.offset (y.offset + k); value_sub_concat (pelts r) r.offset (r.offset + k) (r.offset + k + sx); assert { value r (!i + sx) = value x sx * value y!i by... so... so... (* 20+ subgoals *) };!rp := C.incr!rp 1; done;... March 13, / 36

19 An example: schoolbook multiplication Building block: addmul_limb (** [addmul_limb r x y sz] multiplies [(x, sz)] by [y], adds the [sz] least significant limbs to [(r, sz)] and writes the result in [(r,sz)]. Returns the most significant limb of the product plus the carry of the addition. Corresponds to [mpn_addmul_1].*) let addmul_limb (r x: ptr uint64) (y: uint64) (sz: int32): uint64 requires { valid x sz } requires { valid r sz } ensures { value r sz + (power radix sz) * result = value (old r) sz + value x sz * y } writes { r.data.elts } ensures { forall j. j < r.offset r.offset + sz j r[j] = (old r)[j] } adds y x to r does not change the contents of r outside the first sz cells called on r + i, x and y i for 0 i sy March 13, / 36

20 An example: schoolbook multiplication Extracted code void mul ( uint64_t * r12, uint64_t * x15, uint64_t * y13, int32_t sx4, int32_t sy4 ) { uint64_t ly9, c8, res16 ; uint64_t * rp3 ; int32_t i16, o28 ; uint64_t * o29 ; ly9 = (*( y13 )); c8 = ( mul_limb (r12, x15, ly9, sx4 )); *( r12 +( sx4 )) = c8; rp3 = ( r12 +(1)); i16 = (1); while ( i16 < sy4 ) { ly9 = *( y13 +( i16 )); res16 = ( addmul_limb ( rp3, x15, ly9, sx4 )); *( rp3 +( sx4 )) = res16 ; o28 = ( i16 + 1); i16 = o28 ; o29 = ( rp3 +(1)); ( rp3 ) = o29 ; } return (*( rp3 +( sx4-1))); } not as concise as GMP, but close enough to be optimized by the compiler March 13, / 36

21 Computational reflection in Why3 Computational reflection in Why3 March 13, / 36

22 Computational reflection in Why3 Motivation proof effort: 6000 lines of Why3 code 1350 of programs 4650 of specifications and (mostly) assertions 4200 subgoals, around two thirds are for division large proof contexts, nonlinear arithmetic many long assertions are needed even for some easy goals March 13, / 36

23 Computational reflection in Why3 Toy example: Strassen s algorithm we need to prove equalities such as M 1,1 = M 1,1 with M 1,1 = A 1,1 B 1,1 + A 1,2 B 2,1 M 1,1 = (A 1,1 + A 2,2 ) (B 1,1 + B 2,2 ) + A 2,2 (B 2,1 B 1,1 ) (A 1,1 + A 1,2 ) B 2,2 + (A 1,2 A 2,2 ) (B 2,1 + B 2,2 ) SMT solvers time out in practice idea: embed terms into the logical language of Why3 type t = Var int Add t t Mul t t Sub t t let rec function interp (x: t) (y: int a) : a = match x with Var n y n Add x1 x2 aplus (interp x1 y) (interp x2 y) Mul x1 x2 atimes (interp x1 y) (interp x2 y) Sub x1 x2 asub (interp x1 y) (interp x2 y) end March 13, / 36

24 Computational reflection in Why3 Normalizing terms define functions over t, compute results with Why3 rewriting engine let rec function norm (x:t) : t ensures { forall y. interp result y = interp x y } = match x with... lemma norm_eq: forall x1 x2 y. norm (Sub x1 x2) = Nil interp x1 y = interp x2 y no need to prove that norm computes a normal form very easy proof problem: how to guess x1, x2, y such that interp x1 y = M 1,1 interp x2 y = M 1,1 March 13, / 36

25 Computational reflection in Why3 Reification heuristic approach: invert norm_eq and the body of interp let rec function interp (x: t) (y: int a) : a = match x with Var n y n Add x1 x2 (interp x1 y) + (interp x2 y) Mul x1 x2 (interp x1 y) * (interp x2 y) Sub x1 x2 (interp x1 y) - (interp x2 y) end lemma norm_eq: forall x1 x2 y. norm (Sub x1 x2) = Nil interp x1 y = interp x2 y goal g: foo a + b = c * b [foo a + b = c * b] [foo a + b] = [c * b] Add [foo a] [b] = [c * b] Add (Var 0) (Var 1) = [c * b] Add (Var 0) (Var 1) = Mul [c] [b] Add (Var 0) (Var 1) = Mul (Var 2) (Var 1) x1 = Add (Var 0) (Var 1) x2 = Mul (Var 2) (Var 1) y 0 = foo a y 1 = b y 2 = c interp x1 y = interp x2 y? March 13, / 36

26 Computational reflection in Why3 Extension: reifying the proof context function interp_eq (g:equality) (y:vars) (z:c.cvars) : bool = match g with (g1, g2) interp g1 y z = interp g2 y z end function interp_ctx (l:list equality) (g:equality) (y:vars) (z:c.cvars) : bool = match l with Nil interp_eq g y z (* goal *) Cons h t (interp_eq h y z) (interp_ctx t g y z) end recognize implication and recursive call in the Cons branch heuristic: match all possible hypotheses in the proof context against the left-hand side, build longest possible list in this case, all equalities with the right type March 13, / 36

27 Computational reflection in Why3 Reflection as a Why3 transformation lemma norm_eq: forall x1 x2 y. norm (Sub x1 x2) = Nil interp x1 y = interp x2 y synopsis: take a lemma as parameter, e.g. norm_eq guess appropriate values for parameters using the reification procedure require to prove the premises add the instantiated conclusion, e.g. interp x1 y = interp x2 y to the proof context if we guess wrong, proof probably fails, but no soundness issue no need to trust the reification procedure March 13, / 36

28 Impure programs as decision procedures Impure programs as decision procedures March 13, / 36

29 Impure programs as decision procedures From logic to programs important limitation of logic-based approach: expressiveness no side effects allowed must prove termination with structurally decreasing argument consequence: decision procedures are hard to implement and inefficient idea: write decision procedures as regular, proved Why3 programs use instantiated postcondition as cut indication March 13, / 36

30 Impure programs as decision procedures Interpreter additional step of the reflection transformation: compute the results new interpreter for WhyML programs uses the extraction intermediate language simple, but part of the trusted computing base built-in implementation for arithmetic, arrays... additional debugging built-in: printf val printf (x: a) : unit March 13, / 36

31 Impure programs as decision procedures Example: systems of linear equalities type expr = Term coeff int Add expr expr Cst coeff type equality = (expr, expr) let linear_decision (l: list equality) (g: equality) : bool requires { valid_ctx l valid_eq g } ensures { forall y z. result = True interp_ctx l g y z } raises { Unknown true } = let m = Matrix.make match gauss_jordan m with Some r check_combination l g r None False end given a list l of valid equalities, is the equality g valid? check if g is a linear combination of l by Gaussian elimination if it s not, print a debugging hint proof by certificate: no need to prove Gaussian elimination generic: only requires coeff to provide partial field operations March 13, / 36

32 Impure programs as decision procedures Modularity: specializing the decision procedure to GMP axiom H: value r1 i + (power radix i) * c1 = value x i + value y i 1 axiom H1: res + radix * c = lx + ly + c1 power radix i axiom H2: value r i = value r1 i 1 axiom H3: value x (i+1) = value x i + (power radix i) * lx ( 1) axiom H4: value y (i+1) = value y i + (power radix i) * ly ( 1) axiom H5: value r (i+1) = value r i + (power radix i) * res 1 goal g: value r (i+1) + power radix (i+1) * c = value x (i+1) + value y (i+1) GMP-specific conversion layers, composed with generic procedure: more expressive inductive type for expressions GMP-specialized coefficient field let mp_decision (l: list equality ) (g: equality ) : bool requires { valid_ctx l valid_eq g } ensures { forall y z. result pos_ctx l z pos_eq g z interp_ctx l g y z } raises { Unknown true } = let sl, sg = simp_ctx (m_ctx l) (m_ctx g) in linear_decision sl sg March 13, / 36

33 Impure programs as decision procedures Specialized coefficients for GMP goals the (symbolic) powers of radix need to be part of the scalar coefficients type exp = Lit int Var int Plus exp exp Minus exp Sub exp exp type rat = (int, int) type t = (rat, exp) function qinterp (q:rat) : real = match q with (n,d) from_int n /. from_int d end function interp_exp (e:exp) (y:vars) : int = match e with Lit n n Var v y v Plus e1 e2 interp_exp e1 y + interp_exp e2 y... end function interp (t:t) (y:vars) : real = match t with (q,e) qinterp q *. pow radix (from_int (interp_exp e y)) end March 13, / 36

34 Impure programs as decision procedures Assessment user-supplied Why3 programs can be used as decision procedures no need to know the internal workings of Why3 compositionality: existing procedures can be adapted and reused minimal impact on the trusted computing base GMP proof: hundreds of lines of assertions can be deleted limitations: hard to debug when it doesn t work, though printf helps decision procedure performance reload times March 13, / 36

35 Benchmarks, conclusions Benchmarks, conclusions March 13, / 36

36 Benchmarks, conclusions Comparison with GMP we compare with GMP without assembly (option --disable-assembly) we want to evaluate the algorithms, not the compiler we only consider inputs of 20 words or less ( 1300 bits) above that, GMP uses different algorithms multiplication: less than 5% slower than GMP, satisfactory division: 10% slower than GMP except for very small inputs except for sx very close to sy GMP uses a different algorithm for sy > sx/2, to do performances are very dependent on the compiled code of the primitives ongoing: link to GMP to use the exact same primitives March 13, / 36

37 Benchmarks, conclusions Conclusions verified C library, bit-compatible with GMP GMP mpn functions implemented: add, sub, mul, div, shifts GMP implementation tricks preserved satisfactory performances in the handled cases new Why3 features: extraction and memory model for C alias of return value and parameter Why3 framework for proofs by reflection coming soon: divide-and-conquer algorithms for multiplication and division GMP mpz functions extract specifications as well? March 13, / 36

38 Arithmetic primitives: the uint64 type type uint64 val function to_int (n:uint64): int meta coercion function to_int let constant max = 0xffff_ffff_ffff_ffff predicate in_bounds (n:int) = 0 n max axiom to_int_in_bounds: forall n:uint64. in_bounds n val mul (x y:uint64): uint64 (* defensive, no overflow *) requires { in_bounds (x * y) } ensures { result = x * y } val mul_mod (x y:uint64): uint64 (* with overflow *) ensures { result = mod (x * y) (max+1) } val mul_double (x y:uint64): (uint64,uint64) returns { (l,h) l + (max+1) * h = x * y } (* returns two words*) March 13, / 2

39 A more complex algorithm: long division 1: function div_gen(q, a, d, m, n, inv) 2: x a m 1 3: i = m n 4: while i > 0 do 5: i i 1 6: if x = d n 1 and a n+i 1 = d n 2 then unlikely 7: ˆq β 1 8: submul_limb(a + i, d, n, ˆq) we know the result is d n 1 9: x a n+i 1 10: else 11: (ˆq, x, l) div_3by2(x, a n+i 1, a n+i 2, d n 1, d n 2, inv) 12: b submul_limb(a + i, d, n 2, ˆq) 13: b 1 (l < b) 14: a n+i 2 (l b mod β) 15: b 2 (x < b 1 ) 16: x (x b 1 mod β) 17: if b 2 0 then unlikely, and then b 2 = 1 18: ˆq ˆq 1 only one adjustment step 19: c add_in_place(a + i, d, n 1) 20: x x + d n 1 + c 21: q i ˆq 22: a n 1 x March 13, / 2

How to get an efficient yet verified arbitrary-precision integer library

How to get an efficient yet verified arbitrary-precision integer library How to get an efficient yet verified arbitrary-precision integer library Raphaël Rieu-Helft (joint work with Guillaume Melquiond and Claude Marché) TrustInSoft Inria May 28, 2018 1/31 Context, motivation,

More information

How to Get an Efficient yet Verified Arbitrary-Precision Integer Library

How to Get an Efficient yet Verified Arbitrary-Precision Integer Library How to Get an Efficient yet Verified Arbitrary-Precision Integer Library Raphaël Rieu-Helft, Claude Marché, Guillaume Melquiond To cite this version: Raphaël Rieu-Helft, Claude Marché, Guillaume Melquiond.

More information

Why3 A Multi-Prover Platform for Program Verification

Why3 A Multi-Prover Platform for Program Verification Why3 A Multi-Prover Platform for Program Verification Jean-Christophe Filliâtre CNRS joint work with Andrei Paskevich, Claude Marché, and François Bobot ProVal team, Orsay, France IFIP WG 1.9/2.14 Verified

More information

Why. an intermediate language for deductive program verification

Why. an intermediate language for deductive program verification Why an intermediate language for deductive program verification Jean-Christophe Filliâtre CNRS Orsay, France AFM workshop Grenoble, June 27, 2009 Jean-Christophe Filliâtre Why tutorial AFM 09 1 / 56 Motivations

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter

More information

GNATprove a Spark2014 verifying compiler Florian Schanda, Altran UK

GNATprove a Spark2014 verifying compiler Florian Schanda, Altran UK 1 GNATprove a Spark2014 verifying compiler Florian Schanda, Altran UK Tool architecture User view Source gnatprove Verdict 2 Tool architecture More detailed view... Source Encoding CVC4 gnat2why gnatwhy3

More information

Modules and Representation Invariants

Modules and Representation Invariants Modules and Representation Invariants COS 326 Andrew W. Appel Princeton University slides copyright 2013-2015 David Walker and Andrew W. Appel In previous classes: Reasoning about individual OCaml expressions.

More information

Lecture 15 CIS 341: COMPILERS

Lecture 15 CIS 341: COMPILERS Lecture 15 CIS 341: COMPILERS Announcements HW4: OAT v. 1.0 Parsing & basic code generation Due: March 28 th No lecture on Thursday, March 22 Dr. Z will be away Zdancewic CIS 341: Compilers 2 Adding Integers

More information

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University

G Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

CS153: Compilers Lecture 14: Type Checking

CS153: Compilers Lecture 14: Type Checking CS153: Compilers Lecture 14: Type Checking Stephen Chong https://www.seas.harvard.edu/courses/cs153 Announcements Project 4 out Due Thursday Oct 25 (7 days) Project 5 out Due Tuesday Nov 13 (26 days) Project

More information

Deductive Program Verification with Why3

Deductive Program Verification with Why3 Deductive Program Verification with Why3 Jean-Christophe Filliâtre CNRS Mathematical Structures of Computation Formal Proof, Symbolic Computation and Computer Arithmetic Lyon, February 2014 definition

More information

Formally Certified Satisfiability Solving

Formally Certified Satisfiability Solving SAT/SMT Proof Checking Verifying SAT Solver Code Future Work Computer Science, The University of Iowa, USA April 23, 2012 Seoul National University SAT/SMT Proof Checking Verifying SAT Solver Code Future

More information

Why3 where programs meet provers

Why3 where programs meet provers Why3 where programs meet provers Jean-Christophe Filliâtre CNRS KeY Symposium 2017 Rastatt, Germany October 5, 2017 history started in 2001, as an intermediate language in the process of verifying C and

More information

Pierce Ch. 3, 8, 11, 15. Type Systems

Pierce Ch. 3, 8, 11, 15. Type Systems Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using

More information

Lectures 20, 21: Axiomatic Semantics

Lectures 20, 21: Axiomatic Semantics Lectures 20, 21: Axiomatic Semantics Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Based on slides by George Necula Pratikakis (CSD) Axiomatic Semantics

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory

More information

Recap: Functions as first-class values

Recap: Functions as first-class values Recap: Functions as first-class values Arguments, return values, bindings What are the benefits? Parameterized, similar functions (e.g. Testers) Creating, (Returning) Functions Iterator, Accumul, Reuse

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

A concrete memory model for CompCert

A concrete memory model for CompCert A concrete memory model for CompCert Frédéric Besson Sandrine Blazy Pierre Wilke Rennes, France P. Wilke A concrete memory model for CompCert 1 / 28 CompCert real-world C to ASM compiler used in industry

More information

Work-in-progress: "Verifying" the Glasgow Haskell Compiler Core language

Work-in-progress: Verifying the Glasgow Haskell Compiler Core language Work-in-progress: "Verifying" the Glasgow Haskell Compiler Core language Stephanie Weirich Joachim Breitner, Antal Spector-Zabusky, Yao Li, Christine Rizkallah, John Wiegley June 2018 Let's prove GHC correct

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes Chapter 13: Reference Why reference Typing Evaluation Store Typings Safety Notes References Computational Effects Also known as side effects. A function or expression is said to have a side effect if,

More information

Numerical Computations and Formal Methods

Numerical Computations and Formal Methods Program verification Formal arithmetic Decision procedures Proval, Laboratoire de Recherche en Informatique INRIA Saclay IdF, Université Paris Sud, CNRS October 28, 2009 Program verification Formal arithmetic

More information

Functions & First Class Function Values

Functions & First Class Function Values Functions & First Class Function Values PLAI 1st ed Chapter 4, PLAI 2ed Chapter 5 The concept of a function is itself very close to substitution, and to our with form. Consider the following morph 1 {

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language

More information

Pointers. Chapter 8. Decision Procedures. An Algorithmic Point of View. Revision 1.0

Pointers. Chapter 8. Decision Procedures. An Algorithmic Point of View. Revision 1.0 Pointers Chapter 8 Decision Procedures An Algorithmic Point of View D.Kroening O.Strichman Revision 1.0 Outline 1 Introduction Pointers and Their Applications Dynamic Memory Allocation Analysis of Programs

More information

Fixed-Point Math and Other Optimizations

Fixed-Point Math and Other Optimizations Fixed-Point Math and Other Optimizations Embedded Systems 8-1 Fixed Point Math Why and How Floating point is too slow and integers truncate the data Floating point subroutines: slower than native, overhead

More information

Induction and Semantics in Dafny

Induction and Semantics in Dafny 15-414 Lecture 11 1 Instructor: Matt Fredrikson Induction and Semantics in Dafny TA: Ryan Wagner Encoding the syntax of Imp Recall the abstract syntax of Imp: a AExp ::= n Z x Var a 1 + a 2 b BExp ::=

More information

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen

Formal semantics of loosely typed languages. Joep Verkoelen Vincent Driessen Formal semantics of loosely typed languages Joep Verkoelen Vincent Driessen June, 2004 ii Contents 1 Introduction 3 2 Syntax 5 2.1 Formalities.............................. 5 2.2 Example language LooselyWhile.................

More information

Formal Semantics of Programming Languages

Formal Semantics of Programming Languages Formal Semantics of Programming Languages Mooly Sagiv Reference: Semantics with Applications Chapter 2 H. Nielson and F. Nielson http://www.daimi.au.dk/~bra8130/wiley_book/wiley.html Benefits of formal

More information

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming

CMSC 330: Organization of Programming Languages. OCaml Imperative Programming CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All

More information

Formal Verification of a Floating-Point Elementary Function

Formal Verification of a Floating-Point Elementary Function Introduction Coq & Flocq Coq.Interval Gappa Conclusion Formal Verification of a Floating-Point Elementary Function Inria Saclay Île-de-France & LRI, Université Paris Sud, CNRS 2015-06-25 Introduction Coq

More information

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium

Ornaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium Ornaments in ML Thomas Williams, Didier Rémy Inria - Gallium April 18, 2017 1 Motivation Two very similar functions let rec add m n = match m with Z n S m S (add m n) let rec append ml nl = match ml with

More information

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Outline. What is semantics? Denotational semantics. Semantics of naming. What is semantics? 2 / 21

Outline. What is semantics? Denotational semantics. Semantics of naming. What is semantics? 2 / 21 Semantics 1 / 21 Outline What is semantics? Denotational semantics Semantics of naming What is semantics? 2 / 21 What is the meaning of a program? Recall: aspects of a language syntax: the structure of

More information

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II)

Processadors de Llenguatge II. Functional Paradigm. Pratt A.7 Robert Harper s SML tutorial (Sec II) Processadors de Llenguatge II Functional Paradigm Pratt A.7 Robert Harper s SML tutorial (Sec II) Rafael Ramirez Dep Tecnologia Universitat Pompeu Fabra Paradigm Shift Imperative Paradigm State Machine

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

Multi-Precision Arithmetic for Cryptography in C++

Multi-Precision Arithmetic for Cryptography in C++ Multi-Precision Arithmetic for Cryptography in C++ at Run-Time and at Compile-Time Niek J. Bouman, PhD niekbouman@gmail.com 1 Secure Multiparty Computation (MPC) in Gartner s Hype Cycle (2017) 2 Secure

More information

CMSC 330: Organization of Programming Languages. Rust Basics

CMSC 330: Organization of Programming Languages. Rust Basics CMSC 330: Organization of Programming Languages Rust Basics CMSC330 Spring 2018 1 Organization It turns out that a lot of Rust has direct analogues in OCaml So we will introduce its elements with comparisons

More information

Andrew Reynolds Liana Hadarean

Andrew Reynolds Liana Hadarean 425,7 3!7441$ 89028147 30,7 #0, 7 9 209.&8 3 $ Andrew Reynolds Liana Hadarean July 15, 2010 1 . 34 0/ 020398 University of Iowa Andrew Reynolds, Cesare Tinelli, Aaron Stump Liana Hadarean, Yeting Ge, Clark

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

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.

More information

Exercise 1 ( = 22 points)

Exercise 1 ( = 22 points) 1 Exercise 1 (4 + 3 + 4 + 5 + 6 = 22 points) The following data structure represents polymorphic lists that can contain values of two types in arbitrary order: data DuoList a b = C a (DuoList a b) D b

More information

A Simple Supercompiler Formally Verified in Coq

A Simple Supercompiler Formally Verified in Coq A Simple Supercompiler Formally Verified in Coq IGE+XAO Balkan 4 July 2010 / META 2010 Outline 1 Introduction 2 3 Test Generation, Extensional Equivalence More Realistic Language Use Information Propagation

More information

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures

CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures CSE413: Programming Languages and Implementation Racket structs Implementing languages with interpreters Implementing closures Dan Grossman Fall 2014 Hi! I m not Hal J I love this stuff and have taught

More information

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39

Type checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39 Type checking Jianguo Lu November 27, 2014 slides adapted from Sean Treichler and Alex Aiken s Jianguo Lu November 27, 2014 1 / 39 Outline 1 Language translation 2 Type checking 3 optimization Jianguo

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

Abstract Interpretation

Abstract Interpretation Abstract Interpretation Ranjit Jhala, UC San Diego April 22, 2013 Fundamental Challenge of Program Analysis How to infer (loop) invariants? Fundamental Challenge of Program Analysis Key issue for any analysis

More information

The design of a programming language for provably correct programs: success and failure

The design of a programming language for provably correct programs: success and failure The design of a programming language for provably correct programs: success and failure Don Sannella Laboratory for Foundations of Computer Science School of Informatics, University of Edinburgh http://homepages.inf.ed.ac.uk/dts

More information

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type

More information

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE Type Systems Pierce Ch. 3, 8, 11, 15 CSE 6341 1 A Simple Language ::= true false if then else 0 succ pred iszero Simple untyped expressions Natural numbers encoded as succ succ

More information

Fundamentals of Software Engineering

Fundamentals of Software Engineering Fundamentals of Software Engineering Reasoning about Programs - Selected Features Ina Schaefer Institute for Software Systems Engineering TU Braunschweig, Germany Slides by Wolfgang Ahrendt, Richard Bubel,

More information

Static Program Analysis Part 1 the TIP language

Static Program Analysis Part 1 the TIP language Static Program Analysis Part 1 the TIP language http://cs.au.dk/~amoeller/spa/ Anders Møller & Michael I. Schwartzbach Computer Science, Aarhus University Questions about programs Does the program terminate

More information

Programming Languages

Programming Languages CSE 130 : Winter 2013 Programming Languages Lecture 3: Crash Course, Datatypes Ranjit Jhala UC San Diego 1 Story So Far... Simple Expressions Branches Let-Bindings... Today: Finish Crash Course Datatypes

More information

UNIT 3 OPERATORS. [Marks- 12]

UNIT 3 OPERATORS. [Marks- 12] 1 UNIT 3 OPERATORS [Marks- 12] SYLLABUS 2 INTRODUCTION C supports a rich set of operators such as +, -, *,,

More information

Programming Languages and Compilers (CS 421)

Programming Languages and Compilers (CS 421) Programming Languages and Compilers (CS 421) Elsa L Gunter 2112 SC, UIUC http://courses.engr.illinois.edu/cs421 Based in part on slides by Mattox Beckman, as updated by Vikram Adve and Gul Agha 10/3/17

More information

Integration of SMT Solvers with ITPs There and Back Again

Integration of SMT Solvers with ITPs There and Back Again Integration of SMT Solvers with ITPs There and Back Again Sascha Böhme and University of Sheffield 7 May 2010 1 2 Features: SMT-LIB vs. Yices Translation Techniques Caveats 3 4 Motivation Motivation System

More information

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning

Lecture 1 Contracts. 1 A Mysterious Program : Principles of Imperative Computation (Spring 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Spring 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning

Lecture 1 Contracts : Principles of Imperative Computation (Fall 2018) Frank Pfenning Lecture 1 Contracts 15-122: Principles of Imperative Computation (Fall 2018) Frank Pfenning In these notes we review contracts, which we use to collectively denote function contracts, loop invariants,

More information

FLINT 1.0: Fast Library for Number Theory

FLINT 1.0: Fast Library for Number Theory FLINT 1.0: Fast Library for Number Theory William B. Hart and David Harvey December 2, 2007 1 Introduction FLINT is a C library of functions for doing number theory. It is highly optimised and can be compiled

More information

Intermediate Code Generation

Intermediate Code Generation Intermediate Code Generation In the analysis-synthesis model of a compiler, the front end analyzes a source program and creates an intermediate representation, from which the back end generates target

More information

Representation Independence, Confinement and Access Control

Representation Independence, Confinement and Access Control Representation Independence, Confinement and Access Control Anindya Banerjee and David Naumann ab@cis.ksu.edu and naumann@cs.stevens-tech.edu Kansas State University and Stevens Institute of Technology

More information

CSE351 Winter 2016, Final Examination March 16, 2016

CSE351 Winter 2016, Final Examination March 16, 2016 CSE351 Winter 2016, Final Examination March 16, 2016 Please do not turn the page until 2:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 4:20. There are 125 (not 100) points,

More information

Formal Systems II: Applications

Formal Systems II: Applications Formal Systems II: Applications Functional Verification of Java Programs: Java Dynamic Logic Bernhard Beckert Mattias Ulbrich SS 2017 KIT INSTITUT FÜR THEORETISCHE INFORMATIK KIT University of the State

More information

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml

COSE212: Programming Languages. Lecture 3 Functional Programming in OCaml COSE212: Programming Languages Lecture 3 Functional Programming in OCaml Hakjoo Oh 2017 Fall Hakjoo Oh COSE212 2017 Fall, Lecture 3 September 18, 2017 1 / 44 Why learn ML? Learning ML is a good way of

More information

Semantic Analysis. Lecture 9. February 7, 2018

Semantic Analysis. Lecture 9. February 7, 2018 Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And

More information

Representation Independence, Confinement and Access Control

Representation Independence, Confinement and Access Control Representation Independence, Confinement and Access Control Anindya Banerjee and David Naumann ab@cis.ksu.edu and naumann@cs.stevens-tech.edu Kansas State University and Stevens Institute of Technology,

More information

Axiomatic Rules. Lecture 18: Axiomatic Semantics & Type Safety. Correctness using Axioms & Rules. Axiomatic Rules. Steps in Proof

Axiomatic Rules. Lecture 18: Axiomatic Semantics & Type Safety. Correctness using Axioms & Rules. Axiomatic Rules. Steps in Proof Lecture 18: Axiomatic Semantics & Type Safety CSCI 131 Fall, 2011 Kim Bruce Axiomatic Rules Assignment axiom: - {P [expression / id]} id := expression {P} - Ex: {a+47 > 0} x := a+47 {x > 0} - {x > 1} x

More information

Hardware versus software

Hardware versus software Logic 1 Hardware versus software 2 In hardware such as chip design or architecture, designs are usually proven to be correct using proof tools In software, a program is very rarely proved correct Why?

More information

Lecture 2: SML Basics

Lecture 2: SML Basics 15-150 Lecture 2: SML Basics Lecture by Dan Licata January 19, 2012 I d like to start off by talking about someone named Alfred North Whitehead. With someone named Bertrand Russell, Whitehead wrote Principia

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and

More information

Programming with C Library Functions Safely

Programming with C Library Functions Safely Programming with C Library Functions Safely p.1/39 Programming with C Library Functions Safely Hongwei Xi Boston University Work partly funded by NSF grant CCR-0229480 Programming with C Library Functions

More information

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)

CIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions) By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable

More information

Combining Coq and Gappa for Certifying FP Programs

Combining Coq and Gappa for Certifying FP Programs Introduction Example Gappa Tactic Conclusion Combining Coq and Gappa for Certifying Floating-Point Programs Sylvie Boldo Jean-Christophe Filliâtre Guillaume Melquiond Proval, Laboratoire de Recherche en

More information

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review

More information

CMSC 330: Organization of Programming Languages. Functional Programming with Lists

CMSC 330: Organization of Programming Languages. Functional Programming with Lists CMSC 330: Organization of Programming Languages Functional Programming with Lists 1 Lists in OCaml The basic data structure in OCaml Lists can be of arbitrary length Implemented as a linked data structure

More information

Programming Languages: Application and Interpretation

Programming Languages: Application and Interpretation Programming Languages: Application and Interpretation Version 6.7 October 26, 2016 This is the documentation for the software accompanying the textbook Programming Languages: Application and Interpretation

More information

Combining Programming with Theorem Proving

Combining Programming with Theorem Proving Combining Programming with Theorem Proving Chiyan Chen and Hongwei Xi Boston University Programming with Theorem Proving p.1/27 Motivation for the Research To support advanced type systems for practical

More information

Deductive Program Verification with Why3, Past and Future

Deductive Program Verification with Why3, Past and Future Deductive Program Verification with Why3, Past and Future Claude Marché ProofInUse Kick-Off Day February 2nd, 2015 A bit of history 1999: Jean-Christophe Filliâtre s PhD Thesis Proof of imperative programs,

More information

A heuristic method for formally verifying real inequalities

A heuristic method for formally verifying real inequalities A heuristic method for formally verifying real inequalities Robert Y. Lewis Vrije Universiteit Amsterdam June 22, 2018 Motivation Specific topic for today: verifying systems of nonlinear inequalities over

More information

Example: Adding 1000 integers on Cortex-M4F. Lower bound: 2n + 1 cycles for n LDR + n ADD. Imagine not knowing this : : :

Example: Adding 1000 integers on Cortex-M4F. Lower bound: 2n + 1 cycles for n LDR + n ADD. Imagine not knowing this : : : Cryptographic software engineering, part 2 1 Daniel J. Bernstein Last time: General software engineering. Using const-time instructions. Comparing time to lower bound. Example: Adding 1000 integers on

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

Hoare logic. A proof system for separation logic. Introduction. Separation logic

Hoare logic. A proof system for separation logic. Introduction. Separation logic Introduction Hoare logic Lecture 6: Examples in separation logic In the previous lecture, we saw how reasoning about pointers in Hoare logic was problematic, which motivated introducing separation logic.

More information

18. Inheritance and Polymorphism

18. Inheritance and Polymorphism (Expression) Trees -(3-(4-5))*(3+4*5)/6 18. Inheritance and Polymorphism fork fork / root 6 Expression Trees, Inheritance, Code-Reuse, Virtual Functions, Polymorphism, Concepts of Object Oriented Programming

More information

Lectures 5-6: Introduction to C

Lectures 5-6: Introduction to C Lectures 5-6: Introduction to C Motivation: C is both a high and a low-level language Very useful for systems programming Faster than Java This intro assumes knowledge of Java Focus is on differences Most

More information

Motivation was to facilitate development of systems software, especially OS development.

Motivation was to facilitate development of systems software, especially OS development. A History Lesson C Basics 1 Development of language by Dennis Ritchie at Bell Labs culminated in the C language in 1972. Motivation was to facilitate development of systems software, especially OS development.

More information

VS 3 : SMT Solvers for Program Verification

VS 3 : SMT Solvers for Program Verification VS 3 : SMT Solvers for Program Verification Saurabh Srivastava 1,, Sumit Gulwani 2, and Jeffrey S. Foster 1 1 University of Maryland, College Park, {saurabhs,jfoster}@cs.umd.edu 2 Microsoft Research, Redmond,

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

Introduction to Axiomatic Semantics

Introduction to Axiomatic Semantics Introduction to Axiomatic Semantics Meeting 10, CSCI 5535, Spring 2009 Announcements Homework 3 due tonight Homework 2 is graded 13 (mean), 14 (median), out of 21 total, but Graduate class: final project

More information

LECTURE 16. Functional Programming

LECTURE 16. Functional Programming LECTURE 16 Functional Programming WHAT IS FUNCTIONAL PROGRAMMING? Functional programming defines the outputs of a program as a mathematical function of the inputs. Functional programming is a declarative

More information

ATS: a language to make typeful programming real and fun

ATS: a language to make typeful programming real and fun ATS: a language to make typeful programming real and fun p.1/32 ATS: a language to make typeful programming real and fun Hongwei Xi Boston University Work partly funded by NSF grant CCR-0229480 ATS: a

More information

FLINT : Fast Library for Number Theory

FLINT : Fast Library for Number Theory FLINT 1.0.12: Fast Library for Number Theory William B. Hart and David Harvey July 11, 2008 Contents 1 Introduction 1 2 Building and using FLINT 1 3 Test code 2 4 Reporting bugs 2 5 Example programs 2

More information

Hoare Logic and Model Checking

Hoare Logic and Model Checking Hoare Logic and Model Checking Kasper Svendsen University of Cambridge CST Part II 2016/17 Acknowledgement: slides heavily based on previous versions by Mike Gordon and Alan Mycroft Introduction In the

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

More information

Recap: ML s Holy Trinity

Recap: ML s Holy Trinity Recap: ML s Holy Trinity Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set

More information

CMSC 330: Organization of Programming Languages. Functional Programming with Lists

CMSC 330: Organization of Programming Languages. Functional Programming with Lists CMSC 330: Organization of Programming Languages Functional Programming with Lists CMSC330 Spring 2018 1 Lists in OCaml The basic data structure in OCaml Lists can be of arbitrary length Implemented as

More information

Improving Coq Propositional Reasoning Using a Lazy CNF Conversion

Improving Coq Propositional Reasoning Using a Lazy CNF Conversion Using a Lazy CNF Conversion Stéphane Lescuyer Sylvain Conchon Université Paris-Sud / CNRS / INRIA Saclay Île-de-France FroCoS 09 Trento 18/09/2009 Outline 1 Motivation and background Verifying an SMT solver

More information