Skip to content

[feat] examples: Add linked-list backed stack#213

Open
ethan-kharitonov wants to merge 1 commit into
awslabs:mainfrom
ethan-kharitonov:uRust-examples/stack
Open

[feat] examples: Add linked-list backed stack#213
ethan-kharitonov wants to merge 1 commit into
awslabs:mainfrom
ethan-kharitonov:uRust-examples/stack

Conversation

@ethan-kharitonov

@ethan-kharitonov ethan-kharitonov commented Apr 28, 2026

Copy link
Copy Markdown

Description of changes: Adds a stack uRust type built on top of the existing linked-list implementation.

  • Stack.thy: stack locale with stack_points_to predicate and verified empty, push, pop, is_empty, and push_all operations.
  • ROOT: Adds Stack theory.

Tested: isabelle build -d . Micro_Rust_Examples.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

lemma prism_embed_iso_prism_id [simp]: \<open>prism_embed (iso_prism id id) = id\<close>
by (auto simp: iso_prism_def)

lemma gref_map_id [simp]: \<open>gref_map id = id\<close>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: please use shows when expressing lemma statements and match the prevailing style.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Will fix.

shows \<open>\<Gamma>; push s x \<Turnstile>\<^sub>F push_contract s x ts\<close>
apply (crush_boot f: push_def contract: push_contract_def)
apply (clarsimp simp add: stack_points_to_def)
apply crush_base

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: can the two lines not be collapsed into:

apply (crush_base simp add: ll_focus_node_prism aentails_refl is_valid_ref_for_def)

shows \<open>\<Gamma>; pop s \<Turnstile>\<^sub>F pop_contract s ts\<close>
apply (crush_boot f: pop_def contract: pop_contract_def)
apply (cases ts; clarsimp simp add: stack_points_to_def ll_points_to_None asepconj_simp)
apply (crush_base split!: option.splits)+

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: additional space here of indentation. Is the + needed, also?

shows \<open>\<Gamma>; is_empty s \<Turnstile>\<^sub>F is_empty_contract s ts\<close>
apply (crush_boot f: is_empty_def contract: is_empty_contract_def)
apply (cases ts; clarsimp simp add: stack_points_to_def ll_points_to_None asepconj_simp)
apply (crush_base split!: option.splits)+

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: same comment as above.

\<theta> = \<open>\<lambda>_. \<langle>False\<rangle>\<close>
in wp_raw_for_loop_framedI'
\<close>)
subgoal by crush_base

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can these two subgoal commands not just be replaced with a single apply (crush_base simp add: take_Suc_conv_app_nth)?

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