Skip to content
This repository was archived by the owner on Mar 29, 2019. It is now read-only.

Commit ca23ede

Browse files
author
Johannes Kanig
committed
fixpoints
a bugfix a test an example (list/map.who)
1 parent 5cb4e60 commit ca23ede

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

list/map.who

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
logic List.length ['a] : 'a list -> int
1+
fixpoint List.length ['a] (l : 'a list) : int =
2+
match l with
3+
| Nil -> 0
4+
| Cons (x,xs) -> 1 + List.length xs
5+
end
26

37
let rec List.map ['a 'b||'e]
48
(ia : <'e> -> 'a list -> prop) (ib : <'e> -> <'e> -> 'b list -> prop)
@@ -35,4 +39,4 @@ let test2 (l : int list) =
3539
let f ( _ : int) =
3640
{} r := !r + 1; !r { res : res = !!r /\ !!r = !!r@old + 1 } in
3741
List.map [{t}] ia ib f l
38-
{ res: l_incr res 1 (List.length res) }
42+
{ res: l_incr res 1 (List.length l) }

src/parser/recon.ml

+2-1
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,13 @@ let rec recon_decl x =
172172
let f =
173173
let v = mk_var_with_scheme false fix n (g,t) in
174174
var v (Ty.Generalize.to_inst g) l in
175+
let e = subst n (fun _ -> f) e in
175176
let fapp = List.fold_left (fun acc t -> app acc t l) f tl in
176177
let def = eq fapp e l in
177178
List.fold_left (fun acc (x,t) -> sforall x t acc l) def acc in
178179
[
179180
Logic (n,(g,t));
180-
Formula (Name.append n "def", form, `Assumed)
181+
Formula (Name.append n "def", gen g form l, `Assumed)
181182
]
182183

183184
| I.Inductive (n,g,t,tel) ->

tests/good/parsing/fixpoint.expected

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
type list ['a||] = | Nil | Cons of a* list[a]
2+
logic + : int -> int -> int
3+
logic = ['a||] : a -> a -> prop
4+
logic List_length ['a||] : list[a] -> int
5+
axiom List_lengthdef:
6+
forall ['a||]. forall (l:list[a]).
7+
(List_length [a||] l) =
8+
(match l with Nil -> 0 | Cons(x,xs) ->
9+
1 + (List_length [a||] xs) end )

tests/good/parsing/fixpoint.who

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
type list['a] =
2+
| Nil
3+
| Cons of 'a * 'a list
4+
5+
logic + : int -> int -> int
6+
7+
logic = ['a] : 'a -> 'a -> prop
8+
9+
fixpoint List.length ['a] (l : 'a list) : int =
10+
match l with
11+
| Nil -> 0
12+
| Cons (x,xs) -> 1 + List.length xs
13+
end

0 commit comments

Comments
 (0)