(* 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.
Fixpoint rest (p r s n : nat) {struct n} : nat :=
match n with
| O => r
| S n' =>
match s with
| O => 0
| S O => rest p 0 p n'
| S s' => rest p (S r) s' n'
end
end.
Definition mod_ (m n : nat) : nat := rest n 0 n m.
Proof with trivial.
intro m; unfold mod_ in |- *; unfold rest in |- *...
Qed.
Definition trkrate (phi : Bank) : R :=
toDeg (g * (tand phi / v intruderSpeed)).
left; rewrite <- Ropp_0; apply Ropp_lt_gt_contravar; unfold toDeg in |- *;
repeat simple apply Rmult_lt_0_compat.
unfold MaxBank in |- *; unfold Rdiv in |- *; apply Rmult_lt_0_compat.
prove_sup.
apply Rinv_0_lt_compat; prove_sup.
unfold plat in |- *; prove_sup.
apply Rinv_0_lt_compat; apply PI_RGT_0.
Qed.
left; unfold toDeg in |- *; repeat simple apply Rmult_lt_0_compat.
unfold MaxBank in |- *; unfold Rdiv in |- *; apply Rmult_lt_0_compat.
prove_sup.
apply Rinv_0_lt_compat; prove_sup.
unfold plat in |- *; prove_sup.
apply Rinv_0_lt_compat; apply PI_RGT_0.
Qed.
Proof with trivial.
unfold trkrate in |- *; replace (r (mkBank 0 cond1_0 cond2_0)) with 0%R...
unfold toDeg, tand in |- *; unfold toRad in |- *; repeat rewrite Rmult_0_l;
rewrite tan_0; unfold Rdiv in |- *; repeat rewrite Rmult_assoc;
repeat rewrite Rmult_0_l; apply Rmult_0_r...
Qed.
Definition distance (s1 s2 : State) : R :=
sqrt (Rsqr (xt s2 - xt s1) + Rsqr (yt s2 - yt s1)).
Proof with trivial.
intros; unfold distance in |- *; rewrite (Rsqr_neg (xt s2 - xt s1));
rewrite (Rsqr_neg (yt s2 - yt s1)); repeat rewrite Ropp_minus_distr...
Qed.
Definition alerting_distance (s1 s2 : State) : Prop :=
(distance s1 s2 <= AlertRange)%R.
Definition conflict_distance (s1 s2 : State) : Prop :=
(distance s1 s2 <= ConflictRange)%R.
Definition chkrange (range tpred : R) : Prop :=
(range <= AlertRange)%R /\ (tpred <= AlertTime)%R.
Definition chktrack (intruder evader : State) (tpred : R) : Prop :=
let tau := tau intruder evader 0 in
match Rle_dec tau 0 with
| left _ => chkrange (RR intruder evader 0) tpred
| right _ =>
match Rlt_dec AlertTime (tpred + tau) with
| left _ => (RR intruder evader AlertTime <= AlertRange)%R
| right _ => (RR intruder evader tau <= AlertRange)%R
end
end.
Definition arc_loop (intruder evader : State) (arcrad trkrate : R)
(idtrk iarc : nat) : Prop :=
match iarc with
| S p => False
| O =>
let tpred := (INR iarc * tstep)%R in
let xloc := (xt evader + v evaderSpeed * tpred)%R in
let yloc := yt evader in
let xtrk :=
match Rlt_le_dec 0 trkrate with
| left _ =>
(xt intruder +
arcrad *
(sind (heading intruder + trkrate * tpred) -
sind (heading intruder)))%R
| right _ =>
(xt intruder +
arcrad *
(sind (heading intruder) - sind (heading intruder) +
trkrate * tpred))%R
end in
let ytrk :=
match Rlt_le_dec 0 trkrate with
| left _ =>
(yt intruder +
arcrad *
(cosd (heading intruder) -
cosd (heading intruder + trkrate * tpred)))%R
| right _ =>
(yt intruder +
arcrad *
(cosd (heading intruder + trkrate * tpred) -
cosd (heading intruder)))%R
end in
match mod_ iarc idtrk with
| O =>
let tantrk := (heading intruder + tpred * trkrate)%R in
let int := mkState xtrk ytrk tantrk (bank intruder) in
let eva := mkState xloc yloc (heading evader) (bank evader) in
chktrack int eva tpred
| _ =>
let range := sqrt (Rsqr (xtrk - xloc) + Rsqr (ytrk - yloc)) in
chkrange range tpred
end
end.
Definition ails_alert (intruder evader : State) : Prop :=
let phi := bank intruder in
let trkrate := trkrate phi in
match Req_EM_var trkrate 0 with
| left _ => chktrack intruder evader 0
| right _ =>
let arcrad := (Rsqr (v intruderSpeed) / (g * tand (r phi)))%R in
let idtrk :=
match Rle_dec 3 trkrate with
| left _ => 1
| right _ =>
match Rle_dec (3 / 2) trkrate with
| left _ => 2
| right _ =>
match Rle_dec (3 / 4) trkrate with
| left _ => 4
| right _ => 8
end
end
end in
arc_loop intruder evader arcrad trkrate idtrk 0
end.
Proof with trivial.
intros; unfold RR, distance in |- *; unfold dx, dy in |- *;
repeat rewrite Rmult_0_l; repeat rewrite Rplus_0_r;
rewrite (Rsqr_neg (xt intruder - xt evader));
rewrite (Rsqr_neg (yt intruder - yt evader));
repeat rewrite Ropp_minus_distr...
Qed.
(*********************************************)
(************** MAIN THEOREM *****************)
(*********************************************)
Proof with trivial.
intros; unfold alerting_distance in H; unfold chktrack in |- *;
case (Rle_dec (tau intruder evader 0) 0); intro...
unfold chkrange in |- *; split...
rewrite R_distance; rewrite distance_sym...
unfold AlertTime in |- *; left; prove_sup...
case (Rlt_dec AlertTime (0 + tau intruder evader 0)); intro...
rewrite Rplus_0_l in r; cut (0 <= AlertTime)%R...
intro;
assert
(H1 :=
asymptotic_decrease_tau intruder evader 0 0 AlertTime
(Rlt_le AlertTime (tau intruder evader 0) r) H0);
repeat rewrite Rplus_0_l in H1; rewrite R_distance in H1;
rewrite distance_sym in H1; apply Rle_trans with (distance evader intruder)...
unfold AlertTime in |- *; left; prove_sup...
assert (H0 := derivative_eq_zero_min intruder evader 0 0);
repeat rewrite Rplus_0_l in H0; rewrite R_distance in H0;
rewrite distance_sym in H0; apply Rle_trans with (distance evader intruder)...
Qed.

Lemma step2 :
forall (evader intruder : State) (x : nat),
(distance evader intruder <= AlertRange)%R ->
trkrate (bank intruder) <> 0%R ->
arc_loop intruder evader (Rsqr intruderSpeed / (g * tand (bank intruder)))
(trkrate (bank intruder)) x 0.