Skip to content
Snippets Groups Projects

Added proof for substr_l_eq

Closed Rex Yuan requested to merge (removed):master into master
1 unresolved thread

Added the proof along with helper lemma for substr_l_eq

Merge request reports

Closed by Rex YuanRex Yuan 2 years ago (Jun 13, 2022 6:07pm UTC)

Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
12 12
13 13 (* @TODO *)
14 14 (** The substring left identity *)
15 Axiom substr_l_eq : forall {s1 s2},
15 Lemma conc : forall {s1 : string},
  • Comment on lines -15 to +15

    OK cool for the proofs! Here is a proof suggestion using our practices:

    (** The substring left identity *)
    Lemma conc {s1 : string} :
      s1 ++ "" = s1.
    Proof.
      induction s1; sfirstorder.
    Qed.
    
    Lemma subss {s1 : string} :
      substring 0 (length s1) s1 = s1.
    Proof.
      induction s1; sfirstorder.
    Qed.
    
    Lemma zerozero {s1 : string} :
      substring 0 0 s1 = "".
    Proof.
      sauto lq: on.
    Qed.
    
    Lemma substr_l_eq {s1 s2} :
      String.sub (s1 ++ s2) 0 (String.length s1) = s1.
    Proof.
      induction s1; simpl.
      { apply zerozero. }
      { unfold String.sub, String.length, CoqOfOCaml.String.length in *.
        rewrite Nat2Z.id in *; simpl in *.
        sfirstorder.
      }
    Qed.

    Notes:

    • sfirstorder and sauto are obtained from running the tactic best https://coqhammer.github.io/
    • We separate sub-goals with { ... }
    • We put the parameters of the lemma on the left of the : so that there are less intros to do.
  • Please register or sign in to reply
  • Also, I added you to the project's members so that you can open a merge request without doing a fork and use the CI system.

  • (you can re-open your merge request then)

  • Author Contributor

    Merged as !568 (merged)

  • closed

  • Please register or sign in to reply
    Loading