(* Title: Aodv_Message.thy License: BSD 2-Clause. See LICENSE. Author: Timothy Bourke, Inria *) section "AODV protocol messages" theory Aodv_Message imports Aodv_Basic begin datatype msg = Rreq nat rreqid ip sqn k ip sqn ip | Rrep nat ip sqn ip ip | Rerr "ip \ sqn" ip | Newpkt data ip | Pkt data ip ip instantiation msg :: msg begin definition newpkt_def [simp]: "newpkt \ \(d, dip). Newpkt d dip" definition eq_newpkt_def: "eq_newpkt m \ case m of Newpkt d dip \ True | _ \ False" instance by intro_classes (simp add: eq_newpkt_def) end text \The @{type msg} type models the different messages used within AODV. The instantiation as a @{class msg} is a technicality due to the special treatment of @{term newpkt} messages in the AWN SOS rules. This use of classes allows a clean separation of the AWN-specific definitions and these AODV-specific definitions.\ definition rreq :: "nat \ rreqid \ ip \ sqn \ k \ ip \ sqn \ ip \ msg" where "rreq \ \(hops, rreqid, dip, dsn, dsk, oip, osn, sip). Rreq hops rreqid dip dsn dsk oip osn sip" lemma rreq_simp [simp]: "rreq(hops, rreqid, dip, dsn, dsk, oip, osn, sip) = Rreq hops rreqid dip dsn dsk oip osn sip" unfolding rreq_def by simp definition rrep :: "nat \ ip \ sqn \ ip \ ip \ msg" where "rrep \ \(hops, dip, dsn, oip, sip). Rrep hops dip dsn oip sip" lemma rrep_simp [simp]: "rrep(hops, dip, dsn, oip, sip) = Rrep hops dip dsn oip sip" unfolding rrep_def by simp definition rerr :: "(ip \ sqn) \ ip \ msg" where "rerr \ \(dests, sip). Rerr dests sip" lemma rerr_simp [simp]: "rerr(dests, sip) = Rerr dests sip" unfolding rerr_def by simp lemma not_eq_newpkt_rreq [simp]: "\eq_newpkt (Rreq hops rreqid dip dsn dsk oip osn sip)" unfolding eq_newpkt_def by simp lemma not_eq_newpkt_rrep [simp]: "\eq_newpkt (Rrep hops dip dsn oip sip)" unfolding eq_newpkt_def by simp lemma not_eq_newpkt_rerr [simp]: "\eq_newpkt (Rerr dests sip)" unfolding eq_newpkt_def by simp lemma not_eq_newpkt_pkt [simp]: "\eq_newpkt (Pkt d dip sip)" unfolding eq_newpkt_def by simp definition pkt :: "data \ ip \ ip \ msg" where "pkt \ \(d, dip, sip). Pkt d dip sip" lemma pkt_simp [simp]: "pkt(d, dip, sip) = Pkt d dip sip" unfolding pkt_def by simp end