package hardcaml_verify

  1. Overview
  2. Docs
Hardcaml Verification Tools

Install

Dune Dependency

Authors

Maintainers

Sources

v0.17.0.tar.gz
sha256=a09a904776ad848f685afb4ebe85e0d449acb81f6f2425fccc52a3c5b76be629

doc/src/hardcaml_verify.kernel/tseitin.ml.html

Source file tseitin.ml

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
open Base

module type S = sig
  type t

  val ( ~: ) : t -> t
end

module Make (B : S) = struct
  open B

  let bfalse z = [ [ ~:z ] ]
  let btrue z = [ [ z ] ]
  let bnot z x = [ [ x; z ]; [ ~:x; ~:z ] ]
  let bwire z x = [ [ ~:z; x ]; [ z; ~:x ] ]

  let bnor z x =
    let sum = List.fold_right x ~init:[ z ] ~f:(fun x a -> x :: a) in
    List.fold_right x ~init:[ sum ] ~f:(fun x a -> [ ~:x; ~:z ] :: a)
  ;;

  let bor z x =
    let sum = List.fold_right x ~init:[ ~:z ] ~f:(fun x a -> x :: a) in
    List.fold_right x ~init:[ sum ] ~f:(fun x a -> [ ~:x; z ] :: a)
  ;;

  let bnand z x =
    let sum = List.fold_right x ~init:[ ~:z ] ~f:(fun x a -> ~:x :: a) in
    List.fold_right x ~init:[ sum ] ~f:(fun x a -> [ x; z ] :: a)
  ;;

  let band z x =
    let sum = List.fold_right x ~init:[ z ] ~f:(fun x a -> ~:x :: a) in
    List.fold_right x ~init:[ sum ] ~f:(fun x a -> [ x; ~:z ] :: a)
  ;;

  let bxor z a b = [ [ ~:z; ~:a; ~:b ]; [ ~:z; a; b ]; [ z; ~:a; b ]; [ z; a; ~:b ] ]
end
OCaml

Innovation. Community. Security.