(* This program is free software; you can redistribute it and/or      *)
(* modify it under the terms of the GNU Lesser General Public License *)
(* as published by the Free Software Foundation; either version 2.1   *)
(* of the License, or (at your option) any later version.             *)
(*                                                                    *)
(* This program is distributed in the hope that it will be useful,    *)
(* but WITHOUT ANY WARRANTY; without even the implied warranty of     *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *)
(* GNU General Public License for more details.                       *)
(*                                                                    *)
(* You should have received a copy of the GNU Lesser General Public   *)
(* License along with this program; if not, write to the Free         *)
(* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *)
(* 02110-1301 USA                                                     *)
Unset Standard Proposition Elimination Names.
(**********)
Definition dx (intruder evader : State) (t : R) : R :=
(xt intruder + t * intruderSpeed * cosd (heading intruder) -
(xt evader + t * evaderSpeed))%R.
Definition dy (intruder evader : State) (t : R) : R :=
(yt intruder + t * intruderSpeed * sind (heading intruder) - yt evader)%R.
Definition dxdt (intruder : State) : R :=
(intruderSpeed * cosd (heading intruder) - evaderSpeed)%R.
Definition dydt (intruder : State) : R :=
(intruderSpeed * sind (heading intruder))%R.
Definition RR (intruder evader : State) (t : R) : R :=
sqrt (Rsqr (dx intruder evader t) + Rsqr (dy intruder evader t)).
Definition div_tau (intruder evader : State) : R :=
(Rsqr (dxdt intruder) + Rsqr (dydt intruder))%R.
intros; elim (total_order_T r1 r2); intros.
elim a; intro.
right; red in |- *; intro; rewrite H in a0; elim (Rlt_irrefl r2 a0).
left; assumption.
right; red in |- *; intro.
rewrite H in b; elim (Rlt_irrefl r2 b).
Qed.
(***********)
Definition tau (intruder evader : State) (t : R) : R :=
match Req_EM_var (div_tau intruder evader) 0 with
| left _ => 0%R
| right _ =>
(-
(dx intruder evader t * dxdt intruder +
dy intruder evader t * dydt intruder) / div_tau intruder evader)%R
end.
Definition tmin (intruder evader : State) : R :=
match Req_EM_var (div_tau intruder evader) 0 with
| left _ => 0%R
| right _ =>
(-
(dxdt intruder * (xt intruder - xt evader) +
dydt intruder * (yt intruder - yt evader)) /
div_tau intruder evader)%R
end.

(**********)
Lemma tau_tmin :
forall (intruder evader : State) (t : R),
div_tau intruder evader <> 0%R ->
tau intruder evader t = (tmin intruder evader - t)%R.