theory FOR_Certificate
imports TRS.Term_Rewriting
begin
section ‹Syntax›
type_alias fvar = nat
datatype ftrs = Fwd nat | Bwd nat
definition map_ftrs where
"map_ftrs f = case_ftrs (Fwd ∘ f) (Bwd ∘ f)"
subsection ‹GTT relations›
datatype 'trs gtt_rel
= ARoot "'trs list"
| GInv "'trs gtt_rel"
| AUnion "'trs gtt_rel" "'trs gtt_rel"
| ATrancl "'trs gtt_rel"
| GTrancl "'trs gtt_rel"
| AComp "'trs gtt_rel" "'trs gtt_rel"
| GComp "'trs gtt_rel" "'trs gtt_rel"
definition GSteps where "GSteps trss = GTrancl (ARoot trss)"
subsection ‹RR1 and RR2 relations›
datatype pos_step
= PRoot
| PNonRoot
| PAny
datatype ext_step
= ESingle
| EParallel
| EStrictParallel
datatype 'trs rr1_rel
= R1Terms
| R1NF "'trs list"
| R1Inf "'trs rr2_rel"
| R1Proj nat "'trs rr2_rel"
| R1Union "'trs rr1_rel" "'trs rr1_rel"
| R1Inter "'trs rr1_rel" "'trs rr1_rel"
| R1Diff "'trs rr1_rel" "'trs rr1_rel"
and 'trs rr2_rel
= R2GTT_Rel "'trs gtt_rel" pos_step ext_step
| R2Diag "'trs rr1_rel"
| R2Prod "'trs rr1_rel" "'trs rr1_rel"
| R2Inv "'trs rr2_rel"
| R2Union "'trs rr2_rel" "'trs rr2_rel"
| R2Inter "'trs rr2_rel" "'trs rr2_rel"
| R2Diff "'trs rr2_rel" "'trs rr2_rel"
| R2Comp "'trs rr2_rel" "'trs rr2_rel"
definition R1Fin where
"R1Fin r = R1Diff R1Terms (R1Inf r)"
definition R2Eq where
"R2Eq = R2Diag R1Terms"
definition R2Reflc where
"R2Reflc r = R2Union r R2Eq"
definition R2Step where
"R2Step trss = R2GTT_Rel (ARoot trss) PAny ESingle"
definition R2StepEq where
"R2StepEq trss = R2Reflc (R2Step trss)"
definition R2Steps where
"R2Steps trss = R2GTT_Rel (GSteps trss) PAny EStrictParallel"
definition R2StepsEq where
"R2StepsEq trss = R2GTT_Rel (GSteps trss) PAny EParallel"
definition R2StepsNF where
"R2StepsNF trss = R2Inter (R2StepsEq trss) (R2Prod R1Terms (R1NF trss))"
definition R2ParStep where
"R2ParStep trss = R2GTT_Rel (ARoot trss) PAny EParallel"
definition R2RootStep where
"R2RootStep trss = R2GTT_Rel (ARoot trss) PRoot ESingle"
definition R2RootStepEq where
"R2RootStepEq trss = R2Reflc (R2RootStep trss)"
definition R2RootSteps where
"R2RootSteps trss = R2GTT_Rel (ATrancl (ARoot trss)) PRoot ESingle"
definition R2RootStepsEq where
"R2RootStepsEq trss = R2Reflc (R2RootSteps trss)"
definition R2NonRootStep where
"R2NonRootStep trss = R2GTT_Rel (ARoot trss) PNonRoot ESingle"
definition R2NonRootStepEq where
"R2NonRootStepEq trss = R2Reflc (R2NonRootStep trss)"
definition R2NonRootSteps where
"R2NonRootSteps trss = R2GTT_Rel (GSteps trss) PNonRoot EStrictParallel"
definition R2NonRootStepsEq where
"R2NonRootStepsEq trss = R2GTT_Rel (GSteps trss) PNonRoot EParallel"
definition R2Meet where
"R2Meet trss = R2GTT_Rel (GComp (GInv (GSteps trss)) (GSteps trss)) PAny EParallel"
definition R2Join where
"R2Join trss = R2GTT_Rel (GComp (GSteps trss) (GInv (GSteps trss))) PAny EParallel"
subsection ‹Formulas›
datatype 'trs formula
= FRR1 "'trs rr1_rel" fvar
| FRR2 "'trs rr2_rel" fvar fvar
| FAnd "('trs formula) list"
| FOr "('trs formula) list"
| FNot "'trs formula"
| FExists "'trs formula"
| FForall "'trs formula"
definition FTrue where
"FTrue ≡ FAnd []"
definition FFalse where
"FFalse ≡ FOr []"
definition FRestrict where
"FRestrict f trss ≡ map_formula (map_ftrs (λn. if n ≥ length trss then 0 else trss ! n)) f"
subsection ‹Signatures and Problems›
datatype ('f, 'v, 't) many_sorted_sig
= Many_Sorted_Sig (ms_functions: "('f × 't list × 't) list") (ms_variables: "('v × 't) list")
datatype ('f, 'v, 't) problem
= Problem (p_signature: "('f, 'v, 't) many_sorted_sig")
(p_trss: "('f, 'v) trs list")
(p_formula: "ftrs formula")
subsection ‹Proofs›
datatype equivalence
= EDistribAndOr
| EDistribOrAnd
datatype 'trs inference
= IRR1 "'trs rr1_rel" fvar
| IRR2 "'trs rr2_rel" fvar fvar
| IAnd "nat list"
| IOr "nat list"
| INot nat
| IExists nat
| IRename nat "fvar list"
| INNFPlus nat
| IRepl equivalence "nat list" nat
datatype claim = Empty | Nonempty
datatype info = Size nat nat nat
datatype 'trs certificate
= Certificate "(nat × 'trs inference × 'trs formula × info list) list" claim nat
subsection ‹Example›
text ‹Certify truth of $\forall t.\: \exists u.\: t \to u$.›
definition no_normal_forms_cert :: "ftrs certificate" where
"no_normal_forms_cert = Certificate
[ (0, (IRR2 (R2Step [Fwd 0]) 1 0),
(FRR2 (R2Step [Fwd 0]) 1 0), []) ― ‹0: ... ↝ 1→0›
, (1, (IExists 0),
(FExists (FRR2 (R2Step [Fwd 0]) 1 0)), []) ― ‹1: ... ↝ ∃1→0›
, (2, (INot 1),
(FNot (FExists (FRR2 (R2Step [Fwd 0]) 1 0))), []) ― ‹2: ... ↝ ¬∃1→0›
, (3, (IExists 2),
(FExists (FNot (FExists (FRR2 (R2Step [Fwd 0]) 1 0)))), []) ― ‹3: ... ↝ ∃¬∃1→0›
, (4, (INot 3),
(FNot (FExists (FNot (FExists (FRR2 (R2Step [Fwd 0]) 1 0))))), []) ― ‹4: ... ↝ ¬∃¬∃1→0›
, (5, (INNFPlus 4),
(FForall (FExists (FRR2 (R2Step [Fwd 0]) 1 0))), []) ― ‹5: ... ↝ ∀∃1→0›
] Nonempty 5"
definition no_normal_forms_problem :: "(string, string, unit) problem" where
"no_normal_forms_problem = Problem
(Many_Sorted_Sig [(''f'',[()],()), (''a'',[],())] [(''x'',())])
[{(Fun ''f'' [Var ''x''],Fun ''a'' [])}] ― ‹f(x) -> a›
(FForall (FExists (FRR2 (R2Step [Fwd 0]) 1 0))) ― ‹∀∃1→0›"
end