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
122
Issues
122
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
3ef4b170
Commit
3ef4b170
authored
May 21, 2017
by
Guillaume Melquiond
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some Coq realizations.
parent
4f841f92
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
221 additions
and
175 deletions
+221
-175
lib/coq/int/Int.v
lib/coq/int/Int.v
+14
-14
lib/coq/list/List.v
lib/coq/list/List.v
+18
-0
lib/coq/map/Const.v
lib/coq/map/Const.v
+7
-6
lib/coq/map/Map.v
lib/coq/map/Map.v
+17
-29
lib/coq/number/Divisibility.v
lib/coq/number/Divisibility.v
+10
-1
lib/coq/number/Parity.v
lib/coq/number/Parity.v
+0
-3
lib/coq/option/Option.v
lib/coq/option/Option.v
+18
-0
lib/coq/real/Real.v
lib/coq/real/Real.v
+18
-14
lib/coq/real/RealInfix.v
lib/coq/real/RealInfix.v
+7
-0
lib/coq/set/Set.v
lib/coq/set/Set.v
+112
-108
No files found.
lib/coq/int/Int.v
View file @
3ef4b170
...
@@ -15,22 +15,27 @@ Require Import BuiltIn.
...
@@ -15,22 +15,27 @@ Require Import BuiltIn.
Require
BuiltIn
.
Require
BuiltIn
.
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
infix_ls
is
replaced
with
(
x
<
x1
)
%
Z
by
the
coq
driver
*
)
(
*
prefix_mn
is
replaced
with
(
-
x
)
%
Z
by
the
coq
driver
*
)
(
*
Why3
goal
*
)
Lemma
infix_lseq_def
:
forall
(
x
:
Z
)
(
y
:
Z
),
(
x
<=
y
)
%
Z
<->
((
x
<
y
)
%
Z
\
/
(
x
=
y
)).
exact
Zle_lt_or_eq_iff
.
Qed
.
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
infix_pl
is
replaced
with
(
x
+
x1
)
%
Z
by
the
coq
driver
*
)
(
*
infix_pl
is
replaced
with
(
x
+
x1
)
%
Z
by
the
coq
driver
*
)
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
prefix_mn
is
replaced
with
(
-
x
)
%
Z
by
the
coq
driver
*
)
(
*
infix_as
is
replaced
with
(
x
*
x1
)
%
Z
by
the
coq
driver
*
)
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
infix_as
is
replaced
with
(
x
*
x1
)
%
Z
by
the
coq
driver
*
)
(
*
infix_ls
is
replaced
with
(
x
<
x1
)
%
Z
by
the
coq
driver
*
)
(
*
Why3
goal
*
)
Lemma
infix_mn_def
:
forall
(
x
:
Z
)
(
y
:
Z
),
((
x
-
y
)
%
Z
=
(
x
+
(
-
y
)
%
Z
)
%
Z
).
reflexivity
.
Qed
.
(
*
Why3
goal
*
)
Lemma
infix_lseq_def
:
forall
(
x
:
Z
)
(
y
:
Z
),
(
x
<=
y
)
%
Z
<->
((
x
<
y
)
%
Z
\
/
(
x
=
y
)).
exact
Zle_lt_or_eq_iff
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Assoc
:
forall
(
x
:
Z
)
(
y
:
Z
)
(
z
:
Z
),
Lemma
Assoc
:
forall
(
x
:
Z
)
(
y
:
Z
)
(
z
:
Z
),
...
@@ -96,11 +101,6 @@ intros x y z.
...
@@ -96,11 +101,6 @@ intros x y z.
apply
Zmult_plus_distr_l
.
apply
Zmult_plus_distr_l
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
Lemma
infix_mn_def
:
forall
(
x
:
Z
)
(
y
:
Z
),
((
x
-
y
)
%
Z
=
(
x
+
(
-
y
)
%
Z
)
%
Z
).
reflexivity
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Comm1
:
forall
(
x
:
Z
)
(
y
:
Z
),
((
x
*
y
)
%
Z
=
(
y
*
x
)
%
Z
).
Lemma
Comm1
:
forall
(
x
:
Z
)
(
y
:
Z
),
((
x
*
y
)
%
Z
=
(
y
*
x
)
%
Z
).
Proof
.
Proof
.
...
...
lib/coq/list/List.v
View file @
3ef4b170
...
@@ -14,7 +14,25 @@
...
@@ -14,7 +14,25 @@
Require
Import
BuiltIn
.
Require
Import
BuiltIn
.
Require
BuiltIn
.
Require
BuiltIn
.
(
*
Why3
assumption
*
)
Definition
is_nil
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
l
:
(
list
a
))
:
Prop
:=
match
l
with
|
Init
.
Datatypes
.
nil
=>
True
|
(
Init
.
Datatypes
.
cons
_
_
)
=>
False
end
.
(
*
Why3
goal
*
)
Lemma
is_nil_spec
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
l
:
(
list
a
)),
(
is_nil
l
)
<->
(
l
=
Init
.
Datatypes
.
nil
).
Proof
.
intros
a
a_WT
l
.
split
.
now
destruct
l
.
now
intros
->
.
Qed
.
Global
Instance
list_WhyType
:
forall
T
{
T_WT
:
WhyType
T
}
,
WhyType
(
list
T
).
Global
Instance
list_WhyType
:
forall
T
{
T_WT
:
WhyType
T
}
,
WhyType
(
list
T
).
Proof
.
split
.
split
.
apply
nil
.
apply
nil
.
induction
x
as
[
|
xh
x
]
;
intros
[
|
yh
y
]
;
try
(
now
right
).
induction
x
as
[
|
xh
x
]
;
intros
[
|
yh
y
]
;
try
(
now
right
).
...
...
lib/coq/map/Const.v
View file @
3ef4b170
...
@@ -13,22 +13,23 @@
...
@@ -13,22 +13,23 @@
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
Require
Import
BuiltIn
.
Require
Import
BuiltIn
.
Require
BuiltIn
.
Require
BuiltIn
.
Require
HighOrd
.
Require
map
.
Map
.
Require
map
.
Map
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Definition
const
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
Definition
const
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
b
->
(
map
.
Map
.
map
a
b
).
b
->
(
a
->
b
).
Proof
.
intros
a
a_WT
b
b_WT
v
.
intros
a
a_WT
b
b_WT
v
.
intros
i
.
intros
i
.
exact
v
.
exact
v
.
Defined
.
Defined
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Const
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
Lemma
const_def
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
forall
(
b1
:
b
)
(
a1
:
a
),
((
map
.
Map
.
get
(
const
b1
:
(
map
.
Map
.
map
a
b
))
forall
(
v
:
b
),
forall
(
us
:
a
),
(((
const
v
:
(
a
->
b
))
us
)
=
v
).
a1
)
=
b1
)
.
Proof
.
intros
a
a_WT
b
b_WT
b1
a1
.
intros
a
a_WT
b
b_WT
b1
a1
.
unfold
const
.
reflexivity
.
auto
.
Qed
.
Qed
.
lib/coq/map/Map.v
View file @
3ef4b170
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
Require
Import
BuiltIn
.
Require
Import
BuiltIn
.
Require
BuiltIn
.
Require
BuiltIn
.
Require
HighOrd
.
(
*
This
file
is
generated
by
Why3
'
s
Coq
-
realize
driver
*
)
(
*
This
file
is
generated
by
Why3
'
s
Coq
-
realize
driver
*
)
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
...
@@ -21,11 +22,8 @@ Require BuiltIn.
...
@@ -21,11 +22,8 @@ Require BuiltIn.
Require
Import
ClassicalEpsilon
.
Require
Import
ClassicalEpsilon
.
(
*
Why3
goal
*
)
(
*
Why3
assumption
*
)
Definition
map
:
forall
(
a
:
Type
)
(
b
:
Type
),
Type
.
Definition
map
(
a
:
Type
)
(
b
:
Type
)
:=
(
a
->
b
).
intros
.
exact
(
a
->
b
).
Defined
.
Global
Instance
map_WhyType
:
forall
(
a
:
Type
)
{
a_WT
:
WhyType
a
}
(
b
:
Type
)
{
b_WT
:
WhyType
b
}
,
WhyType
(
map
a
b
).
Global
Instance
map_WhyType
:
forall
(
a
:
Type
)
{
a_WT
:
WhyType
a
}
(
b
:
Type
)
{
b_WT
:
WhyType
b
}
,
WhyType
(
map
a
b
).
Proof
.
Proof
.
...
@@ -36,16 +34,10 @@ intros x y.
...
@@ -36,16 +34,10 @@ intros x y.
apply
excluded_middle_informative
.
apply
excluded_middle_informative
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
Definition
get
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
(
map
a
b
)
->
a
->
b
.
intros
a
a_WT
b
b_WT
m
x
.
exact
(
m
x
).
Defined
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Definition
set
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
Definition
set
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
(
map
a
b
)
->
a
->
b
->
(
map
a
b
).
(
a
->
b
)
->
a
->
b
->
(
a
->
b
).
Proof
.
intros
a
a_WT
b
b_WT
m
x
y
.
intros
a
a_WT
b
b_WT
m
x
y
.
intros
x
'
.
intros
x
'
.
destruct
(
why_decidable_eq
x
x
'
)
as
[
H
|
H
].
destruct
(
why_decidable_eq
x
x
'
)
as
[
H
|
H
].
...
@@ -54,22 +46,18 @@ exact (m x').
...
@@ -54,22 +46,18 @@ exact (m x').
Defined
.
Defined
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Select_eq
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
Lemma
set_def
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
forall
(
m
:
(
map
a
b
)),
forall
(
a1
:
a
)
(
a2
:
a
),
forall
(
b1
:
b
),
(
a1
=
a2
)
->
forall
(
f
:
(
a
->
b
))
(
x
:
a
)
(
v
:
b
),
forall
(
y
:
a
),
((
y
=
x
)
->
(((
set
f
x
v
)
((
get
(
set
m
a1
b1
)
a2
)
=
b1
).
y
)
=
v
))
/
\
((
~
(
y
=
x
))
->
(((
set
f
x
v
)
y
)
=
(
f
y
))).
Proof
.
intros
a
a_WT
b
b_WT
m
a1
a2
b1
h1
.
unfold
get
,
set
.
now
case
why_decidable_eq
.
Qed
.
(
*
Why3
goal
*
)
Lemma
Select_neq
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
{
b
:
Type
}
{
b_WT
:
WhyType
b
}
,
forall
(
m
:
(
map
a
b
)),
forall
(
a1
:
a
)
(
a2
:
a
),
forall
(
b1
:
b
),
(
~
(
a1
=
a2
))
->
((
get
(
set
m
a1
b1
)
a2
)
=
(
get
m
a2
)).
Proof
.
Proof
.
intros
a
a_WT
b
b_WT
m
a1
a2
b1
h1
.
intros
a
a_WT
b
b_WT
f
x
v
y
.
unfold
get
,
set
.
unfold
set
.
now
case
why_decidable_eq
.
case
why_decidable_eq
.
intros
<-
.
easy
.
intros
H
.
split
;
intros
H
'
.
now
elim
H
.
easy
.
Qed
.
Qed
.
lib/coq/number/Divisibility.v
View file @
3ef4b170
...
@@ -22,13 +22,22 @@ Require number.Parity.
...
@@ -22,13 +22,22 @@ Require number.Parity.
(
*
Hack
so
that
Why3
does
not
override
the
notation
below
.
(
*
Hack
so
that
Why3
does
not
override
the
notation
below
.
(
*
Why3
assumption
*
)
(
*
Why3
assumption
*
)
Definition
divides
(
d
:
Z
)
(
n
:
Z
)
:
Prop
:=
exists
q
:
Z
,
(
n
=
(
q
*
d
)
%
Z
).
Definition
divides
(
d
:
Z
)
(
n
:
Z
)
:
Prop
:=
((
d
=
0
%
Z
)
->
(
n
=
0
%
Z
))
/
\
((
~
(
d
=
0
%
Z
))
->
((
ZArith
.
BinInt
.
Z
.
rem
n
d
)
=
0
%
Z
)).
*
)
*
)
Require
Import
Znumtheory
.
Require
Import
Znumtheory
.
Notation
divides
:=
Zdivide
(
only
parsing
).
Notation
divides
:=
Zdivide
(
only
parsing
).
(
*
Why3
goal
*
)
Lemma
divides_spec
:
forall
(
d
:
Z
)
(
n
:
Z
),
(
divides
d
n
)
<->
exists
q
:
Z
,
(
n
=
(
q
*
d
)
%
Z
).
Proof
.
intros
d
n
.
easy
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
divides_refl
:
forall
(
n
:
Z
),
(
divides
n
n
).
Lemma
divides_refl
:
forall
(
n
:
Z
),
(
divides
n
n
).
Proof
.
Proof
.
...
...
lib/coq/number/Parity.v
View file @
3ef4b170
...
@@ -17,9 +17,6 @@ Require int.Int.
...
@@ -17,9 +17,6 @@ Require int.Int.
Require
int
.
Abs
.
Require
int
.
Abs
.
Require
int
.
ComputerDivision
.
Require
int
.
ComputerDivision
.
(
*
Why3
assumption
*
)
Definition
unit
:=
unit
.
(
*
Why3
assumption
*
)
(
*
Why3
assumption
*
)
Definition
even
(
n
:
Z
)
:
Prop
:=
exists
k
:
Z
,
(
n
=
(
2
%
Z
*
k
)
%
Z
).
Definition
even
(
n
:
Z
)
:
Prop
:=
exists
k
:
Z
,
(
n
=
(
2
%
Z
*
k
)
%
Z
).
...
...
lib/coq/option/Option.v
View file @
3ef4b170
...
@@ -14,7 +14,25 @@
...
@@ -14,7 +14,25 @@
Require
Import
BuiltIn
.
Require
Import
BuiltIn
.
Require
BuiltIn
.
Require
BuiltIn
.
(
*
Why3
assumption
*
)
Definition
is_none
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
o
:
(
option
a
))
:
Prop
:=
match
o
with
|
Init
.
Datatypes
.
None
=>
True
|
(
Init
.
Datatypes
.
Some
_
)
=>
False
end
.
(
*
Why3
goal
*
)
Lemma
is_none_spec
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
o
:
(
option
a
)),
(
is_none
o
)
<->
(
o
=
Init
.
Datatypes
.
None
).
Proof
.
intros
a
a_WT
o
.
split
.
now
destruct
o
.
now
intros
->
.
Qed
.
Global
Instance
option_WhyType
:
forall
T
{
T_WT
:
WhyType
T
}
,
WhyType
(
option
T
).
Global
Instance
option_WhyType
:
forall
T
{
T_WT
:
WhyType
T
}
,
WhyType
(
option
T
).
Proof
.
split
.
split
.
apply
@
None
.
apply
@
None
.
intros
[
x
|
]
[
y
|
]
;
try
(
now
right
)
;
try
(
now
left
).
intros
[
x
|
]
[
y
|
]
;
try
(
now
right
)
;
try
(
now
left
).
...
...
lib/coq/real/Real.v
View file @
3ef4b170
...
@@ -15,22 +15,23 @@ Require Import BuiltIn.
...
@@ -15,22 +15,23 @@ Require Import BuiltIn.
Require
BuiltIn
.
Require
BuiltIn
.
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
infix_ls
is
replaced
with
(
x
<
x1
)
%
R
by
the
coq
driver
*
)
(
*
prefix_mn
is
replaced
with
(
-
x
)
%
R
by
the
coq
driver
*
)
(
*
Why3
goal
*
)
Lemma
infix_lseq_def
:
forall
(
x
:
R
)
(
y
:
R
),
(
x
<=
y
)
%
R
<->
((
x
<
y
)
%
R
\
/
(
x
=
y
)).
reflexivity
.
Qed
.
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
infix_pl
is
replaced
with
(
x
+
x1
)
%
R
by
the
coq
driver
*
)
(
*
infix_pl
is
replaced
with
(
x
+
x1
)
%
R
by
the
coq
driver
*
)
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
prefix_mn
is
replaced
with
(
-
x
)
%
R
by
the
coq
driver
*
)
(
*
infix_as
is
replaced
with
(
x
*
x1
)
%
R
by
the
coq
driver
*
)
(
*
Why3
comment
*
)
(
*
Why3
comment
*
)
(
*
infix_as
is
replaced
with
(
x
*
x1
)
%
R
by
the
coq
driver
*
)
(
*
infix_ls
is
replaced
with
(
x
<
x1
)
%
R
by
the
coq
driver
*
)
(
*
Why3
goal
*
)
Lemma
infix_lseq_def
:
forall
(
x
:
R
)
(
y
:
R
),
(
x
<=
y
)
%
R
<->
((
x
<
y
)
%
R
\
/
(
x
=
y
)).
Proof
.
reflexivity
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Assoc
:
forall
(
x
:
R
)
(
y
:
R
)
(
z
:
R
),
Lemma
Assoc
:
forall
(
x
:
R
)
(
y
:
R
)
(
z
:
R
),
...
@@ -92,11 +93,6 @@ intros x y z.
...
@@ -92,11 +93,6 @@ intros x y z.
apply
Rmult_plus_distr_r
.
apply
Rmult_plus_distr_r
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
Lemma
infix_mn_def
:
forall
(
x
:
R
)
(
y
:
R
),
((
x
-
y
)
%
R
=
(
x
+
(
-
y
)
%
R
)
%
R
).
reflexivity
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Comm1
:
forall
(
x
:
R
)
(
y
:
R
),
((
x
*
y
)
%
R
=
(
y
*
x
)
%
R
).
Lemma
Comm1
:
forall
(
x
:
R
)
(
y
:
R
),
((
x
*
y
)
%
R
=
(
y
*
x
)
%
R
).
Proof
.
Proof
.
...
@@ -122,12 +118,20 @@ Qed.
...
@@ -122,12 +118,20 @@ Qed.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
Inverse
:
forall
(
x
:
R
),
(
~
(
x
=
0
%
R
))
->
Lemma
Inverse
:
forall
(
x
:
R
),
(
~
(
x
=
0
%
R
))
->
((
x
*
(
Reals
.
Rdefinitions
.
Rinv
x
))
%
R
=
1
%
R
).
((
x
*
(
Reals
.
Rdefinitions
.
Rinv
x
))
%
R
=
1
%
R
).
Proof
.
exact
Rinv_r
.
exact
Rinv_r
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
Lemma
infix_mn_def
:
forall
(
x
:
R
)
(
y
:
R
),
((
x
-
y
)
%
R
=
(
x
+
(
-
y
)
%
R
)
%
R
).
Proof
.
reflexivity
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
infix_sl_def
:
forall
(
x
:
R
)
(
y
:
R
),
Lemma
infix_sl_def
:
forall
(
x
:
R
)
(
y
:
R
),
((
x
/
y
)
%
R
=
(
x
*
(
Reals
.
Rdefinitions
.
Rinv
y
))
%
R
).
((
x
/
y
)
%
R
=
(
x
*
(
Reals
.
Rdefinitions
.
Rinv
y
))
%
R
).
Proof
.
reflexivity
.
reflexivity
.
Qed
.
Qed
.
...
...
lib/coq/real/RealInfix.v
View file @
3ef4b170
...
@@ -15,3 +15,10 @@ Require Import BuiltIn.
...
@@ -15,3 +15,10 @@ Require Import BuiltIn.
Require
BuiltIn
.
Require
BuiltIn
.
Require
real
.
Real
.
Require
real
.
Real
.
(
*
Why3
goal
*
)
Lemma
infix_mndt_def
:
forall
(
x
:
R
)
(
y
:
R
),
((
x
-
y
)
%
R
=
(
x
+
(
-
y
)
%
R
)
%
R
).
Proof
.
intros
x
y
.
reflexivity
.
Qed
.
lib/coq/set/Set.v
View file @
3ef4b170
...
@@ -13,234 +13,238 @@
...
@@ -13,234 +13,238 @@
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
(
*
Beware
!
Only
edit
allowed
sections
below
*
)
Require
Import
BuiltIn
.
Require
Import
BuiltIn
.
Require
BuiltIn
.
Require
BuiltIn
.
Require
HighOrd
.
Require
map
.
Map
.
Require
map
.
Const
.
Require
Import
ClassicalEpsilon
.
Require
Import
ClassicalEpsilon
.
Lemma
predicate_extensionality
:
Lemma
predicate_extensionality
:
forall
A
(
P
Q
:
A
->
Prop
),
forall
A
(
P
Q
:
A
->
bool
),
(
forall
x
,
P
x
<->
Q
x
)
->
P
=
Q
.
(
forall
x
,
P
x
=
Q
x
)
->
P
=
Q
.
Admitted
.
Admitted
.
(
*
"it is folklore that the two together are consistent"
*
)
(
*
Why3
goal
*
)
(
*
Why3
assumption
*
)
Definition
set
:
forall
(
a
:
Type
),
Type
.
Definition
set
(
a
:
Type
)
:=
(
a
->
bool
).
intros
.
exact
(
a
->
Prop
).
Defined
.
Global
Instance
set_WhyType
:
forall
(
a
:
Type
)
{
a_WT
:
WhyType
a
}
,
WhyType
(
set
a
).
Global
Instance
set_WhyType
:
forall
(
a
:
Type
)
{
a_WT
:
WhyType
a
}
,
WhyType
(
set
a
).
Proof
.
Proof
.
intros
.
intros
.
split
.
split
.
exact
(
fun
_
=>
F
alse
).
exact
(
fun
_
=>
f
alse
).
intros
x
y
.
intros
x
y
.
apply
excluded_middle_informative
.
apply
excluded_middle_informative
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
assumption
*
)
Definition
mem
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
a
->
(
set
a
)
->
Prop
.
Definition
mem
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
x
:
a
)
(
s
:
(
a
->
bool
))
:
Prop
:=
((
s
intros
a
a_WT
x
s
.
x
)
=
true
).
exact
(
s
x
).
Defined
.
Hint
Unfold
mem
.
Hint
Unfold
mem
.
(
*
Why3
assumption
*
)
(
*
Why3
assumption
*
)
Definition
infix_eqeq
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
s1
:
(
set
a
))
(
s2
:
(
set
Definition
infix_eqeq
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
s1
:
(
a
->
bool
))
(
s2
:
(
a
->
a
))
:
Prop
:=
forall
(
x
:
a
),
(
mem
x
s1
)
<->
(
mem
x
s2
).
bool
))
:
Prop
:=
forall
(
x
:
a
),
(
mem
x
s1
)
<->
(
mem
x
s2
).
Notation
"x == y"
:=
(
infix_eqeq
x
y
)
(
at
level
70
,
no
associativity
).
Notation
"x == y"
:=
(
infix_eqeq
x
y
)
(
at
level
70
,
no
associativity
).
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
extensionality
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
s1
:
(
set
a
))
Lemma
extensionality
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
s1
:
(
a
->
(
s2
:
(
set
a
)),
(
infix_eqeq
s1
s2
)
->
(
s1
=
s2
).
bool
))
(
s2
:
(
a
->
bool
)),
(
infix_eqeq
s1
s2
)
->
(
s1
=
s2
).
Proof
.
Proof
.
intros
a
a_WT
s1
s2
h1
.
intros
a
a_WT
s1
s2
h1
.
now
apply
predicate_extensionality
.
apply
predicate_extensionality
.
intros
x
.
generalize
(
h1
x
).
unfold
mem
.
intros
[
h2
h3
].
destruct
(
s1
x
).
now
rewrite
h2
.
destruct
(
s2
x
).
now
apply
h3
.
easy
.
Qed
.
Qed
.
(
*
Why3
assumption
*
)
(
*
Why3
assumption
*
)
Definition
subset
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
s1
:
(
set
a
))
(
s2
:
(
set
Definition
subset
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
s1
:
(
a
->
bool
))
(
s2
:
(
a
->
a
))
:
Prop
:=
forall
(
x
:
a
),
(
mem
x
s1
)
->
(
mem
x
s2
).
bool
))
:
Prop
:=
forall
(
x
:
a
),
(
mem
x
s1
)
->
(
mem
x
s2
).
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
subset_refl
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
s
:
(
set
a
)),
Lemma
subset_refl
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
s
:
(
a
->
bool
)),
(
subset
s
s
).
(
subset
s
s
).
Proof
.
Proof
.
now
intros
a
a_WT
s
x
.
now
intros
a
a_WT
s
x
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
subset_trans
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
s1
:
(
set
a
))
Lemma
subset_trans
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
s1
:
(
a
->
(
s2
:
(
set
a
))
(
s3
:
(
set
a
)),
(
subset
s1
s2
)
->
((
subset
s2
s3
)
->
(
subset
s1
bool
))
(
s2
:
(
a
->
bool
))
(
s3
:
(
a
->
bool
)),
(
subset
s1
s2
)
->
((
subset
s2
s3
)).
s3
)
->
(
subset
s1
s3
)
).
Proof
.
Proof
.
intros
a
a_WT
s1
s2
s3
h1
h2
x
H
.
intros
a
a_WT
s1
s2
s3
h1
h2
x
H
.
now
apply
h2
,
h1
.
now
apply
h2
,
h1
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
Definition
empty
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
(
set
a
).
intros
.
exact
(
fun
_
=>
False
).
Defined
.
(
*
Why3
assumption
*
)
(
*
Why3
assumption
*
)
Definition
is_empty
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
s
:
(
set
a
))
:
Prop
:=
Definition
is_empty
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
(
s
:
(
a
->
bool
))
:
Prop
:=
forall
(
x
:
a
),
~
(
mem
x
s
).
forall
(
x
:
a
),
~
(
mem
x
s
).
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
empty_def1
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
(
is_empty
(
empty
:
(
set
Lemma
mem_empty
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
(
is_empty
a
))).
(
map
.
Const
.
const
false
:
(
a
->
bool
))).
Proof
.
Proof
.
now
intros
a
a_WT
x
.
now
intros
a
a_WT
x
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Lemma
mem_empty
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
x
:
a
),
~
(
mem
x
Lemma
add_spec
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
x
:
a
)
(
s
:
(
a
->
(
empty
:
(
set
a
))).
bool
)),
forall
(
y
:
a
),
(
mem
y
(
map
.
Map
.
set
s
x
true
))
<->
((
y
=
x
)
\
/
(
mem
y
Proof
.
s
)).
now
intros
a
a_WT
x
.
Qed
.
(
*
Why3
goal
*
)
Definition
add
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
a
->
(
set
a
)
->
(
set
a
).
intros
a
a_WT
x
s
.
exact
(
fun
y
=>
x
=
y
\
/
s
y
).
Defined
.
(
*
Why3
goal
*
)
Lemma
add_def1
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
forall
(
x
:
a
)
(
y
:
a
),
forall
(
s
:
(
set
a
)),
(
mem
x
(
add
y
s
))
<->
((
x
=
y
)
\
/
(
mem
x
s
)).
Proof
.
Proof
.
intros
a
a_WT
x
y
s
.
intros
a
a_WT
x
y
s
.
unfold
add
,
mem
;
intuition
.
unfold
Map
.
set
,
mem
.
destruct
why_decidable_eq
;
intuition
.
Qed
.
Qed
.
(
*
Why3
goal
*
)
(
*
Why3
goal
*
)
Definition
remove
:
forall
{
a
:
Type
}
{
a_WT
:
WhyType
a
}
,
a
->
(
set
a
)
->
(
set
a
).