Skip to content

Added first part of Lab#22

Open
DumitruIlie wants to merge 9 commits into
masterfrom
ilie-dumitru
Open

Added first part of Lab#22
DumitruIlie wants to merge 9 commits into
masterfrom
ilie-dumitru

Conversation

@DumitruIlie

Copy link
Copy Markdown
Collaborator

No description provided.

@DumitruIlie

Copy link
Copy Markdown
Collaborator Author

Also added optional lemmas. Last one was not the hardest (:

Comment on lines +30 to +37
induction r
· rename_i μ st'' h
simp only [step, fetchInstr, replaceStackAndIncrPC, incrPC, stackPeek1,
replaceMemStackAndIncrPC, stackPeek2, beq_iff_eq, gt_iff_lt] at h
by_cases pc_ok : μ.pc < μ.code.length
· simp only [pc_ok, ↓reduceDIte] at h
generalize m : μ.code[μ.pc] = c
cases c

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhh this looks like it was painful. See my comment here. When you have repetitive case analysis, aesop is generally your friend. The idea is to distribute as many of the simp lemmas (e.g., bind, Except.bind) before you perform the case analysis, not after.

rw [←stp]
unfold isError
simp only
· rename_i st1 st2 sti st1i sti2 ih0 ih1

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do induction or cases, you can give explicit names to your hypotheses and avoid using rename_i. The keyword you're missing is with.

Suggested change
· rename_i st1 st2 sti st1i sti2 ih0 ih1
induction r with
| @step μ st'' stp =>
unfold isFinal at h
simp only at h
simp only [step, bind, Except.bind, fetchInstr, h, Nat.lt_irrefl, ↓reduceDIte] at stp
rw [←stp]
unfold isError
simp only
| @trans st1 st2 sti st1i sti2 ih0 ih1 =>
specialize ih0 h
cases sti
· exact isErrorLemma.elim sti2
· unfold isError at ih0
simp at ih0

Same goes for cases. There's an "at" symbol there (@) because you also provide names to the anonymous parameters of step and trans. If you don't need those names, just skip the "at".

Comment on lines +228 to +229
lemma execTrans {μ μ'} (h : Reachable (.ok μ) (.ok μ')) :
∃ k : ℕ, ∀ n : ℕ, execute (n + k) μ = execute n μ' := by

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, cleanly stated!

@alexoltean61 alexoltean61 force-pushed the master branch 3 times, most recently from c7c1340 to 0a51137 Compare June 1, 2026 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants