Repository navigation
Expand file tree
/
Copy pathStability.lean
More file actions
49 lines (42 loc) · 1.69 KB
/
Copy pathStability.lean
File metadata and controls
49 lines (42 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import Langlib.Languages.JavaGen.Semantics
/-! # JavaGen: completed runs and stationary queries
These proofs concern the actual evaluator, including the retained proof
record. They do not assume validator correctness or Java correspondence.
-/
namespace Langlib.JavaGen
open Langlib.Common
/-- More fuel cannot change a completed result, including its proof record. -/
theorem exec_stable (p : Prepared) :
∀ (n m : Nat) (st : State), n ≤ m → (exec p n st).2 ≠ .outOfFuel →
exec p m st = exec p n st := by
intro n
induction n with
| zero => intro m st _ h; exact absurd rfl h
| succ n ih =>
intro m st hnm h
obtain ⟨m', rfl⟩ : ∃ m', m = m' + 1 := ⟨m - 1, by omega⟩
have hn : n ≤ m' := by omega
cases hs : step p st.query with
| accept frame => simp [exec, hs]
| reject => simp [exec, hs]
| next frame q =>
simp only [exec, hs] at h ⊢
exact ih m' _ hn h
theorem evalProg_stable (p : Prepared) {n m : Nat} (hnm : n ≤ m)
(h : (evalProg p n).exit ≠ .outOfFuel) :
evalProg p m = evalProg p n := by
unfold evalProg at h ⊢
split
· rfl
· next hg =>
rw [if_neg hg] at h
rw [exec_stable p n m ⟨p.source.query, []⟩ hnm h]
/-- A query returning to itself really diverges at every finite fuel,
even though the retained history keeps growing. The step has positive cost. -/
theorem exec_self_loop (p : Prepared) (q : Query) (frame : Frame)
(hs : step p q = .next frame q) (fuel : Nat) (history : List Frame) :
(exec p fuel ⟨q, history⟩).2 = .outOfFuel := by
induction fuel generalizing history with
| zero => rfl
| succ fuel ih => simpa only [exec, hs] using ih (frame :: history)
end Langlib.JavaGen