Commit 3ef4b170 authored by Guillaume Melquiond's avatar Guillaume Melquiond

Fix some Coq realizations.

parent 4f841f92
......@@ -15,22 +15,27 @@ Require Import BuiltIn.
Require BuiltIn.
(* Why3 comment *)
(* infix_ls is replaced with (x < x1)%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.
(* prefix_mn is replaced with (-x)%Z by the coq driver *)
(* Why3 comment *)
(* infix_pl is replaced with (x + x1)%Z by the coq driver *)
(* 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 *)
(* 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 *)
Lemma Assoc : forall (x:Z) (y:Z) (z:Z),
......@@ -96,11 +101,6 @@ intros x y z.
apply Zmult_plus_distr_l.
Qed.
(* Why3 goal *)
Lemma infix_mn_def : forall (x:Z) (y:Z), ((x - y)%Z = (x + (-y)%Z)%Z).
reflexivity.
Qed.
(* Why3 goal *)
Lemma Comm1 : forall (x:Z) (y:Z), ((x * y)%Z = (y * x)%Z).
Proof.
......
......@@ -14,7 +14,25 @@
Require Import 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).
Proof.
split.
apply nil.
induction x as [|xh x] ; intros [|yh y] ; try (now right).
......
......@@ -13,22 +13,23 @@
(* Beware! Only edit allowed sections below *)
Require Import BuiltIn.
Require BuiltIn.
Require HighOrd.
Require map.Map.
(* Why3 goal *)
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 i.
exact v.
Defined.
(* Why3 goal *)
Lemma Const : 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))
a1) = b1).
Lemma const_def : forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (v:b), forall (us:a), (((const v: (a -> b)) us) = v).
Proof.
intros a a_WT b b_WT b1 a1.
unfold const.
auto.
reflexivity.
Qed.
......@@ -13,6 +13,7 @@
(* Beware! Only edit allowed sections below *)
Require Import BuiltIn.
Require BuiltIn.
Require HighOrd.
(* This file is generated by Why3's Coq-realize driver *)
(* Beware! Only edit allowed sections below *)
......@@ -21,11 +22,8 @@ Require BuiltIn.
Require Import ClassicalEpsilon.
(* Why3 goal *)
Definition map : forall (a:Type) (b:Type), Type.
intros.
exact (a -> b).
Defined.
(* Why3 assumption *)
Definition map (a:Type) (b:Type) := (a -> b).
Global Instance map_WhyType : forall (a:Type) {a_WT:WhyType a} (b:Type) {b_WT:WhyType b}, WhyType (map a b).
Proof.
......@@ -36,16 +34,10 @@ intros x y.
apply excluded_middle_informative.
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 *)
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 x'.
destruct (why_decidable_eq x x') as [H|H].
......@@ -54,22 +46,18 @@ exact (m x').
Defined.
(* Why3 goal *)
Lemma Select_eq : 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) = b1).
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)).
Lemma set_def : forall {a:Type} {a_WT:WhyType a} {b:Type} {b_WT:WhyType b},
forall (f:(a -> b)) (x:a) (v:b), forall (y:a), ((y = x) -> (((set f x v)
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.
intros a a_WT b b_WT f x v y.
unfold set.
case why_decidable_eq.
intros <-.
easy.
intros H.
split ; intros H'.
now elim H.
easy.
Qed.
......@@ -22,13 +22,22 @@ Require number.Parity.
(* Hack so that Why3 does not override the notation below.
(* 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.
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 *)
Lemma divides_refl : forall (n:Z), (divides n n).
Proof.
......
......@@ -17,9 +17,6 @@ Require int.Int.
Require int.Abs.
Require int.ComputerDivision.
(* Why3 assumption *)
Definition unit := unit.
(* Why3 assumption *)
Definition even (n:Z): Prop := exists k:Z, (n = (2%Z * k)%Z).
......
......@@ -14,7 +14,25 @@
Require Import 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).
Proof.
split.
apply @None.
intros [x|] [y|] ; try (now right) ; try (now left).
......
......@@ -15,22 +15,23 @@ Require Import BuiltIn.
Require BuiltIn.
(* Why3 comment *)
(* 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)).
reflexivity.
Qed.
(* prefix_mn is replaced with (-x)%R by the coq driver *)
(* Why3 comment *)
(* infix_pl is replaced with (x + x1)%R by the coq driver *)
(* 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 *)
(* 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 *)
Lemma Assoc : forall (x:R) (y:R) (z:R),
......@@ -92,11 +93,6 @@ intros x y z.
apply Rmult_plus_distr_r.
Qed.
(* Why3 goal *)
Lemma infix_mn_def : forall (x:R) (y:R), ((x - y)%R = (x + (-y)%R)%R).
reflexivity.
Qed.
(* Why3 goal *)
Lemma Comm1 : forall (x:R) (y:R), ((x * y)%R = (y * x)%R).
Proof.
......@@ -122,12 +118,20 @@ Qed.
(* Why3 goal *)
Lemma Inverse : forall (x:R), (~ (x = 0%R)) ->
((x * (Reals.Rdefinitions.Rinv x))%R = 1%R).
Proof.
exact Rinv_r.
Qed.
(* Why3 goal *)
Lemma infix_mn_def : forall (x:R) (y:R), ((x - y)%R = (x + (-y)%R)%R).
Proof.
reflexivity.
Qed.
(* Why3 goal *)
Lemma infix_sl_def : forall (x:R) (y:R),
((x / y)%R = (x * (Reals.Rdefinitions.Rinv y))%R).
Proof.
reflexivity.
Qed.
......
......@@ -15,3 +15,10 @@ Require Import BuiltIn.
Require BuiltIn.
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.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment