Skip to content

Instantly share code, notes, and snippets.

@d4hines
Last active September 17, 2020 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d4hines/d9a0c674f324cab46d2cf0967bde1ac3 to your computer and use it in GitHub Desktop.
Save d4hines/d9a0c674f324cab46d2cf0967bde1ac3 to your computer and use it in GitHub Desktop.
First Order Fragment
Require Import Init.Nat Arith List FL.CpdtTactics.
Require Import Logic.Decidable.
Set Implicit Arguments.
Set Asymmetric Patterns.
Require Import ZArith.
Require Import Lia.
Open Scope Z_scope.
Inductive Term : Set :=
| NumTerm : nat -> Term
| Plus : Term -> Term -> Term
.
Fixpoint termDenote (t : Term) : nat :=
match t with
| NumTerm n => n
| Plus n n' => (termDenote n) + (termDenote n')
end.
Eval simpl in termDenote (Plus (Plus (NumTerm 0) (NumTerm 5)) (NumTerm 7)).
Inductive RelOp : Set :=
| Eq
| Lt
| Lte
.
Definition relOpDenote (r : RelOp) : nat -> nat -> Prop :=
match r with
| Eq => eq
| Lt => lt
| Lte => le
end.
Inductive Formula : Set :=
| And : Formula -> Formula -> Formula
| Or : Formula -> Formula -> Formula
| Not : Formula -> Formula
| ForAll : (nat -> Formula) -> Formula
| Exists : (nat -> Formula) -> Formula
| Rel : Term -> RelOp -> Term -> Formula
.
Fixpoint formDenote (f : Formula) : Prop :=
match f with
| And f1 f2 => (formDenote f1) /\ (formDenote f2)
| Or f1 f2 => (formDenote f1) \/ (formDenote f2)
| Not f1 => ~ (formDenote f1)
| Rel t1 rel t2 => (relOpDenote rel) (termDenote t1) (termDenote t2)
| ForAll f' => forall n : nat, formDenote (f' n)
| Exists f' => exists n : nat, formDenote(f' n)
end.
Theorem formulas_are_decidable : forall (f : Formula) (p : Prop),
formDenote f = p ->
decidable p.
Proof.
Admitted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment