-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheval.v
88 lines (63 loc) · 1.86 KB
/
eval.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
75
76
77
78
79
80
81
82
83
84
85
86
87
(** Proof Reflection in Coq ; eval.v ; 050128 ; Dimitri Hendriks; Coq 8.0pl1 *)
Require Export objects.
Set Implicit Arguments.
Section evaluation.
Variable A : Set.
Variable l1 l2 : list nat.
Let T := trm l1.
Let Ts := trms l1.
Let F := frm l1 l2.
Let P := prf l1 l2.
Definition fun_piT := forall i : index l1, listn A (select i) -> A.
Variable FUN : fun_piT.
Section term_evaluation.
Variable VAR : nat -> A.
Fixpoint eval_trm (t : T) : A :=
match t with
| var i => VAR i
| fun_ i l => FUN i (mapn eval_trm l)
end.
Definition eval_trms (z : nat) (l : Ts z) := mapn eval_trm l.
End term_evaluation.
Definition insertVAR_O (x : A) (V : nat -> A) (m : nat) :=
match m with
| O => x
| S m' => V m'
end.
Fixpoint insertVAR (x : A) (V : nat -> A) (n : nat) {struct n} :
nat -> A :=
match n with
| O => insertVAR_O x V
| S n' =>
fun m =>
match m with
| O => V 0
| S m' => insertVAR x (fun p => V (S p)) n' m'
end
end.
Section formula_evaluation.
Definition rel_piT :=
forall i : index l2, listn A (select i) -> Prop.
Variable REL : rel_piT.
Fixpoint eval_frm' (VAR : nat -> A) (p : F) {struct p} : Prop :=
match p with
| top => True
| bot => False
| rel i l => REL i (eval_trms VAR l)
| imp q r => eval_frm' VAR q -> eval_frm' VAR r
| cnj q r => eval_frm' VAR q /\ eval_frm' VAR r
| dsj q r => eval_frm' VAR q \/ eval_frm' VAR r
| uvq q => forall x : A, eval_frm' (insertVAR_O x VAR) q
| exq q => exists x : A, eval_frm' (insertVAR_O x VAR) q
end.
(* conjunction of evaluated list elements *)
Fixpoint eval_cxt' (VAR : nat -> A) (G : list F) {struct G} : Prop :=
match G with
| nil => True
| p :: g => eval_frm' VAR p /\ eval_cxt' VAR g
end.
Variable dflt : A.
Definition eval_frm := eval_frm' (fun _ => dflt).
Definition eval_cxt := eval_cxt' (fun _ => dflt).
End formula_evaluation.
End evaluation.