[coq] ohe.v: add eqb

This commit is contained in:
Julin S 2024-03-06 10:41:06 +05:30
parent 391e3de385
commit 08d553e847
1 changed files with 36 additions and 0 deletions

View File

@ -2,8 +2,15 @@
From mathcomp Require Import all_ssreflect.
Set Bullet Behavior "Strict Subproofs".
(* Set Implicit Arguments. *)
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 *)
(* Valid values have flag set to true *)
Inductive t: nat -> bool -> Type :=
@ -13,6 +20,34 @@ Inductive t: nat -> bool -> Type :=
| Mark: forall {n: nat},
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 :=
match a with
| Nil => 0
@ -74,6 +109,7 @@ Compute markCount eg4.
Compute markCount eg5.
Compute to_bv eg5.
(* = [false; false; true; false] : Bvector 4 *)
Fixpoint genPad (z: nat): t z false :=
match z with