-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formula.v
74 lines (65 loc) · 2.14 KB
/
Formula.v
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
Require Import Lang.
Require Import Finset.
Fixpoint weight (p : prop) : nat :=
match p with
| p1 ∧ p2 => S ((weight p1) + (weight p2))
| p1 ∨ p2 => S ((weight p1) + (weight p2))
| p1 ⊃ p2 => S ((weight p1) + (weight p2))
| p1 ⊂ p2 => S ((weight p1) + (weight p2))
| p1 ⊗ p2 => S ((weight p1) + (weight p2))
| _ => S O
end.
Fixpoint atoms_of (p : prop) : finset :=
match p with
| ^x_a => {{a}}
| p1 ∧ p2 => (atoms_of p1) ∪ (atoms_of p2)
| p1 ∨ p2 => (atoms_of p1) ∪ (atoms_of p2)
| p1 ⊃ p2 => (atoms_of p1) ∪ (atoms_of p2)
| p1 ⊂ p2 => (atoms_of p1) ∪ (atoms_of p2)
| p1 ⊗ p2 => (atoms_of p1) ∪ (atoms_of p2)
| _ => ∅
end.
Notation "^V" := atoms_of.
Fixpoint atoms_num (p : prop) : nat :=
match p with
| ^x__ => 1
| p1 ∧ p2 => (atoms_num p1) + (atoms_num p2)
| p1 ∨ p2 => (atoms_num p1) + (atoms_num p2)
| p1 ⊃ p2 => (atoms_num p1) + (atoms_num p2)
| p1 ⊂ p2 => (atoms_num p1) + (atoms_num p2)
| p1 ⊗ p2 => (atoms_num p1) + (atoms_num p2)
| _ => 0
end.
(*
Require Import BinNat BinNatDef BinPos BinPosDef.
Fixpoint partition {T : Type} (l : list T) (mask : N) : list T :=
match (l, mask) with
| (_, 0%N) => []
| ([], _) => []
| (h :: t, pos p) => match p with
| xH => [h]
| xO p => partition t p
| xI p => h :: (partition t p)
end
end.
Fixpoint partition_list {T : Type} (l : list T) (mask : N) : list (list T) :=
match (l, mask) with
([], _) => [[]]
(_, 0%N) => [[]]
(h :: t, pos p) => match p with
| xH => [[h]]
| xO p =>
end.
Compute (partition_list [2;3;4;5]).
Fixpoint E0 (a : atom) (G : list prop) (mask : nat) : prop :=
match G with
| [] => 1
| [^x_b] => if PeanoNat.Nat.eqb a b then ⊤ else ^x_b
| (p ∧ q) :: G => (E0 a (p :: G) mask) ∧ (E0 a (p :: G) mask)
| (p ∨ q) :: G => (E0 a (p :: G) mask) ∨ (E0 a (p :: G) mask)
| (p ⊗ q) :: G => E0 a (p :: q :: G) mask
| _ => 0
end.
Fixpoint E1 (a : atom) (G : list prop) (mask : nat) : prop :=
match (BinNatDef.of_nat mask) with
| 0%N => *)