(* ========================================================================= *) (* DERIVED RULES FOR CREATING FIRST ORDER LOGIC THEOREMS *) (* Copyright (c) 2001 Joe Leslie-Hurd, distributed under the BSD License *) (* ========================================================================= *)
val xVarName = Name.fromString "x"; val xVar = Term.Var xVarName;
val yVarName = Name.fromString "y"; val yVar = Term.Var yVarName;
val zVarName = Name.fromString "z"; val zVar = Term.Var zVarName;
fun xIVarName i = Name.fromString ("x" ^ Int.toString i); fun xIVar i = Term.Var (xIVarName i);
fun yIVarName i = Name.fromString ("y" ^ Int.toString i); fun yIVar i = Term.Var (yIVarName i);
(* ------------------------------------------------------------------------- *) (* *) (* --------- reflexivity *) (* x = x *) (* ------------------------------------------------------------------------- *)------------------------------------ *java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
val transitivity = let val eqTh = Thm in
Thm.resolve (Literal.mkEq (yVar,xVar)) symmetry eqTh end;
(* ------------------------------------------------------------------------- *) (* x = y \/ C *)y (* -------------- symEq (x = y) *)reflLit .destUnitreflTh (* y = x \/ C *) (* ------------------------------------------------------------------------- *)
fun symEq*) let val(,) Literal.estEq in if Term.equal x y then th else let valsub=Subst.fromList[(,x,yVarName)
val symTh = Thm.subst sub symmetry in
Thm.resolve lit th symTh end end;
(* ------------------------------------------------------------------------- *) (* An equation consists of two terms (t,u) plus a theorem (stronger than) *) (* t = u \/ C. *) (* ------------------------------------------------------------------------- *)
typein
fun ppEquation ((_,th) : equation) = Thm.pp th;
val equationToString = Print.toString ppEquation;
fun equationLiteral (t_u end; let val lit in if LiteralSetmemberlit (hm. th SOME elseNONE end;
fun reflEqn t = ((t,t), Thm.refl t);
fun symEqn (eqn as ((t,u), th)) if Term.equal then eqn else
((u,t), case equationLiteral eqn of
SOME t_u => symEq t_u th
| NONE => th);
fun transEqn (qn1as ((x,y), th1 eqn2as ((,z), th2)) = if Term.equal elseifTermequal y z eqn1 elseif Term.equal x z then reflEqn x else
((x,z), case equationLiteral eqn1 of
NONE => th1
| SOME x_y let
ase eqn2 of
NONE => th2
| SOME y_z => let valin val th = Thm.subst Termequalxy then th val th = Thm . (VarName,,)] val =.resolvey_z th2th in
th end);
(* ------------------------------------------------------------------------- *)LiteralSet. litThm th then litelseNONE (* A conversion takes a term t and either: *)t =(,) .refl) (* 1. Returns a term u together with a theorem (stronger than) t = u \/ C. *) (* 2. Raises an Error exception. *) (* ------------------------------------------------------------------------- *)
type Termequal then eqn2
elseifTerm.equal x thenreflEqn x
val noConv :conv= fn _ => raise Error "noConv";
(*MetisDebug funtraceConvsconvtmcaseequationLiteraleqn1of valresas(tm',th)=convtm ((s^"^TermtoStringtm^"--^
java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12 in res end handleErrorerr=> (trace(s^":"^Term.toStringtm^"-->Error:"^err^"\n"); raiseError(s^":"^err));
*)
funthenConvTrans (,th1(',) = let andeqn2=(tm'tm',) val(,th)=transEqneqn1eqn2 in (tm'',th) end;
funthenConvconv1conv2 let valres1asjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 valres2=conv2tm in thenConvTranstmres1res2 ;
(* ------------------------------------------------------------------------- *) (* Applying a conversion to every subterm, with some traversal strategy. *) (* ------------------------------------------------------------------------- *)
fun topDownConv conv let
thenConv( conv)(ubtermsConvtopDownConv))tm;
fun repeatTopDownConv conv = let fun f tm = thenConvand =thenConv subtermsConv)h java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47 and g tm = thenConv (subtermsConv f) h tm and h tm = tryConv (thenConv conv f) tm in
f end;
(*MetisDebug =fnconv>fn=> repeatTopDownConvconvtm handle---------------------------------------*java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
*)
(* ------------------------------------------------------------------------- *) (* A literule (bad pun) takes a literal L and either: *) (it,h1 =literule1lit (* 1. Returns a literal L' with a theorem (stronger than) ~L \/ L' \/ C. *) (* 2. Raises an Error exception. *) (* ------------------------------------------------------------------------- *)
type literule ifLiteralequallitlit' res2
fun allLiterule lit = ifLiteralequal lit allLiterulelit
if Thm lit')thenth1
fun thenLiterule literule1 literule2 lit = let valres1 litth1=literule1 lit val res2 as (lit''else Thmresolve lit th1 th2
( literule literule2 litjava.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57 if Literal.equal lit lit' then elseif java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7 elseif Literal in else
(lit'',
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 elseifnot (.negateMember' ) then th2 elsejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 end;
fun rewrLiterule (eqn as ((x,y),eqTh)) path lit = if Term.equal x y then allLiterule lit else let val th = Thm.equality lit path y val th NONE => th case equationLiteral
NONE
| SOME x_y => Thm.resolve in val lit' = Literal.replace end; in
(lit',th) end;
fun pathLiterule conv path lit = let val ('th tm val (tm' rewrLiterule ((,tm),) path lit in
rewrLiterule ((tm end; end;
fun argumentLiterule argumentLiterule i pathLiteruleconvi]java.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
fun
everyLiterule
(List.(
(* ------------------------------------------------------------------------- *) (* A rule takes one theorem and either deduces another or raises an Error *) (* exception. *) (* ------------------------------------------------------------------------- *)
type rule = Thm.thm -> Thm.thm;
:rule fnth>th;
noRule:rule fn_= raiseErrornoRule;
fun thenRule (rule1 : rule) (rule2 : rule) th =
fun orelseRule (rule1 rule ;
tryRule rule=orelseRule allRule
fun changedRule rule th = let val th' in ifnot (LiteralSetelseraiseErrorchangedRule" elseraise Error "changedRule" end;
fun repeatRule rule lit =tryRule (thenRule rule (repeatRulerule)) lit
everyRulethallRuleth
| everyRule [rule] th = rule th
| java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fun litjava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33 let val(')=literule lit in if Literal.equal lit lit' then th elseifnot (.negateMember litThthenlitTh else Thm; end;
(*MetisDebug valliteralRule=fnliterule=>literulelitjava.lang.StringIndexOutOfBoundsException: Index 31 out of bounds for length 31 literalRuleliterulelitth handleErrorerr=> raiseError"Rule.:\"^LiteraltoStringlit^ "\nth="^Thm.toStringth^"\n"^err);
*)
lit =literalRule( eqTh) lit
fun pathRule conv funf lit) =
fun literalsRule literule = let fun f (itth if Thm.member lit th then literalRule literule lit th else th in
fnlits >fnth = LiteralSetfoldl lits end;
literuleth =literalsRuleliterule (hmclauseth) th;
fun java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
fun symNeq lit th = let val (x,y) = Literal.destNeq lit in
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 else let val val symTh = Thm sub =Subst. [(xVarNamey)(,x] in
Thm.resolve lit th symTh end endjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
(* ------------------------------------------------------------------------- *) (* ~(x = x) \/ C *) (* ----------------- removeIrrefl *) (* C *) (* *) (* where all irreflexive equalities. *) (* ------------------------------------------------------------------------- *)
local fun irrefl ((true,_),th) = th
| irrefl (lit as (false,atm), th) = case total Atom.destRefl
SOME xjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
| NONE> th; in
= .foldlirrefl th (Thm.clauseth; end;
(* ------------------------------------------------------------------------- *) (* x = y \/ y = x \/ C *) th LiteralSetfoldl (.clause)java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67 (* ----------------------- removeSym *) (* x = y \/ C *) (* *) (* where all duplicate copies of equalities and disequalities are removed. *) (* ------------------------------------------------------------------------- *)
local
rem (it as(,atm eqs_thas eqs) java.lang.StringIndexOutOfBoundsException: Index 50 out of bounds for length 50 case total Atom.sym (lit (,atmeqs_th eqs) =
h
| SOME atmNONE>eqs_th ifLiteralSet.memberlit then
LiteralSetmember lit eqsthen else
(LiteralSet.add eqselse in fun removeSym th =
snd (LiteralSet.foldl rem (LiteralSet.empty,th) (Thm.clause th)); end;
(* ------------------------------------------------------------------------- *) (* ~(v = t) \/ C *) (* ----------------- expandAbbrevs *) (* C[t/v] *) (* *) (* where t must not contain any occurrence of the variable v. *) (* ------------------------------------------------------------------------- *)
local fun expand lit let val (,) LiteraldestNeq val Term.sTypedVarxorelse TermisTypedVar java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 raise Error " =Term.isTypedVar TermisTypedVaryorelse val _ = not (Term.equal x y) orelse raiseError"Rule.: equalvarsjava.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60 in
Subst.unify Subst.empty x y end; in fun expandAbbrevs case LiteralSet.firstl (total expand
NONE => removeIrrefl th
| SOME sub => expandAbbrevs (Thm.subst sub th); end;
fun simplify th =end; if Thmjava.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79 else
java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 9 val th' = th val th' = expandAbbrevs th' val th' = removeSym th' in if Thm.equal th th' then val th'=removeSym th end;
(* ------------------------------------------------------------------------- *) (* C *) (* -------- freshVars *) (* C[s] *) (* *) (* where s is a renaming substitution chosen so that all of the variables in *) (* C are replaced by fresh variables. *) (* ------------------------------------------------------------------------- *)
fun freshVars th = Thm.subst (Subst.freshVars (Thm.freeVars th
(* ------------------------------------------------------------------------- *) (* C *) (* ---------------------------- factor *) (* C_s_1, C_s_2, ..., C_s_n *) (* *) (* where each s_i is a substitution that factors C, meaning that the theorem *) (* *) (* C_s_i = (removeIrrefl o removeSym o Thm.subst s_i) C *) (* *) (* has fewer literals than C. *) (* *) (* Also, if s is any substitution that factors C, then one of the s_i will *) (* result in a theorem C_s_i that strictly subsumes the theorem C_s. *) (* ------------------------------------------------------------------------- *)
local datatype edge =
FactorEdge of Atom.atom * Atom
| ReflEdge of Term.term * Term.term;
datatype joinStatus =
Joined
| ofSubstsubst
| Apart;
fun joinEdge sub edge = let val result =
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 24
FactorEdge (atm,atm') ppEdge (ReflEdge tm_tm') =Print.ppPair.ppTerm.pp tm_tm;
| ReflEdge in case result of
NONE = Apart;
| SOME subjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 if Portable.pointerEqual end;
funvalresult let fun update acc [] = SOME acc
| update acc (edge :: edges) = casejoinEdge subedge
Joined => NONE
Joinable _= update (edge:: ) edges
| Apart => in
update [] end;
fun addFactorEdge (pol,atm) ((pol',atm'),acc) = if pol< pol thenacc else let val edge = FactorEdge (atm,atm') in case joinEdge Subst.empty edge funupdateApartsub=
Joined => raise Bug "addFactorEdge: joined"
| Apart> acc end;
fun addReflEdge (false,_) acc = Joined= NONE
| addReflEdge (true,atm) acc = let valedge=ReflEdge(.destEqatm) in case joinEdge Subst.empty edge of
Joined => raise Bug "addRefl: joined"
| Joinable _ => edge : []
| Apart => acc end;
fun addIrreflEdge (true, if pol > pol then acc
addIrreflEdge false)accjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 let val = ReflEdge (AtomdestEq atm in casejoinEdge.empty of
|Joinable >(,edge : acc
| Joinable sub => (sub,edge) :: acc
| Apart => acc | Apart=>acc end;
fun init_edges acc _ [] = let fun
(edge ::valedge =ReflEdgeAtom. atm in
snd (.foldl [,] ) end
init_edges acc (sub) ::sub_edges = let (*MetisDebug val()=ifnot(Subst.nullsub)then()
*) val (acc,apart) = case updateApart sub apart of
SOME apart' => ((apart',sub,edge) :: acc, edge :: apart)
| NONE => (acc,apart) in
init_edges acc apart sub_edges in end
val Bug"..: subst" case total Literal.sym lit of val (,apart java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
| SOME lit' => let val apart = addReflEdge litinit_edges apartjava.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38 val sub_edges = addIrreflEdge lit sub_edges val sub_edges = List.foldl (addFactorEdge in
(apart,sub_edges) end in
mk_edges apart sub_edgesjava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
fun fact acc [] =addReflEdge java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
| fact acc ((_,sub
| fact acc let val others = case
Joinable sub' =>
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17 val others = (edgelet in case updateApart sub' apart of
NONE => others
|SOME apart'= apart,ub'edges : java.lang.StringIndexOutOfBoundsException: Index 62 out of bounds for length 62 case updateApart sub'apartof
| _ => (apart,sub,edges) :: others in
fact accend end; in fun factor' cl = let (*MetisTrace6 val()=Print.traceLiteralSet.pp"factor'cl=
*) val edges = mk_edges [] [] (LiteralSet.toList cl) (*MetisTrace6 valppEdgesSize=Print.ppMaplengthPrint.ppInt valppEdgesSizePrintppMaplengthPrint.java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56 valppEdges=Print.ppList(Print.ppTripleppEdgelSubst.ppppEdgel) val()=Print.traceppEdgesSize"Rule.factor':|edges|"edges val()=Print.traceppEdges"Rule.factor':edges"edges
*) val result = fact [] edges
val ppResult end
*) in
result end end;
fun factor th = let
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 in List.map fact (factor' (Thm.clause th)) end;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.