2019-03-13 13:02:29 +01:00
|
|
|
open Sexplib.Std
|
2019-01-25 11:39:31 +01:00
|
|
|
|
|
|
|
(*
|
|
|
|
Type for bits
|
|
|
|
==============
|
|
|
|
|
|
|
|
Zero | One
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
|
|
|
type t =
|
|
|
|
| One
|
|
|
|
| Zero
|
|
|
|
[@@deriving sexp]
|
|
|
|
|
|
|
|
let to_string = function
|
|
|
|
| Zero -> "0"
|
|
|
|
| One -> "1"
|
2019-03-13 13:02:29 +01:00
|
|
|
|
2019-01-25 11:39:31 +01:00
|
|
|
|
|
|
|
let and_operator a b =
|
|
|
|
match a, b with
|
|
|
|
| Zero, _ -> Zero
|
|
|
|
| _, Zero -> Zero
|
|
|
|
| _, _ -> One
|
2019-03-13 13:02:29 +01:00
|
|
|
|
2019-01-25 11:39:31 +01:00
|
|
|
|
|
|
|
let or_operator a b =
|
|
|
|
match a, b with
|
|
|
|
| One, _ -> One
|
|
|
|
| _, One -> One
|
|
|
|
| _, _ -> Zero
|
2019-03-13 13:02:29 +01:00
|
|
|
|
2019-01-25 11:39:31 +01:00
|
|
|
|
|
|
|
let xor_operator a b =
|
|
|
|
match a, b with
|
|
|
|
| One, Zero -> One
|
|
|
|
| Zero, One -> One
|
|
|
|
| _, _ -> Zero
|
2019-03-13 13:02:29 +01:00
|
|
|
|
2019-01-25 11:39:31 +01:00
|
|
|
|
|
|
|
let not_operator = function
|
|
|
|
| One -> Zero
|
|
|
|
| Zero -> One
|
2019-03-13 13:02:29 +01:00
|
|
|
|
2019-01-25 11:39:31 +01:00
|
|
|
|