playground/coq/binN-more.v

184 lines
1.6 KiB
Coq

(*
- N: https://coq.inria.fr/library/Coq.Numbers.BinNums.html
- Z: https://coq.inria.fr/library/Coq.Numbers.BinNums.html
- positive: https://coq.inria.fr/library/Coq.Numbers.BinNums.html
*)
Require Import ZArith.
Require Import QArith.
Require Import Reals.
Check INR.
(*
INR
: nat -> R
*)
Compute 12%R.
(*
= ((R1 + R1) * ((R1 + R1) * (R1 + (R1 + R1))))%R
: R
*)
Compute INR 5.
(*
= (R1 + R1 + R1 + R1 + R1)%R
: R
*)
Check Q.
Compute Qmake 2 3.
(*
= 2 # 3
: Q
*)
Definition a:Q := Qmake 10 5.
Definition b:Q := Qmake 5 10.
Compute a*b.
(*
= 50 # 50
: Q
*)
Search (Q -> _).
Compute Qred (50 # 25).
(*
= 2
: Q
*)
Compute Qopp (50 # 25).
Compute Qopp (-1 # 25).
Compute Qinv (-1 # 25).
Compute Qmult (20 # 1) (1 # 2).
Compute Qmult' (20 # 1) (1 # 2).
Compute Qminus (10 # 2) (6 # 3).
Compute Qminus' (10 # 2) (6 # 3).
Check Z.
Compute Z0.
(*
= 0%Z
: Z
*)
Compute Zpos 8%positive.
(*
= 8%Z
: Z
*)
Compute Zneg 53%positive.
(*
= (-53)%Z
: Z
*)
Check N.
Compute N0.
(*
= 0%N
: N
*)
Compute Npos 1%positive.
(*
= 1%N
: N
*)
Compute Npos 45%positive.
(*
= 45%N
: N
*)
Check positive.
Check N.
Check Z.
Compute xH.
(*
= 1%positive
: positive
*)
Compute xO xH.
(*
= 2%positive
: positive
*)
Compute xI xH.
(*
= 3%positive
: positive
*)
Compute xO (xI (xO xH)).
(*
The term "xO" has type "positive -> positive"
while it is expected to have type "positive".
*)
Compute xO (xI (xO xO)).
Unset Printing Notations.
Compute xI xH.
Set Printing Notations.
Compute xI xH.
Compute (Pos.to_nat 6%positive).
Search (positive -> nat).