Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
why3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
121
Issues
121
List
Boards
Labels
Service Desk
Milestones
Merge Requests
15
Merge Requests
15
Operations
Operations
Incidents
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Why3
why3
Commits
a430350f
Commit
a430350f
authored
Mar 04, 2010
by
Jean-Christophe Filliâtre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linearite des patterns
parent
4b92124c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
12 deletions
+29
-12
bench/typing/bad/pat_linearity1.why
bench/typing/bad/pat_linearity1.why
+4
-0
bench/typing/bad/pat_linearity2.why
bench/typing/bad/pat_linearity2.why
+5
-0
src/parser/typing.ml
src/parser/typing.ml
+18
-4
src/test.why
src/test.why
+2
-8
No files found.
bench/typing/bad/pat_linearity1.why
0 → 100644
View file @
a430350f
theory A
type 'a list = Nil | Cons('a, 'a list)
axiom A : forall l:int list. match l with Cons(x,x) -> true | Nil -> false end
end
bench/typing/bad/pat_linearity2.why
0 → 100644
View file @
a430350f
theory A
type 'a list = Nil | Cons('a, 'a list)
axiom A : forall l:int list. (match l with Cons(x,x) -> 0 | Nil -> 1 end) = 2
end
src/parser/typing.ml
View file @
a430350f
...
...
@@ -402,6 +402,20 @@ let binop = function
|
PPimplies
->
Fimplies
|
PPiff
->
Fiff
let
check_pat_linearity
pat
=
let
s
=
ref
S
.
empty
in
let
add
id
=
if
S
.
mem
id
.
id
!
s
then
errorm
~
loc
:
id
.
id_loc
"duplicate variable %s"
id
.
id
;
s
:=
S
.
add
id
.
id
!
s
in
let
rec
check
p
=
match
p
.
pat_desc
with
|
PPpwild
->
()
|
PPpvar
id
->
add
id
|
PPpapp
(
_
,
pl
)
->
List
.
iter
check
pl
|
PPpas
(
p
,
id
)
->
check
p
;
add
id
in
check
pat
let
rec
dpat
env
pat
=
let
env
,
n
,
ty
=
dpat_node
pat
.
pat_loc
env
pat
.
pat_desc
in
env
,
{
dp_node
=
n
;
dp_ty
=
ty
}
...
...
@@ -412,7 +426,6 @@ and dpat_node loc env = function
let
ty
=
Tyvar
(
create_type_var
~
loc
~
user
:
false
tv
)
in
env
,
Pwild
,
ty
|
PPpvar
{
id
=
x
}
->
if
M
.
mem
x
env
.
dvars
then
assert
false
;
(* FIXME? *)
let
tv
=
create_tvsymbol
(
id_user
"a"
loc
)
in
let
ty
=
Tyvar
(
create_type_var
~
loc
~
user
:
false
tv
)
in
let
env
=
{
env
with
dvars
=
M
.
add
x
ty
env
.
dvars
}
in
...
...
@@ -424,7 +437,6 @@ and dpat_node loc env = function
env
,
Papp
(
s
,
pl
)
,
ty
|
PPpas
(
p
,
{
id
=
x
})
->
let
env
,
p
=
dpat
env
p
in
if
M
.
mem
x
env
.
dvars
then
assert
false
;
(* FIXME? *)
let
env
=
{
env
with
dvars
=
M
.
add
x
p
.
dp_ty
env
.
dvars
}
in
env
,
Pas
(
p
,
x
)
,
p
.
dp_ty
...
...
@@ -453,7 +465,7 @@ let rec trigger_not_a_term_exn = function
|
Loc
.
Located
(
_
,
exn
)
->
trigger_not_a_term_exn
exn
|
_
->
false
let
check_linearity
uqu
=
let
check_
quant_
linearity
uqu
=
let
s
=
ref
S
.
empty
in
let
check
id
=
if
S
.
mem
id
.
id
!
s
then
errorm
~
loc
:
id
.
id_loc
"duplicate variable %s"
id
.
id
;
...
...
@@ -496,6 +508,7 @@ and dterm_node loc env = function
(* TODO: unify e1.type with patterns *)
(* TODO: unify branch types with each other *)
let
branch
(
pat
,
e
)
=
check_pat_linearity
pat
;
let
env
,
pat
=
dpat
env
pat
in
pat
,
dterm
env
e
in
...
...
@@ -527,7 +540,7 @@ and dfmla env e = match e.pp_desc with
|
PPif
(
a
,
b
,
c
)
->
Fif
(
dfmla
env
a
,
dfmla
env
b
,
dfmla
env
c
)
|
PPquant
(
q
,
uqu
,
trl
,
a
)
->
check_linearity
uqu
;
check_
quant_
linearity
uqu
;
let
uquant
env
(
idl
,
ty
)
=
let
ty
=
dty
env
ty
in
let
env
,
idl
=
...
...
@@ -565,6 +578,7 @@ and dfmla env e = match e.pp_desc with
(* TODO: unify e1.type with patterns *)
(* TODO: unify branch types with each other *)
let
branch
(
pat
,
e
)
=
check_pat_linearity
pat
;
let
env
,
pat
=
dpat
env
pat
in
pat
,
dfmla
env
e
in
...
...
src/test.why
View file @
a430350f
...
...
@@ -2,15 +2,9 @@
(* test file *)
theory A
use import prelude.Int
logic p(int, int)
axiom A : forall x:int. x = x
end
theory TreeForest
type 'a list = Nil | Cons('a, 'a list)
type 'a tree = Leaf('a) | Node('a forest)
type 'a forest = 'a tree list
axiom A : forall l:int list. (match l with Cons(x,x) -> 0 | Nil -> 1 end) = 2
end
theory TestPrelude
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment