(* ========================================================================= *)
(* *)
(* Geometrical Optics Library *)
(* *)
(* (c) Copyright, Muhammad Umair Siddique, Vincent Aravantinos, 2012 *)
(* Hardware Verification Group, *)
(* Concordia University *)
(* *)
(* Contact: <muh_sidd@ece.concordia.ca>, <vincent@ece.concordia.ca> *)
(* *)
(* Last update: Feb 16, 2012 *)
(* *)
(* ========================================================================= *)
needs "Multivariate/make_complex.ml";;
needs "utils.ml";;
(* ------------------------------------------------------------------------- *)
(* Preliminaries *)
(* ------------------------------------------------------------------------- *)
(* ------------------------------------------------------------------------- *)
(* System formalization *)
(* ------------------------------------------------------------------------- *)
new_type_abbrev ("free_space",`:real#real`);;
;
;
new_type_abbrev("optical_component",`:free_space#interface#interface_kind`);;
new_type_abbrev("optical_system",`:optical_component list#free_space`);;
(* ------------------------------------------------------------------------- *)
(* Ray formalization *)
(* ------------------------------------------------------------------------- *)
new_type_abbrev("single_ray",`:real#real`);;
new_type_abbrev("ray",
`:single_ray # single_ray # (single_ray # single_ray) list`);;
let EXISTS_IS_VALID_RAY_IN_SYSTEM = prove(
`?f. !sr1 sr2 h h' fs cs rs i ik y0 theta0 y1 theta1 y2 theta2 y3 theta3 n d n' d'.
(f (sr1,sr2,[]) (CONS h cs,fs) <=> F) /\
(f (sr1,sr2, CONS h' rs) ([],fs) <=> F) /\
(f ((y0,theta0),(y1,theta1), []) ([],(n,d)) <=>
is_valid_ray_in_free_space (y0,theta0) (y1,theta1) (n,d)) /\
(f ((y0,theta0),(y1,theta1), CONS ((y2,theta2),(y3,theta3)) rs)
((CONS ((n',d'),i,ik) cs),(n,d)) <=>
(
is_valid_ray_in_free_space (y0,theta0) (y1,theta1) (n',d') /\
(
is_valid_ray_at_interface (y1,theta1) (y2,theta2) n' (
head_index(cs,(n,d))) i ik))
/\ f ((y2,theta2),(y3,theta3),rs) (cs,(n,d)))`,
SUBGOAL_THEN `!y0 theta0 y1 theta1 n d. ?f1. (f1 ([]:(free_space#interface#interface_kind)list) =
is_valid_ray_in_free_space (y0,theta0) (y1,theta1) (n,d)
/\ !h t. f1 (CONS h t) = F)` (STRIP_ASSUME_TAC o REWRITE_RULE[
SKOLEM_THM])
THENL [
REPEAT GEN_TAC THEN MATCH_ACCEPT_TAC list_RECURSION;
SUBGOAL_THEN
`!y2 theta2 self y0 theta0 y1 theta1 (fs:free_space). ?f2. (f2 [] = F /\ !h t.
f2 (CONS h t) <=>
let (n,d),i,ik = h in
is_valid_ray_in_free_space (y0,theta0) (y1,theta1) (n,d) /\
is_valid_ray_at_interface (y1,theta1) (y2,theta2) n (
head_index(t,fs)) i ik /\
self t)`
(STRIP_ASSUME_TAC o REWRITE_RULE[
SKOLEM_THM])
THENL [
REPEAT GEN_TAC THEN MATCH_ACCEPT_TAC list_RECURSION;
SUBGOAL_THEN
`!n:real d:real. ?g. (g [] = (\y0:real theta0:real y1:real theta1:real. f1 y0 theta0 y1 theta1 n d) /\ !h t. g (CONS h t) =
\y0:real theta0:real y1:real theta1:real.
let (y2,theta2),(y3,theta3) = (h:single_ray#single_ray) in
(f2 y2 theta2 (g t y2 theta2 y3 theta3) y0 theta0 y1 theta1 (n,d)):(free_space#interface#interface_kind)list ->bool)`
(STRIP_ASSUME_TAC o REWRITE_RULE [
SKOLEM_THM])
THENL [
REPEAT GEN_TAC THEN MATCH_ACCEPT_TAC list_RECURSION;
EXISTS_TAC `\(((y0,theta0),(y1,theta1),rs):ray) ((cs,(n,d)):optical_system). (g n d rs y0 theta0 y1 theta1 cs):bool`
THEN ASM_REWRITE_TAC[
LET_DEF;
LET_END_DEF;
CONJ_ACI;
FORALL_PAIR_THM]
]
]
]);;
(* ------------------------------------------------------------------------- *)
(* 2x2 Matrices *)
(* ------------------------------------------------------------------------- *)
overload_interface("pow",`mat_pow:real^N^N->num->real^N^N`);;
let COMMON_TAC xs =
SIMP_TAC (xs @ [mat2x2;CART_EQ;VECTOR_2;DIMINDEX_2;FORALL_2;DOT_2;SUM_2]);;
let MAT2X2_EQ = prove
(`!A B C D P Q R S. mat2x2 A B C D = mat2x2 P Q R S <=>
A = P /\ B = Q /\ C = R /\ D = S`,
COMMON_TAC [] THEN CONV_TAC TAUT);;
let MAT2X2_MUL = prove
(`!A B C D P Q R S.
mat2x2 A B C D ** mat2x2 P Q R S =
mat2x2 (A*P + B*R) (A*Q + B*S) (C*P + D*R) (C*Q + D*S)`,
let MAT2X2_ID = CONJ MAT2X2_LID MAT2X2_RID;;
let MAT2X2_EQ_SCALAR_LMUL = prove
(`!A B C D P Q R S. ~(k = &0) ==>
(k %% mat2x2 A B C D = k %% mat2x2 P Q R S
<=> A = P /\ B = Q /\ C = R /\ D = S)`,
let MAT2_MUL = prove (
` !(M:real^2^2). M**M = mat2x2((M$1$1 * M$1$1) + (M$1$2 * M$2$1))
((M$1$1 * M$1$2) + (M$1$2 * M$2$2))
((M$2$1 * M$1$1) + (M$2$2 * M$2$1))
((M$2$1 * M$1$2) + (M$2$2 * M$2$2))`,
(* ------------------------------------------------------------------------- *)
(* Matrix formalism *)
(* ------------------------------------------------------------------------- *)
(*-------------------------------------------------------------------------
---Verification of matrix relationships for free space and interfaces------
-- ** PI= Plane Interface *** SI = Spherical Interface ** FS = Free Space--
--------------------------------------------------------------------------*)
let common_prove t = prove (t,
SIMP_TAC[free_space_matrix;FORALL_FREE_SPACE_THM;MAT2X2_VECTOR_MUL;VECTOR2_EQ;
LET_END_DEF;is_valid_ray_in_free_space;REAL_MUL_LZERO;REAL_MUL_LID;LET_DEF;
REAL_ADD_LID;interface_matrix;is_valid_ray_at_interface;REAL_ADD_RID]
THEN CONV_TAC REAL_FIELD);;
let FS_MATRIX = common_prove
`!fs y0 theta0 y1 theta1.
is_valid_free_space fs
/\ is_valid_ray_in_free_space (y0,theta0) (y1,theta1) fs
==> vector[y1;theta1] = free_space_matrix fs ** vector[y0;theta0]`;;
let PI_MATRIX_TRANSMITTED = common_prove
`!n0 n1 y0 theta0 y1 theta1.
is_valid_ray_at_interface (y0,theta0) (y1,theta1) n0 n1 plane transmitted
/\ &0 < n0 /\ &0 < n1
==> vector [y1;theta1]
= interface_matrix n0 n1 plane transmitted ** vector [y0; theta0]`;;
let PI_MATRIX_REFLECTED = common_prove
`!n0 y0 theta0 y1 theta1.
is_valid_ray_at_interface (y0,theta0) (y1,theta1) n0 n1 plane reflected
/\ &0 < n0 /\ &0 < n1
==> vector [y1;theta1]
= interface_matrix n0 n1 plane reflected ** vector [y0;theta0]`;;
let SI_MATRIX_TRANSMITTED = common_prove
`!n0 n1 y0 theta0 y1 theta1 R.
is_valid_interface (spherical R) /\ &0 < n0 /\ &0 < n1
/\ is_valid_ray_at_interface (y0,theta0) (y1,theta1) n0 n1 (spherical R)
transmitted
==> vector [y1;theta1]
= interface_matrix n0 n1 (spherical R) transmitted ** vector [y0;theta0]`;;
let SI_MATRIX_REFLECTED = common_prove
`!n0 y0 theta0 y1 theta1 R.
is_valid_interface (spherical R) /\ &0 < n0
/\ is_valid_ray_at_interface (y0,theta0) (y1,theta1) n0 n1 (spherical R)
reflected
==> vector [y1;theta1]
= interface_matrix n0 n1 (spherical R) reflected ** vector [y0; theta0]`;;
(*-------General Relationship for any Interface i --------------------*)
(*-----------------------------------------------*)
let system_composition = define
`system_composition ([],fs) = free_space_matrix fs /\
system_composition (CONS ((n',d'),i,ik) cs,n,d) =
system_composition (cs,n,d)
** interface_matrix n' (head_index (cs,n,d)) i ik
** free_space_matrix (n',d')`;;