Skip to content

Instantly share code, notes, and snippets.

@jp-diegidio
Last active December 23, 2023 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jp-diegidio/37fef7673349cd4bad3b007b3368164c to your computer and use it in GitHub Desktop.
Save jp-diegidio/37fef7673349cd4bad3b007b3368164c to your computer and use it in GitHub Desktop.
Naive SAT solver in Coq
From Coq Require Import Bool.
Ltac solve_sat_naive :=
repeat multimatch goal with
| [|- exists _ : bool, _] => exists true
| [|- exists _ : bool, _] => exists false
end; reflexivity.
Example ex_01 : exists x y, x && negb y = true.
Proof. solve_sat_naive. Qed.
Example ex_02 : exists x y z, x && negb y || z = false.
Proof. solve_sat_naive. Qed.
Example ex_e1 : exists x, x && negb x = true.
Proof. Fail solve_sat_naive. Abort.
Print ex_01.
(*
ex_01 =
ex_intro (fun x => exists y, x && negb y = true) true
(ex_intro (fun y => true && negb y = true) false
eq_refl)
: exists x y, x && negb y = true
*)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment