~james/remy

feat(model): prove optimiser idempotence and scope weakening

commit
974b16e2aca2567ecf0d3f566f3287566f49c530 browse tree
parent
3ac5bae085495f49c3f24dbfb40242ee81069c4f
author
james <j@cpl0.zip>
signature
Verified ~james signed with a key registered by ~james
date
2026-09-02 11:00 UTC

1 files changed, +16 −0

src/Model.thy modified

@@ -94,4 +94,20 @@ lemma fold_cond_nodes: "nodes (fold_cond c a b) \<le> Suc (nodes c + nodes a + n
9494 theorem optimise_size: "nodes (optimise e) \<le> nodes e"
9595 by (induction e) (auto intro: order_trans[OF fold_binary_nodes] order_trans[OF fold_cond_nodes])
9696
97+lemma fold_binary_idempotent:
98+ "optimise a = a \<Longrightarrow> optimise b = b \<Longrightarrow>
99+ optimise (fold_binary op a b) = fold_binary op a b"
100+ by (cases a; cases b) auto
101+
102+lemma fold_cond_idempotent:
103+ "optimise c = c \<Longrightarrow> optimise a = a \<Longrightarrow> optimise b = b \<Longrightarrow>
104+ optimise (fold_cond c a b) = fold_cond c a b"
105+ by (cases c) auto
106+
107+theorem optimise_idempotent: "optimise (optimise e) = optimise e"
108+ by (induction e) (auto intro: fold_binary_idempotent fold_cond_idempotent)
109+
110+theorem scoped_weaken: "scoped n e \<Longrightarrow> n \<le> m \<Longrightarrow> scoped m e"
111+ by (induction e arbitrary: n m) auto
112+
97113 end