Theory Test

(*
Authors: Makarius Wenzel (2018)

Some Isabelle/Naproche examples for testing.
*)

section ‹Naproche-SAD texts within the Isabelle context›

theory Test
  imports Naproche.Naproche
begin

subsection ‹Inlined text›

declare [[naproche_isabelle]]

forthel ‹
[synonym element/-s] [synonym system/-s] [synonym reduct/-s] [synonym term/-s]

Signature Rewriting system.  A rewriting system is a notion.
Signature Term. A term is an object.

Let a,b,c,d,u,v,w,x,y,z denote terms.
Let R,S,T denote rewriting systems.

Signature Reduct.   A reduct of x in R is a term.

Let x -R> y stand for y is a reduct of x in R.

Signature. x -R+> y is a relation.

Axiom TCDef.   x -R+> y <=> x -R> y \/ exists z : x -R> z -R+> y.
Axiom TCTrans.      x -R+> y -R+> z => x -R+> z.

Definition TCRDef.  x -R*> y <=> x = y \/ x -R+> y.
Lemma TCRTrans.     x -R*> y -R*> z => x -R*> z.

Definition CRDef.   R is confluent iff
    for all a,b,c  such that a -R*> b,c
    there exists d such that b,c -R*> d.

Definition WCRDef.  R is locally confluent iff
    for all a,b,c  such that a -R> b,c
    there exists d such that b,c -R*> d.

Definition Termin.  R is terminating iff for all a,b
    a -R+> b => b -<- a.

Definition NFRDef.  A normal form of x in R is a term y
                    such that x -R*> y and y has no reducts in R.

Lemma TermNF.   Let R be a terminating rewriting system.
                Every term x has a normal form in R.
Proof by induction. Obvious.

Lemma Newman.
    Any locally confluent terminating rewriting system is confluent.
Proof.
Let R be a rewriting system.
    Assume R is locally confluent and terminating.
    Let us demonstrate by induction that for all a,b,c
    such that a -R*> b,c there exists d such that b,c -R*> d.
        Let a,b,c be terms.
        Let us show that if a -R+> b,c then thesis.
            Assume a -R+> b,c.

            Take u such that a -R> u -R*> b.
            Take v such that a -R> v -R*> c.
            Take w such that u,v -R*> w.
            Take a normal form d of w in R.
    
            b -R*> d. Indeed take x such that b,d -R*> x.
            c -R*> d. Indeed take y such that c,d -R*> y.
        End.
    End.
End.
›

naproche_problems

naproche_problem 1
  by (metis assms(6) assms(7) assms(8))
naproche_problem 2 using assms
  by (metis assms(11) assms(12) assms(13) assms(3) assms(5) assms(7))
naproche_problem 3
  by (metis (no_types, lifting) assms(14) assms(16) assms(18) assms(5) assms(7))
naproche_problem 4
  by (metis assms(14) assms(16) assms(18) assms(5) assms(7))
naproche_problem 5
  by (metis (no_types, lifting) assms(10) assms(14) assms(15) assms(16) assms(19) assms(20))
naproche_problem 6
  by (metis assms(13) assms(14) assms(15) assms(21))
naproche_problem 7
  by (smt (verit, del_insts) assms(11) assms(12) assms(14) assms(15) assms(16) assms(17) assms(19) assms(21) assms(22) assms(5) assms(8))
naproche_problem 8
  by (metis (no_types, lifting) assms(12) assms(14) assms(21) assms(22) assms(23) assms(5) assms(7))
naproche_problem 9
  by (smt (verit, del_insts) assms(11) assms(12) assms(14) assms(15) assms(16) assms(17) assms(20) assms(21) assms(22) assms(5) assms(8))
naproche_problem 10
  by (metis assms(12) assms(14) assms(21) assms(22) assms(24) assms(5) assms(7))
naproche_problem 11
  by (metis (no_types, lifting))
naproche_problem 12
  by (metis (no_types, lifting) assms(14) assms(16) assms(18) assms(7))
naproche_problem 13
  by (metis (mono_tags, lifting))


subsection ‹External text file›

declare [[naproche_prove = false]]

forthel_file ‹$NAPROCHE_HOME/examples/newman.ftl›
forthel_file ‹$NAPROCHE_HOME/examples/newman.ftl.tex›

end