Skip to content

New lemmas for List - #1072

Open
namasikanam wants to merge 1 commit into
mainfrom
oram-new-lemmas-list
Open

New lemmas for List#1072
namasikanam wants to merge 1 commit into
mainfrom
oram-new-lemmas-list

Conversation

@namasikanam

Copy link
Copy Markdown
Collaborator

There are a few new lemmas and four new operators:

  • isprefix: whether one list is a prefix of the other list
  • prefixes: the sets of all prefixes of a list
  • interval: a consecutive subsequence of a list
  • rfind: reverse finding (start from the end of the list)

Also, I reduced smt usage in some old proofs, as smt solving in those proof fails on my machine. I believe these updates only make proofs better :)

@strub

strub commented Jul 15, 2026

Copy link
Copy Markdown
Member

@namasikanam Did you change some lemmas?

@fdupress

Copy link
Copy Markdown
Member

The SHA3 one could be a smt(@List) that blows up with new lemmas. The stdlib failure is inside List itself, so likely one of the new lemmas. (Different SMT environment between @namasikanam's machine and the docker?)

@namasikanam

namasikanam commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

I didn't change any statement of existing lemmas (only update some proofs when they are not running on my machine). I coudn't find smt(@List) in SHA3, either. Do not understand why sha-3 is broken. I will try to reproduce the failure in a local docker.

@strub

strub commented Jul 17, 2026

Copy link
Copy Markdown
Member

I didn't change any statement of existing lemmas (only update some proofs when they are not running on my machine). I didn't find smt(@List). Do not understand why sha-3 is broken. I will try to reproduce the failure in a local docker.

Maybe the sha3 dev contains rogue smt?

@namasikanam
namasikanam force-pushed the oram-new-lemmas-list branch from e221166 to e211fc2 Compare July 18, 2026 09:44
@namasikanam

Copy link
Copy Markdown
Collaborator Author

Maybe the sha3 dev contains rogue smt?

I fixed the inconsistency in docker. I couldn't reproduce the failure for SHA3. But it turned out that the failure in SHA3 gets also resolved magically :)

@namasikanam

Copy link
Copy Markdown
Collaborator Author

I will always test within docker before creating a PR in the future :)

lemma find_le ['a] (p : 'a -> bool) (s : 'a list) (n : int) :
0 <= n < size s => p (nth witness s n) => find p s <= n.
proof.
move=> [ge0_n _] pn; apply/lezNgt/negP => lt_n.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you're not going to use n < size s you might as well remove it from the lemma statement.

Comment thread theories/datatypes/List.ec
qed.

lemma subseq_range (l1 l2 r1 r2 : int) :
l1 <= l2 <= r2 <= r1 => subseq (range l2 r2) (range l1 r1).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You don't need l2 <= r2 here.

(* -------------------------------------------------------------------- *)
(* prefixes *)
(* -------------------------------------------------------------------- *)
op isprefix ['a] (s1 s2 : 'a list) : bool =

@oskgo oskgo Aug 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You should also expose a recursive definition through lemmas to enable induction. isprefix_nil s: isprefix [] s and isprefix_cons s1 s2 x1 x2: isprefix (x1::s1) (x2::s2) <=> (isprefix s1 s2 /\ x1 = x2)

(* rfind p l = index of the last element of l satisfying p *)
(* (or -1 if there is none). *)
(* -------------------------------------------------------------------- *)
op rfind ['a] (p : 'a -> bool) (l : 'a list) : int =

@oskgo oskgo Aug 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This rfind operator should have lemmas corresponding to all existing find lemmas when possible.
This section should be next to the find section if possible.

(* interval *)
(* interval s l r = the slice s[l..r) (l included, r excluded) *)
(* -------------------------------------------------------------------- *)
op interval ['a] (s : 'a list) (l r : int) = drop l (take r s).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a name like sublist would be better. This has precedence (https://www.w3schools.com/java/ref_arraylist_sublist.asp)

size s <= r => interval s l r = drop l s.
proof. by move=> *; rewrite /interval take_oversize. qed.

lemma interval_subseq ['a] (s : 'a list) (l1 l2 r1 r2 : int) :

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would expect a lemma with this name to prove subseq (interval s l r) s. Change the name to interval_subseq_interval

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.

4 participants