Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Notation for Hoare logic

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Notation for Hoare logic


Chronological Thread 
  • From: CJ Bell <siegebell AT gmail.com>
  • To: "Benjamin C. Pierce" <bcpierce AT cis.upenn.edu>
  • Cc: Coq Club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Notation for Hoare logic
  • Date: Fri, 8 Mar 2013 19:07:58 -0500

Here is an approach that works because it uses the existing notation
for " { } " and requires prefixing Hoare triples with "|-" (or some
other keyword). Hard to tell if it breaks something, though.


Inductive ht_pred : Set := ht_pred_: nat->ht_pred.
Inductive ht : ht_pred->nat->ht_pred->Prop := .

Delimit Scope htriple with htriple.
Delimit Scope htriple_pred with htriple_pred.
Arguments ht P%htriple_pred c%nat Q%htriple_pred.

Module Notations.
Notation " { P } " := (ht_pred_ P%nat) : htriple_pred.
Notation "|-" := ht (no associativity, at level 0) : htriple.
End Notations.

Module TestNotations.
Import Notations.
Open Scope htriple.

(* do existing notations still work? *)
Record Rat : Set := mkRat {
top: nat; bottom: nat; Rat_cond: (gt bottom O) }.
Goal (forall b:bool, { b=true } + { b=false }). destruct b; auto. Qed.
Goal {a | a<>false}. exists true; intro; discriminate. Qed.

Goal (forall p, {p}%htriple_pred = ht_pred_ p). reflexivity. Qed.

Goal (forall p c q,
|- {p} c {q} <-> ht (ht_pred_ p) c (ht_pred_ q)).
Proof. split; intros; auto. Qed.

End TestNotations.



-cj



Archive powered by MHonArc 2.6.18.

Top of Page