-
Notifications
You must be signed in to change notification settings - Fork 0
/
Formula.v
93 lines (73 loc) · 2.55 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(*common header begin*)
Require Import Utf8.
From Coq Require Import ssreflect ssrfun ssrbool.
Set Implicit Arguments.
Unset Strict Implicit.
Unset Printing Implicit Defensive.
Set Maximal Implicit Insertion.
Require Import List.
Import ListNotations.
(*common header end*)
Require Export Label.
Require Import UserTactics.
(*rewrite to_list l*)
Create HintDb list'.
(*non-empty list*)
Inductive list' (A : Type) : Type :=
| singleton : A -> list' A
| cons' : A -> list' A -> list' A.
Inductive formula : Set :=
| atom (a : label) : formula
| arr (phi : list' formula) (t : formula) : formula.
(*intersections are non-empty in the Coppo-Dezani type assingnment system*)
(*used to define rank, lists with at least two elements are assigned at least the value 1*)
Definition rank_formula_aux' (f : formula -> nat) : list' formula -> nat :=
fix maxby_rec' (l: list' formula) :=
match l with
| (singleton x) => f x
| (cons' x xs) => Nat.max (maxby_rec' xs) (Nat.max (f x) 1)
end.
Fixpoint rank_formula (t : formula) : nat :=
match t with
| (atom _) => 0
| (arr phi s) => Nat.max (1 + rank_formula_aux' rank_formula phi) (rank_formula s)
end.
Definition rank_formula' (phi : list' formula) := rank_formula_aux' rank_formula phi.
Fixpoint to_list (A : Type) (l : list' A) : list A :=
match l with
| (singleton a) => cons a nil
| (cons' a l) => cons a (to_list l)
end.
Fixpoint to_list' (A : Type) (a : A) (l : list A) : list' A :=
match l with
| nil => singleton a
| (cons b l) => cons' a (to_list' b l)
end.
Lemma to_list_inv : forall (A : Type) (a : A) (l : list A), to_list (to_list' a l) = a :: l.
Proof.
move => A a l.
elim : l a; cbn; auto.
intros; by f_equal.
Qed.
Coercion to_list : list' >-> list.
Lemma to_list_cons' : forall (T : Type) (a : T) (l : list' T),
to_list (cons' a l) = a :: to_list l.
Proof. intros; reflexivity. Qed.
(*Definition formula' : Set := list' formula.*)
Notation formula' := (list' formula).
Definition label_to_atom (a : label) : formula := atom a.
Definition formula_to_singleton (s : formula) : formula' := singleton s.
(*embedding formulae into singleton intersections*)
Coercion formula_to_singleton : formula >-> formula'.
Coercion label_to_atom : label >-> formula.
Lemma forall_exists_in_formula' : forall (P : formula -> Prop) (phi : formula'), Forall P phi -> exists (s : formula), In s phi /\ P s.
Proof.
move => P; case.
move => s; inversion.
exists s; split; auto.
by constructor.
move => s phi; inversion.
exists s; split; auto.
by constructor.
Qed.
Hint Rewrite @to_list_inv @to_list_cons' : list'.