File tutorial


(* What follows is a minimal example of how to use the ProofMode. *)

From MatchingLogic Require Import ProofMode.MLPM
                                  Definedness_ProofSystem.

Import MatchingLogic.Logic.Notations
       MatchingLogic.Theories.Definedness_Syntax.Notations.


Open Scope string_scope.
Open Scope list_scope.

Section tutorial.

Context {Σ : Signature}
        {Γ : Theory}
        (ϕ : Pattern)
        (wfϕ : well_formed ϕ).

(* Below we prove that in matching logic, ϕ -> ϕ for any pattern ϕ. *)
Example phi_implies_phi :
    Γϕ ---> ϕ.

(* We can also work with conjunction and disjunction. *)

Context (ϕ₁ : Pattern)
        (wfϕ₁ : well_formed ϕ₁)
        (ϕ₂ : Pattern)
        (wfϕ₂ : well_formed ϕ₂).

Example and_or :
    Γϕ₁ and ϕ₂ ---> ϕ₁ or ϕ₂
.

Context (ϕ₃ : Pattern)
        (wfϕ₃ : well_formed ϕ₃)
        (ϕ₄ : Pattern)
        (wfϕ₄ : well_formed ϕ₄).

Example use_rewrite :
    Γϕ₁ <---> ϕ₂
    (* The  operator is an application. *)
    Γ ⊢ (ϕ₃ϕ₁ϕ₄) <---> (ϕ₃ϕ₂ϕ₄)
.

(* We can also use definedness and equality.
   To do so, we have to assume that the signature contains a definedness symbol,
   and the theory a definedness axiom.
   Otherwise, the signature and axiom can be arbitrary.
*)


(* Obviously, without the definedness symbol, we cannot use equality. *)

(* The typeclass Definedness_Syntax.Syntax ensures the presence of the definedness symbol
   in the (implicit) signature Σ.
 *)

Context {syntax : Definedness_Syntax.Syntax}.

Example use_rewriteBy :
    Γ ⊢ (ϕ₁ϕ₄ =ml ϕ₂ϕ₄) ---> (ϕ₁ =ml ϕ₂) ---> ((ϕ₃ ⋅ (ϕ₁ϕ₄)) <---> (ϕ₃ ⋅ (ϕ₂ϕ₄)))
.

Context { : Definedness_Syntax.theoryΓ}.

Example use_rewriteBy :
    Γ ⊢ (ϕ₁ϕ₄ =ml ϕ₂ϕ₄ ) ---> (ϕ₁ =ml ϕ₂) ---> ((ϕ₃ ⋅ (ϕ₁ϕ₄)) <---> (ϕ₃ ⋅ (ϕ₂ϕ₄)))
.

(*
   We now demonstrate how to use local hypotheses that are implications.
*)

Example use_mlApply :
    Γ ⊢ (ϕ₁ ---> ϕ₂ϕ₃) ---> (ϕ₂ϕ₃ ---> ϕ₃) ---> (ϕ₁ ---> ϕ₃).

Context (ψ : Pattern)
        (wfψ : well_formed (ex, ψ)).

(*
   What if we have a matching logic implication in a Coq hypothesis
   or in a lemma? There is `mlApplyMeta` for that.
*)

Example use_mlApplyMeta :
    Γϕ₁ ---> ((ex, ψ) ⋅ ϕ₂) ---> ϕ₃ ---> (ex, (ψ ⋅ ϕ₂)).
    Check Prop_ex_left.
    (*
        Prop_ex_left
        : ∀ (Γ : Theory) (ϕ ψ : Pattern),
            well_formed (ex , ϕ)
            → well_formed ψ
            → Γ ⊢i (ex , ϕ) ⋅ ψ ---> (ex , ϕ ⋅ ψ) using BasicReasoning
    *)

    (* Did you notice that mlApplyMeta automatically instantiated
       all the preconditions of the lemma?
       That is, without some magic happening on the background,
       one would need to manualy specify them,
       and solve the well-formedness subgoals.
    *)

Defined.

End tutorial.

This page has been generated by coqdoc