This repository has been archived by the owner on Apr 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
dectypes.v
70 lines (59 loc) · 1.83 KB
/
dectypes.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Require Import HoTT FunextAxiom UnivalenceAxiom.
Require Export basics.
(*
Results about types where some relations (equality/order) are decidable
*)
Module DecOrder.
Export Relation_pr.
Section VarSec.
Context {T : Type}.
Variable L : FullRelation T.
Lemma leqdec_eqdec {Hpo : Poset (<=)} : Decidable (<=) -> DecidablePaths T.
Proof.
intros H x y.
destruct (H x y);[destruct (H y x);[left;apply antisymmetric;assumption|]|];
right;intros p;destruct p;apply n;apply @reflexivity;apply Hpo.
Defined.
Global Instance leqdec_ltdec {Htr : TrivialApart (#)} {Hpo : FullPoset L}
: Decidable (<=) -> Decidable (<).
Proof.
intros Hdec x y.
unfold rrel.
destruct (Hdec x y) as [H|H];unfold rrel in H.
destruct (leqdec_eqdec Hdec x y).
right;intro H'. apply lt_iff_le_apart in H'. destruct H' as [H' H1].
apply Htr in H1. apply H1. assumption.
left. apply lt_iff_le_apart. split. assumption. apply Htr;assumption.
right;intro H';apply lt_iff_le_apart in H';destruct H';auto.
Defined.
(* we use neq_apart more often but this justifies that neq is the only apartness on decidable sets *)
Global Instance apartdec_trivial {Hap : Apartness (#)} {Hdec : Decidable (#)}
: TrivialApart (#).
Proof.
red. intros. split.
intros H H'.
destruct H'.
eapply irrefl. apply H.
intros H. destruct (Hdec x y). assumption.
destruct H. apply Hap. assumption.
Defined.
Lemma linear_dec_trichotomic {Hdec : Decidable (<=)}
{Htr : TrivialApart (#)} {Hlin : ConstrLinear (<=)}
{Hfull : FullPoset L} : Trichotomic (<).
Proof.
intros x y.
destruct (Hdec y x).
right.
destruct (Hdec x y).
left. apply antisymmetric;assumption.
right. apply lt_iff_le_apart. split.
assumption.
apply Htr. intro H'. destruct H'. auto.
left.
apply lt_iff_le_apart. split.
destruct (Hlin x y). assumption.
apply Empty_rect;auto.
apply Htr. intros p;destruct p. apply n;apply Hfull.
Defined.
End VarSec.
End DecOrder.