Reasoning

[View perm.thm]

Click on a command or tactic to see a detailed view of its use.

Type is_o  o -> prop.

Import "list" with is_o := is_o. [View list]

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% adj J A K : K is J with A inserted somewhere
Define adj : olist -> o -> olist -> prop by
; adj L A (A :: L) := is_o A /\ is_list L
; adj (B :: K) A (B :: L) := is_o B /\ adj K A L
.

Theorem adj_1_is_list : forall K A L, adj K A L -> is_list K.

Theorem adj_2_is_o : forall K A L, adj K A L -> is_o A.

Theorem adj_3_is_list : forall K A L, adj K A L -> is_list L.

Theorem adj_exists : forall A L,
  is_o A -> is_list L ->
  exists M, adj L A M.

Theorem adj_swap : forall A J K B L,
  adj J A K -> adj K B L ->
  exists U, adj J B U /\ adj U A L.

Theorem adj_same : forall A L B, adj L A (B :: L) -> A = B.

Theorem adj_append_1 : forall J A K L KL,
  adj J A K ->
  append K L KL ->
  exists JL, append J L JL /\ adj JL A KL.

Theorem adj_1_append : forall J A K L JL,
  adj J A K ->
  append J L JL ->
  exists KL, append K L KL /\ adj JL A KL.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% perm J K : J and K have the same elements
Define perm : olist -> olist -> prop by
; perm nil nil
; perm K L :=
    exists A KK LL, adj KK A K /\ adj LL A L /\ perm KK LL.

Theorem perm_1_is_list : forall K L, perm K L -> is_list K.

Theorem perm_2_is_list : forall K L, perm K L -> is_list L.

Theorem perm_refl : forall L, is_list L -> perm L L.

Theorem perm_sym : forall K L, perm K L -> perm L K.

Theorem perm_cons_1 : forall A K L,
  perm (A :: K) L ->
  exists J, adj J A L /\ perm K J.

Theorem perm_cons_2 : forall A K L,
  perm K (A :: L) ->
  exists J, adj J A K /\ perm J L.

Theorem adj_preserves_perm : forall A JJ J KK K,
  adj JJ A J ->
  adj KK A K ->
  perm JJ KK ->
  perm J K.

Theorem perm_trans_lem : forall J K L, is_list K -> perm J K -> perm K L -> perm J L.

Theorem perm_trans : forall J K L, perm J K -> perm K L -> perm J L.

Theorem adj_same_source : forall J A K L,
  adj J A K -> adj J A L ->
  perm K L.

Theorem adj_same_result : forall J K A L,
  adj J A L ->
  adj K A L ->
  perm J K.

Theorem adj_same_result_diff : forall J A K B L,
  adj J A L ->
  adj K B L ->
  (A = B /\ perm J K) \/
  exists KK, adj KK A K.

Theorem adj_same_result_diff_both : forall J A K B L,
  adj J A L ->
  adj K B L ->
  (A = B /\ perm J K) \/
  exists JJ KK, adj JJ B J /\ adj KK A K /\ perm JJ KK.

Theorem perm_invert : forall A J K JJ KK,
  perm J K ->
  adj JJ A J ->
  adj KK A K ->
  perm JJ KK.

Theorem adj_perm_result : forall J K A JJ,
  perm J K ->
  adj JJ A J ->
  exists KK, adj KK A K /\ perm JJ KK.

Theorem adj_perm_source : forall J K A L,
  perm J K ->
  adj J A L ->
  exists LL, adj K A LL /\ perm L LL.

Theorem adj_nil_1 : forall A L, 
  adj nil A L -> L = A :: nil.

Theorem perm_nil_1 : forall L, 
  perm nil L -> L = nil.

Theorem adj_det : forall A B L,
  adj L A (B :: nil) -> A = B /\ L = nil.

Theorem perm_singleton : forall A L,
  perm (A :: nil) L -> L = (A :: nil).

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% append and perm

Theorem append_perm : forall J K L JJ KK,
  append J K L ->
  perm J JJ ->
  perm K KK ->
  exists LL, append JJ KK LL /\ perm L LL.

Theorem adj_perm : forall J K JJ A,
  perm J K ->
  adj JJ A J ->
  exists KK, adj KK A K.

Theorem adj_perm_full : forall J K JJ A,
  perm J K ->
  adj JJ A J ->
  exists KK, adj KK A K /\ perm JJ KK.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% set theoretic semantics of adj and perm

Theorem adj_member : forall J A L,
  adj J A L -> member A L.

Theorem member_adj : forall A L,
  is_list L -> member A L -> exists J, adj J A L.

Theorem member_adj_rel : forall JJ A J B,
  adj JJ A J -> member B J ->
  A = B \/ member B JJ.

Theorem adj_preserves_member_lem : forall A J B L,
  is_list J -> member A J -> adj J B L -> member A L.

Theorem adj_preserves_member : forall A J B L,
  member A J -> adj J B L -> member A L.

Theorem perm_preserves_member : forall A K L,
  perm K L ->
  member A K -> member A L.