From eef08bbd1c65a72013f312f2103f07d613343af7 Mon Sep 17 00:00:00 2001
From: Mackie Loeffel <mackie.loeffel@web.de>
Date: Wed, 25 Apr 2018 14:42:33 +0200
Subject: [PATCH] started gqm

---
 _CoqProject             |  4 +++-
 theories/Base.v         |  7 ++++++
 theories/GQM.v          | 53 ++++++++++++++++++++++++++++++++++++++---
 theories/GQMDeduction.v | 34 ++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 4 deletions(-)
 create mode 100644 theories/Base.v
 create mode 100644 theories/GQMDeduction.v

diff --git a/_CoqProject b/_CoqProject
index a4ba2f5..4aa82f1 100644
--- a/_CoqProject
+++ b/_CoqProject
@@ -1,3 +1,5 @@
 -Q theories GQM
 -arg -w -arg -notation-overridden
-theories/GQM.v
\ No newline at end of file
+theories/Base.v
+theories/GQM.v
+theories/GQMDeduction.v
\ No newline at end of file
diff --git a/theories/Base.v b/theories/Base.v
new file mode 100644
index 0000000..733e928
--- /dev/null
+++ b/theories/Base.v
@@ -0,0 +1,7 @@
+From Coq Require Export ssreflect ssrfun ssrbool.
+Require Export Coq.Lists.List.
+Export ListNotations.
+
+Set Implicit Arguments.
+Unset Strict Implicit.
+Unset Printing Implicit Defensive.
diff --git a/theories/GQM.v b/theories/GQM.v
index 67b2aec..d7e2479 100644
--- a/theories/GQM.v
+++ b/theories/GQM.v
@@ -1,11 +1,58 @@
 Require Import Autosubst.Autosubst.
 
+Require Import GQM.Base.
+
 Inductive form :=
 | Var (x : var)
-| App (s t : form)
-| Lam (s : {bind form}).
+| Neg (f : form)
+| And (f g : form)
+| Box (f : form)
+| SquareAll (f : {bind form}).
 
 Instance Ids_form : Ids form. derive. Defined.
 Instance Rename_form : Rename form. derive. Defined.
 Instance Subst_form : Subst form. derive. Defined.
-Instance SubstLemmas_form : SubstLemmas form. derive. Qed.
\ No newline at end of file
+Instance SubstLemmas_form : SubstLemmas form. derive. Qed.
+
+Infix "&" :=  And (at level 75, right associativity).
+Notation "'[A]' B"   := (SquareAll B) (at level 74, right associativity).
+Notation "|[]| A"   := (Box A) (at level 74, right associativity).
+Notation "'-!' A" := (Neg A) (at level 73, right associativity).
+Definition Or A B := (-! (-! A & -! B)).
+Notation "A '|||' B" := (Or A B) (at level 76, right associativity).
+Definition Imp A B := ((-! A) ||| B).
+Notation "A '->>' B" := (Imp A B) (at level 77, right associativity).
+Notation "A '<<->>' B" := ((A ->> B) & (B ->> A)) (at level 78).
+
+Notation context := (list form).
+
+(** ** Decidable Equality *)
+
+Lemma dceq_v : forall n n0,  {Var n = Var n0} + {Var n <> Var n0}.
+Proof.
+  elim.
+  - case; by [ left | right].
+  - move => n IH.
+    case; try by right.
+    move => n0.
+    case: (IH n0).
+    + case => ->.
+        by left.
+    + move => Hneq.
+      right.
+      move => [Heq].
+      apply: Hneq.
+      by rewrite Heq.
+Qed.
+
+Lemma dceq_f: forall (A B: form), {A = B} + {A <> B}.
+Proof.
+  elim; intros; case: B; try by [right];
+    try by [ move => f2; case: (X f2); try by [move => ->; left];
+    move => Hneq;
+    right;
+     move => [Heq]].
+  - apply: dceq_v.
+  - move => f2 g2.
+    case: (X f2);case: (X0 g2);move => H1 H2;subst; try by [left]; right; by move => [].
+Qed.
\ No newline at end of file
diff --git a/theories/GQMDeduction.v b/theories/GQMDeduction.v
new file mode 100644
index 0000000..5666625
--- /dev/null
+++ b/theories/GQMDeduction.v
@@ -0,0 +1,34 @@
+Require Import GQM.Base.
+Require Import GQM.GQM.
+
+Inductive GQMded: context -> form -> Prop :=
+| gqm_in G f: In f G -> GQMded G f
+| gqm_andE1 G f1 f2: GQMded G (f1 & f2) -> GQMded G f1
+| gqm_andE2 G f1 f2: GQMded G (f1 & f2) -> GQMded G f2
+| gqm_andI G f1 f2: GQMded G f1 -> GQMded G f2 -> GQMded G (f1 & f2)
+| gqm_negI G f g: GQMded G (f ->> g) -> GQMded G (f ->> -! g) -> GQMded G (-! f) (* TODO neg intro*)
+| gqm_negE G f: GQMded G (Neg (Neg f)) -> GQMded G f. (* TODO neg intro*)
+
+Hint Constructors GQMded : GQMDB.
+
+Lemma gqm_orE1 : forall G f1 f2, GQMded G f1 -> GQMded G (f1 ||| f2).
+Proof.
+  move => G f1 f2 Hf1.
+  unfold Or.
+  apply: (gqm_negI _ _ f1).
+  - unfold Imp.
+    unfold Or.
+
+
+Lemma gqm_impE : forall G f1 f2, GQMded G f1 -> GQMded G (f1 ->> f2) -> GQMded G f2.
+Proof.
+  move => G f1.
+  elim: f1 G.
+  - move => x G f2 Hvar Himp.
+    inversion Himp; subst.
+  elim: Himp.
+
+Lemma gqm_impI : forall G f1 f2, GQMded (f1 :: G) f2 -> GQMded G (f1 ->> f2).
+Proof.
+  move => G f1 f2.
+  elim.
\ No newline at end of file
-- 
GitLab