[coq] ohe.v: add eqb
This commit is contained in:
parent
391e3de385
commit
08d553e847
36
coq/ohe.v
36
coq/ohe.v
|
@ -2,8 +2,15 @@
|
||||||
From mathcomp Require Import all_ssreflect.
|
From mathcomp Require Import all_ssreflect.
|
||||||
Set Bullet Behavior "Strict Subproofs".
|
Set Bullet Behavior "Strict Subproofs".
|
||||||
|
|
||||||
|
(* Set Implicit Arguments. *)
|
||||||
|
|
||||||
Require Import Bvector.
|
Require Import Bvector.
|
||||||
|
|
||||||
|
Search (Vector.t _ _ -> Vector.t _ _ -> bool).
|
||||||
|
Print BVeq.
|
||||||
|
Print Vector.eqb.
|
||||||
|
About Vector.eqb.
|
||||||
|
|
||||||
(* Parameters: size and a flag indicating whether the mark has been made *)
|
(* Parameters: size and a flag indicating whether the mark has been made *)
|
||||||
(* Valid values have flag set to true *)
|
(* Valid values have flag set to true *)
|
||||||
Inductive t: nat -> bool -> Type :=
|
Inductive t: nat -> bool -> Type :=
|
||||||
|
@ -13,6 +20,34 @@ Inductive t: nat -> bool -> Type :=
|
||||||
| Mark: forall {n: nat},
|
| Mark: forall {n: nat},
|
||||||
t n false -> t (S n) true.
|
t n false -> t (S n) true.
|
||||||
|
|
||||||
|
|
||||||
|
Fixpoint eqb {b1 b2: bool} {n1 n2: nat} (o1: t n1 b1) (o2: t n2 b2): bool.
|
||||||
|
case (Nat.eqb n1 n2) eqn:Hneq.
|
||||||
|
move/PeanoNat.Nat.eqb_spec: Hneq => Hneq.
|
||||||
|
refine (
|
||||||
|
match o1, o2 with
|
||||||
|
| Nil, Nil => true
|
||||||
|
| Pad n1' b1' o1', Pad n2' b2' o2' => _
|
||||||
|
| Mark n1' o1', Mark n2' o2' => _
|
||||||
|
| _, _ => false
|
||||||
|
end).
|
||||||
|
- move: n1' n2' o1' o2' => n1' n2'.
|
||||||
|
case (Nat.eqb n1' n2') eqn:Hneq'.
|
||||||
|
+ move/PeanoNat.Nat.eqb_spec: Hneq' => Hneq'.
|
||||||
|
rewrite -Hneq'.
|
||||||
|
move => o1' o2'.
|
||||||
|
exact: eqb _ _ _ _ o1' o2'.
|
||||||
|
+ exact: (fun _ _ => false).
|
||||||
|
- move: n1' n2' o1' o2' => n1' n2'.
|
||||||
|
case (Nat.eqb n1' n2') eqn:Hneq'.
|
||||||
|
+ move/PeanoNat.Nat.eqb_spec: Hneq' => Hneq'.
|
||||||
|
rewrite -Hneq'.
|
||||||
|
move => o1' o2'.
|
||||||
|
exact: eqb _ _ _ _ o1' o2'.
|
||||||
|
+ exact: (fun _ _ => false).
|
||||||
|
- exact: false.
|
||||||
|
Defined.
|
||||||
|
|
||||||
Fixpoint markCount_aux {n: nat} {b: bool} (a: t n b): nat :=
|
Fixpoint markCount_aux {n: nat} {b: bool} (a: t n b): nat :=
|
||||||
match a with
|
match a with
|
||||||
| Nil => 0
|
| Nil => 0
|
||||||
|
@ -74,6 +109,7 @@ Compute markCount eg4.
|
||||||
Compute markCount eg5.
|
Compute markCount eg5.
|
||||||
|
|
||||||
Compute to_bv eg5.
|
Compute to_bv eg5.
|
||||||
|
(* = [false; false; true; false] : Bvector 4 *)
|
||||||
|
|
||||||
Fixpoint genPad (z: nat): t z false :=
|
Fixpoint genPad (z: nat): t z false :=
|
||||||
match z with
|
match z with
|
||||||
|
|
Loading…
Reference in New Issue