Guest User

coq prop formulas

a guest
Apr 29th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. (*Basé sur le travail de P. Dehornoy, DehornoyChap6.pdf*)
  2.  
  3. Require Import Arith.
  4. Require Import List.
  5.  
  6. (*Variables propositionnelles*)
  7.  
  8. (*Formules*)
  9. Inductive PFormule :=
  10. | FVar : nat -> PFormule
  11. | FNeg : PFormule -> PFormule
  12. | FAnd : PFormule -> PFormule -> PFormule
  13. | FOr : PFormule -> PFormule -> PFormule
  14. | FImply : PFormule -> PFormule -> PFormule.
  15.  
  16. Theorem PFormule_eq_dec : forall (p q : PFormule), {p=q}+{p<>q}.
  17. repeat (decide equality).
  18. Qed.
  19.  
  20. Delimit Scope PFormule_scope with prop.
  21. Bind Scope PFormule_scope with PFormule.
  22. Local Open Scope PFormule_scope.
  23.  
  24. Notation "'X' i" := (FVar i) (at level 5).
  25. Notation "~ F" := (FNeg F).
  26. Notation "F /\ G" := (FAnd F G).
  27. Notation "F \/ G" := (FOr F G).
  28. Notation "F -> G" := (FImply F G) : PFormule_scope.
  29. Notation "F <-> G" := (FAnd (FImply F G) (FImply G F)).
  30.  
  31.  
  32. Definition X1 := X 1.
  33. Definition X2 := X 2.
  34. Definition X3 := X 3.
  35.  
  36. (*Implication*)
  37. Definition A1:PFormule := X1 -> X2 -> X1.
  38. Definition A2:PFormule := (X1->(X2->X3))->((X1->X2)->(X1->X3)).
  39.  
  40. (*Négation*)
  41. Definition A3:PFormule := X1-> ~~X1.
  42. Definition A4:PFormule := ~~X1->X1.
  43. Definition A5:PFormule:= (X1->X2)->(~X2->~X1).
  44.  
  45. (*Conjonction*)
  46. Definition A6:PFormule := X1->(X2->(X1/\X2)).
  47. Definition A7:PFormule := (X1/\X2)->X1.
  48. Definition A8:PFormule := (X1/\X2)->X2.
  49.  
  50. (*Disjonction*)
  51. Definition A9:PFormule := X1->(X1\/X2).
  52. Definition A10:PFormule := X2->(X1\/X2).
  53. Definition A11:PFormule := ~X1->((X1\/X2)->X2).
  54.  
  55. Inductive AProp : PFormule -> Prop :=
  56. | a1: AProp A1
  57. | a2 : AProp A2
  58. | a3 : AProp A3
  59. | a4 : AProp A4
  60. | a5 : AProp A5
  61. | a6 : AProp A6
  62. | a7 : AProp A7
  63. | a8 : AProp A8
  64. | a9 : AProp A9
  65. | a10 : AProp A10
  66. | a11 : AProp A11.
  67.  
  68.  
  69. (*Variables libres et substitutions*)
  70. (*Basé sur le travail de Gyesik Lee "Proof Pearl : substitution revisited, again"*)
  71. Fixpoint FV (F : PFormule) : list nat :=
  72. match F with
  73. | FVar x => x :: nil
  74. | FNeg F => FV F
  75. | FAnd F G | FOr F G | FImply F G => (FV F) ++ (FV G)
  76. end.
  77.  
  78. Definition substitution := (nat -> PFormule)%type.
  79.  
  80. (** Mise à jour d'une fonction avec une nouvelle valeur*)
  81. Definition up (f : nat -> PFormule) (e : PFormule) (d : nat) : nat -> PFormule :=
  82. fun x => if eq_nat_dec x d then e else f x.
  83. Notation " f [[ e => d ]] " := (up f e d) (at level 70).
  84.  
  85. Fixpoint subst (F : PFormule) (rho : substitution) {struct F} : PFormule :=
  86. match F with
  87. | FVar n => rho n
  88. | FNeg F => FNeg (subst F rho)
  89. | FAnd F1 F2 => FAnd (subst F1 rho) (subst F2 rho)
  90. | FOr F1 F2 => FOr (subst F1 rho) (subst F2 rho)
  91. | FImply F1 F2 => FImply (subst F1 rho) (subst F2 rho)
  92. end.
  93.  
  94. Notation id := (fun (n : nat) => FVar n).
  95.  
  96. Notation " M {{ rho }} " := (subst M rho) (at level 55).
  97.  
  98. (*Demonstration*)
  99. Inductive Pdemonstration :=
  100. |PdemonstrationInst : forall F l, (exists A s, (AProp A /\ (subst A s) = F)%type)-> Pdemonstration F (F::l)
  101. |PdemonstrationCoupure : forall F G l, In F l -> In (F->G) l -> Pdemonstration G (G::l).
  102.  
  103.  
  104. Definition verification (l : list PFormule) (f : PFormule) : option {d:Pdemonstration | Pdemonstration f l}.
  105.  
  106. Local Close Scope PFormule_scope.
Advertisement
Add Comment
Please, Sign In to add comment