Repository navigation
Expand file tree
/
Copy pathPartial.lean
More file actions
46 lines (38 loc) · 1.87 KB
/
Copy pathPartial.lean
File metadata and controls
46 lines (38 loc) · 1.87 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
import Fe.Core
/-!
# Partial correctness of exported loops
A `partial_fixpoint` loop of an exported model comes with `fixpoint_induct` for admissible
predicates. "Every run that returns satisfies `Q`" is admissible (`admissible_exec`): a run
that diverges is `none`, the bottom of the flat order, and satisfies it.
-/
open Lean.Order
namespace Fe.M
/-- Any property of every run's outcome that a diverging run has is admissible. -/
theorem admissible_outcome {ρ σ α : Type}
(P : ρ → σ → Option (Except (Exit σ) (α × σ)) → Prop) (h : ∀ env w, P env w none) :
admissible (fun (m : Fe.M ρ σ α) => ∀ env w, P env w (m.exec env w)) := by
apply admissible_pi_apply (β := fun _ : ρ => StateT σ (ExceptT (Exit σ) Option) α)
(P := fun env g => ∀ w, P env w ((g.run w).run))
intro env
apply admissible_pi_apply (β := fun _ : σ => ExceptT (Exit σ) Option (α × σ))
(P := fun w g => P env w g.run)
intro w
exact admissible_flatOrder _ (h env w)
/-- `admissible_pi_apply` for a non-dependent argument, one argument of a curried loop at a
time. -/
theorem admissible_arrow {α β : Type} [CCPO β] (P : α → β → Prop) (h : ∀ x, admissible (P x)) :
admissible (fun f : α → β => ∀ x, P x (f x)) :=
admissible_pi_apply (β := fun _ => β) P h
theorem admissible_exec {ρ σ α : Type} (Q : α → σ → Prop) :
admissible (fun (m : Fe.M ρ σ α) =>
∀ env w r w', m.exec env w = some (.ok (r, w')) → Q r w') := by
apply admissible_pi_apply (β := fun _ : ρ => StateT σ (ExceptT (Exit σ) Option) α)
(P := fun _ g => ∀ w r w', ((g.run w).run) = some (.ok (r, w')) → Q r w')
intro env
apply admissible_pi_apply (β := fun _ : σ => ExceptT (Exit σ) Option (α × σ))
(P := fun _ g => ∀ r w', g.run = some (.ok (r, w')) → Q r w')
intro w
apply admissible_flatOrder
intro r w' h
cases h
end Fe.M