Commit 1a2cd3fd authored by Ralf Jung's avatar Ralf Jung

make the discrete metric more general: for any setoid

parent c5fc5262
...@@ -402,3 +402,10 @@ Section OptDefs. ...@@ -402,3 +402,10 @@ Section OptDefs.
Qed. Qed.
End OptDefs. End OptDefs.
Section DiscreteType.
Context {T : Type}.
Program Instance discreteType : Setoid T := mkType (@eq T).
End DiscreteType.
...@@ -870,22 +870,26 @@ Qed. ...@@ -870,22 +870,26 @@ Qed.
(** Discrete spaces are proper metric spaces (discrete meaning that the distance (** Discrete spaces are proper metric spaces (discrete meaning that the distance
is 1 if elements are diffent and 0 for equal elements. Equality here is is 1 if elements are diffent and 0 for equal elements. Equality here is
propositional Coq equality. *) propositional Coq equality. *)
Section Discrete. Section DiscreteMetric.
Context {T : Type}. Context {T : Type} {T_type : Setoid T}.
Program Instance discreteType : Setoid T := mkType (@eq T).
Definition discreteDist n (x y : T) := Definition discreteDist n (x y : T) :=
match n with match n with
O => True O => True
| _ => x = y | _ => x == y
end. end.
Global Arguments discreteDist n x y / . Global Arguments discreteDist n x y / .
Program Instance discreteMetric : metric T := mkMetr discreteDist. Program Instance discreteMetric : metric T := mkMetr discreteDist.
Next Obligation. Next Obligation.
split; intros HEq; [specialize (HEq 1) | intros [ | n] ]; intros x y Heq x' y' Heq'. split; (destruct n as [|n]; [reflexivity|simpl]).
inversion HEq; subst; simpl; reflexivity. - intros Heqx. rewrite <-Heq, <-Heq'. assumption.
- intros Heqy. rewrite Heq, Heq'. assumption.
Qed.
Next Obligation.
split; intros Heq.
- now apply (Heq 1).
- intros [|n]; tauto.
Qed. Qed.
Next Obligation. Next Obligation.
destruct n as [| n]; intros x y HS; simpl in *; [| symmetry]; tauto. destruct n as [| n]; intros x y HS; simpl in *; [| symmetry]; tauto.
...@@ -903,11 +907,11 @@ Section Discrete. ...@@ -903,11 +907,11 @@ Section Discrete.
Next Obligation. Next Obligation.
intros n; exists 1; simpl; intros [| i] HLe; [inversion HLe |]. intros n; exists 1; simpl; intros [| i] HLe; [inversion HLe |].
destruct n as [| n]; [exact I |]. destruct n as [| n]; [exact I |].
assert (HT := chain_cauchy σ _ 1 (S i) 1); inversion HT. assert (HT := chain_cauchy σ _ 1 (S i) 1). rewrite HT.
rewrite H0; reflexivity. reflexivity.
Qed. Qed.
End Discrete. End DiscreteMetric.
Section Option. Section Option.
Context `{cT : cmetric T}. Context `{cT : cmetric T}.
......
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