Skip to content

Commit 91494d5

Browse files
hyperpolymathclaude
andcommitted
proof(coq): improve file_content_operations proof tactics
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c36139b commit 91494d5

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

proofs/coq/file_content_operations.v

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,30 +120,31 @@ Theorem write_file_reversible :
120120
read_file p fs = Some old_content ->
121121
write_file p old_content (write_file p new_content fs) = fs.
122122
Proof.
123-
intros p fs old_content new_content Hpre Hold.
123+
intros p fs old_content new_content _Hpre Hold.
124124
unfold write_file.
125125
apply functional_extensionality.
126126
intros p'.
127-
destruct (list_eq_dec String.string_dec p p').
127+
destruct (list_eq_dec String.string_dec p p') as [Heqp | Hneqp].
128128
- (* p = p' *)
129129
subst p'.
130130
unfold read_file in Hold.
131-
destruct Hpre as [node [Hnode [Htype [perms [Hperms Hwrite]]]]].
132-
rewrite Hnode.
133-
rewrite Htype.
134131
destruct (fs p) as [n|] eqn:Hfs; [|discriminate].
135-
simpl in Hold.
136132
destruct (node_type n) eqn:Hntype; [|discriminate].
137-
injection Hold as Heq.
138-
subst old_content.
139-
simpl.
140-
rewrite Hfs.
141-
rewrite Hntype.
142-
destruct n; simpl in *.
143-
subst node_type0.
133+
rewrite Hntype in Hold. simpl in Hold.
134+
destruct (node_content n) as [c|] eqn:Hcontent; [|discriminate].
135+
injection Hold as Heq. subst c.
136+
(* Both (list_eq_dec p p) branches are trivially left/right *)
137+
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra]; [|exact (Hcontra eq_refl)].
138+
rewrite Hfs. rewrite Hntype.
139+
(* After inner write: result is Some {|...; node_content := Some new_content|} *)
140+
destruct (list_eq_dec String.string_dec p p) as [_|Hcontra]; [|exact (Hcontra eq_refl)].
141+
rewrite Hfs. rewrite Hntype. simpl.
142+
(* node_type of the intermediate node is File, so outer write applies old_content *)
143+
destruct n as [nt perms cont]; simpl in *.
144+
subst nt. subst cont.
144145
reflexivity.
145146
- (* p <> p' *)
146-
reflexivity.
147+
destruct (list_eq_dec String.string_dec p p'); [contradiction | reflexivity].
147148
Qed.
148149

149150
(** * Content Preservation *)

0 commit comments

Comments
 (0)