-
Notifications
You must be signed in to change notification settings - Fork 3
/
proof_check.ml
96 lines (71 loc) · 1.98 KB
/
proof_check.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
(** val app : 'a1 list -> 'a1 list -> 'a1 list **)
let rec app l m =
match l with
| [] -> m
| a :: l1 -> a :: (app l1 m)
module Nat =
struct
end
(** val forallb : ('a1 -> bool) -> 'a1 list -> bool **)
let rec forallb f = function
| [] -> true
| a :: l0 -> (&&) (f a) (forallb f l0)
module Literal =
struct
type t =
| Pos of int
| Neg of int
(** val eqb : t -> t -> bool **)
let eqb l1 l2 =
match l1 with
| Pos u -> (match l2 with
| Pos v -> (=) u v
| Neg _ -> false)
| Neg u -> (match l2 with
| Pos _ -> false
| Neg v -> (=) u v)
end
module Clause =
struct
type t = Literal.t list
(** val mem : t -> Literal.t -> bool **)
let rec mem c l =
match c with
| [] -> false
| l' :: ls -> if Literal.eqb l l' then true else mem ls l
(** val sub_clause : t -> t -> bool **)
let sub_clause c1 c2 =
forallb (mem c1) c2
(** val eqb : t -> t -> bool **)
let eqb c1 c2 =
(&&) (sub_clause c1 c2) (sub_clause c2 c1)
end
module ClauseSet =
struct
type t = Clause.t list
(** val mem : t -> Clause.t -> bool **)
let rec mem cs c =
match cs with
| [] -> false
| c' :: cs' -> if Clause.eqb c c' then true else mem cs' c
end
type proof_step =
| Proof_mem of Clause.t
| Proof_cut of int * Clause.t * Clause.t
(** val conclusion : proof_step -> Clause.t **)
let conclusion = function
| Proof_mem c -> c
| Proof_cut (_, c1, c2) -> app c1 c2
(** val is_proof_step : ClauseSet.t -> proof_step -> bool **)
let is_proof_step context = function
| Proof_mem c -> ClauseSet.mem context c
| Proof_cut (l, c1, c2) ->
(&&) (ClauseSet.mem context ((Literal.Neg l) :: c1))
(ClauseSet.mem context ((Literal.Pos l) :: c2))
(** val is_proof : ClauseSet.t -> proof_step list -> Clause.t -> bool **)
let rec is_proof context uts c =
match uts with
| [] -> ClauseSet.mem context c
| ut :: uts0 ->
(&&) (is_proof_step context ut)
(is_proof ((conclusion ut) :: context) uts0 c)