File: P.v

package info (click to toggle)
coq-corn 8.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,216 kB
  • sloc: python: 112; haskell: 69; makefile: 39; sh: 4
file content (53 lines) | stat: -rw-r--r-- 1,211 bytes parent folder | download | duplicates (2)
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

Require Import Coq.Setoids.Setoid Coq.PArith.BinPos Coq.PArith.Pnat ZArith_base.


Section P_of_nat.

  Variables (n: nat) (E: n <> O).

  Lemma P_of_nat: positive.
   apply P_of_succ_nat.
   destruct n as [|p].
    exfalso. apply E. reflexivity.
   exact p.
  Defined.

  Lemma P_of_nat_correct: nat_of_P P_of_nat = n.
   unfold P_of_nat.
   destruct n. exfalso. intuition.
   apply nat_of_P_o_P_of_succ_nat_eq_succ.
  Qed.

End P_of_nat.

Lemma nat_of_P_inj_iff (p q : positive): nat_of_P p = nat_of_P q <-> p = q.
Proof with auto.
 split; intro. apply nat_of_P_inj... subst...
Qed.

Lemma nat_of_P_nonzero (p: positive): nat_of_P p <> 0.
Proof.
 intro H.
 apply Nat.lt_irrefl with 0.
 rewrite <- H at 2.
 apply lt_O_nat_of_P.
Qed.

#[global]
Hint Immediate nat_of_P_nonzero.

Lemma Plt_lt (p q: positive): Pos.lt p q <-> (nat_of_P p < nat_of_P q).
Proof.
 split. apply nat_of_P_lt_Lt_compare_morphism.
 apply nat_of_P_lt_Lt_compare_complement_morphism.
Qed.

Lemma Ple_le (p q: positive): Pos.le p q <-> le (nat_of_P p) (nat_of_P q).
Proof.
 rewrite Pos.le_lteq, Plt_lt, Nat.lt_eq_cases, nat_of_P_inj_iff.
 reflexivity.
Qed.

Lemma Ple_refl p: Pos.le p p.
Proof. intros. apply Pos.le_lteq. firstorder. Qed.