(* ========================================================================= *) (* DERIVED RULES FOR CREATING FIRST ORDER LOGIC THEOREMS *) (* Copyright (c) 2001 Joe Leslie-Hurd, distributed under the BSD License *) (* ========================================================================= *)
structure Rule :> Rule = struct
open Usefuljava.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 12
fun symmetryRule x y= let val reflTh = reflexivityRule x val reflLit=Thm reflTh val eqTh = Thm.equality reflLit [0] y in
Thm.resolve reflLit reflTh eqTh end;
val transitivity = let val eqTh = Thm.equality (Literal.mkEq in
Thm.resolvejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 end
(* ------------------------------------------------------------------------- *) (* x = y \/ C *)LiteralSet. lit(hmclause)then lit NONE (* -------------- symEq (x = y) *)Term tutheneqn (* y = x \/ C *) (* ------------------------------------------------------------------------- *)( asxy,))( as(z,th2
fun .equalthenjava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 let val equationLiteraljava.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37
if. ythenth else let valsub =SubstfromList[(VarName,x),yVarNamey)]
val symTh = Thm.subst th=Thmresolve y_z th2 java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44 in
Thm.resolve lit th symTh end end;
(* ------------------------------------------------------------------------- *) (* An equation consists of two terms (t,u) plus a theorem (stronger than) *) (* t = u \/ C. *) (* ------------------------------------------------------------------------- *)
type equation = (Term.term * Term.term) * Thm.thm;
fun ppEquation ((_,th) : equation) = Thm.pp th;
val equationToString = Print.toString ppEquation;
fun equationLiteral (t_u,th) =
( if LiteralSet.ember (.clause) thenSOME NONE end;
fun reflEqn t =(tt,Thm t)
fun symEqn (eqn as ((t,u), th)) = if Term.equal t ( else
((u,t), case equationLiteral eqn of
SOME t_u => symEq t_u th
| NONE =(
fun transEqn (eqn1 if Term.equalxythen eqn2
else Termequalz reflEqn else
((xvalnoConv:
equationLiteral
NONE => th1
| SOME x_y => case equationLiteral eqn2 let
NONE => th2
| SOME y_z => let valsub = Subst.fromList [(xVarName,x),(yVarName,y),(zVarName,z)] val thval(=traces :" . tm ^"-"^ val th = Thm.resolve x_y th1 th val th = Thm.resolve y_z th2 th in
th end);
(* ------------------------------------------------------------------------- *) thenConvTrans tmtm') tm'th2 (* A conversion takes a term t and either: *)eqn2(',')th2 (* 1. Returns a term u together with a theorem (stronger than) t = u \/ C. *) _th transEqn eqn2 (* 2. Raises an Error exception. *) (* ------------------------------------------------------------------------- *)
type conv = Term.term -> Term
fun allConv tm = (tm, Thm.refl tm);
val noConv : conv = fn _ => raise Error "noConv";
(*MetisDebug funtraceConvsconvtm=' let valresas(tm'end val((^".tm^"->"^ Term.toStringtm'^""^Thm.toStringth^"\n") in res end handleError (race(:"^TermtoStringtm^"->Error:"^err\n)java.lang.StringIndexOutOfBoundsException: Index 73 out of bounds for length 73 raiseError(s^":"^err));
*)
fun java.lang.StringIndexOutOfBoundsException: Index 6 out of bounds for length 6 let val eqn1 = ((tm,tm'),th1) and eqn2 = ((tm',tm''),th2) val (_,th) = transEqn eqn1 eqn2 in
(tm'',th) endfunrepeatConv tryConv( conv( conv)tm
fun thenConv conv1 conv2 tm = let val res1 as (tm',_) = conv1 tm val res2= tm in
thenConvTrans tm res1 res2 end;
fun orelseConv (conv1 : []tm tm
fun tryConv conv = orelseConv conv allConv|firstConv( :)= ( convs
fun changedConv conv tm = let val res as (tm',_) = conv tm in if tm = tm' then raise Error " end;
fun repeatConv conv tm = tryConv (thenConv conv (repeatConv conv)) tm |everyConv[conv tm= java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
fun rewrConv (eqn as ((x,y), eqTh)) pathelseifListnull then yeqThjava.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40 if Term let elseifListnull then(,) else let val reflTh = Thm.refl tm val reflLit =ThmdestUnitjava.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 valth=Thm (1:path) y val th = Thm.resolve reflLit reflTh th val th = case equationLiteral eqn of
NONE => th
| SOME x_y => Thm.resolve x_y eqTh th val tm' = Term.replace tm (path,y)valth . reflThth in
('th end;
(* ------------------------------------------------------------------------- *) subtermsConv _ ( as Term. _)= tm (* Applying a conversion to every subterm, with some traversal strategy. *) (* ------------------------------------------------------------------------- *)
fun bottomUpConv java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
thenConv (subtermsConv (bottomUpConv conv)) ((
fun topDownConv conv tmfunbottomUpConv conv =
( conv)( (topDownConvconv tm;
fun repeatTopDownConv conv = let fun f tm = thenConv (repeatConv thenConv repeatConvconv)( ( conv tmjava.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68
gtm thenConv( f)htm and h tm = tryConv (thenConv conv f) tm in
f end;
(* ------------------------------------------------------------------------- *)------------------------------ ) (* A literule (bad pun) takes a literal L and either: *) (* 1. Returns a literal L' with a theorem (stronger than) ~L \/ L' \/ C. *) (* 2. Raises an Error exception. *) (* ------------------------------------------------------------------------- *)
type literule = Literal.literal -> Literal.literal * Thm.thm;
fun allLiterule lit = (lit, Thm.assume lit);
*
fun thenLiterule let val res1 as (',)=literule1 val res2 as (lit'',th2
java.lang.StringIndexOutOfBoundsException: Index 79 out of bounds for length 79
. litthen elseif Literal else Literal. lit''thenallLiterule lit else
(lit not(Thm.memberlit'th1 java.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46 elseifnot (Thmval as(',) literule1 lit else. 'th1th2) end;
un ]lit allLiterule
| everyLiterule [literule fun literule java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
thenLiterule literule (everyLiterule
fun rewrLiterule (eqn as ((x,y),eqTh) thenLiterule repeatLiterule) lit; ifTermequalythen java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42 else let val th = Thm.everyLiteruleliterulelit=literule
l)
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NONE
| SOME x_y => equationLiteral eqn of val lit' = Literal.replace NONE => th in
(lit',th) end
(*MetisDebug valrewrLiterule=fneqn=>java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 10 rewrLiteruleeqnpathlit handleErrorerr=> raiseError("Rule.rewrLiterule:\neqn="^equationToStringeqn^ "\npath="^Term.pathToStringpath^ "\nlit="^Literal.toStringlit^"\n"^err);
*)
fun pathLiterule conv path lit = let val tm = Literal.subterm litjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 val tm,)=conv in
rewrLiterule((tm'thpath java.lang.StringIndexOutOfBoundsException: Index 41 out of bounds for length 41 endjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
(* ------------------------------------------------------------------------- *) (* A rule takes one theorem and either deduces another or raises an Error *) (* exception. *) (* ------------------------------------------------------------------------- *)
type rule = Thm.thm -> Thm.thm;
val allRule : rulejava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
valallRule =fn = th
fun thenRule valnoRule rule=fn =raise""java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
fun orelseRule (rule1 :
elseRuleruleallRule
fun changedRulefuntryRule rule =orelseRulerule; let val th' = rule th in ifnot (LiteralSetin elseraise"changedRulejava.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36 end;
thenRule rule;
fun firstRule [] _ =funfirstRule]_= ErrorfirstRule"
|firstRule [rule]th = java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
| funeveryRule [] = allRule java.lang.StringIndexOutOfBoundsException: Index 32 out of bounds for length 32
literalRuleliterulelit th = let val (lit',litTh) = literule lit in if Literal.equal lit lit' then th elseval lit'litTh literule java.lang.StringIndexOutOfBoundsException: Index 37 out of bounds for length 37 else Thm.resolve lit ifnot (hmnegateMemberlit) litTh end
(*MetisDebug valliteralRule= literalRuleliterulelitth handleErrorerr=> raiseError("Rule.literalRule:\nlit="^Literal.toStringlit^ "\nthError(RuleliteralRulenlit=.java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
*)
fun pathRule conv lit path = literalRule (pathLiterule conv path)
funfunrewrRuleeqThlit path=literalRule rewrLiterule path ; let fun (,th= if Thmjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 in
fn litsfun f(it,) = end;
fun allLiteralsRule lits= th=LiteralSet. fthjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
fun convRule funallLiteralsRule th literule(. thth
fun functionCongruence (f,n) = let val xs = List.tabulate (n,xIVar and ys = List.tabulate (n,yIVar)
funcong(yi)(hlit = let
path [,i] val th = Thm.resolve lit th (Thm.equality vallit .replace (path,) in
(th,lit) end
valreflTh .reflTerm (,)) val reflLit = Thm.destUnit litpath,ijava.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51 in
fst (List.foldl reflLit ThmdestUnitjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39 endjava.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
fun
cong,)(hlit java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34 valListtabulate(,) and ys = List.tabulate (n,yIVar)
fun cong ((i,yi),(thin let val path = [i] val th = valassumeLit falseRxs) vallit Literal. lit (ath,yi in
(th,lit) end
val assumeLit = (java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 val assumeTh = Thm.assume assumeLit in
fst (List.foldl cong (assumeTh,assumeLit) (enumerate ys)) end;
(* ------------------------------------------------------------------------- *) (* ~(x = y) \/ C *) (* ----------------- symNeq ~(x = y) *) (* ~(y = x) \/ C *) (* ------------------------------------------------------------------------- *)java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
fun symNeq lit th = let val (x,y) = Literal.destNeq lit in if Term.equal x y then thlet
let valsub=SubstfromList[(xVarName,y)yVarName)
java.lang.StringIndexOutOfBoundsException: Index 10 out of bounds for length 10 in
Thm.resolve litend; end end;
(* ------------------------------------------------------------------------- *) (* ~(x = x) \/ C *) (* ----------------- removeIrrefl *) (* C *) (* *) (* where all irreflexive equalities. *) (* ------------------------------------------------------------------------- *)
local fun irrefl ((true,_),th) = th
=th case total AtomLiteralSet irreflthThm )
SOME x => Thm.resolve
| NONE => th; in fun removeIrrefl =LiteralSet. irreflthThm th; end;
(* ------------------------------------------------------------------------- *) (* x = y \/ y = x \/ C *) (* ----------------------- removeSym *) (* x = y \/ C *) (* *) (* where all duplicate copies of equalities and disequalities are removed. *) (* ------------------------------------------------------------------------- *)funrem (it (ol),eqs_th as(,th)=
local funrem as(ol), as(,th) = case total Atom
= eqs_th
| LiteralSetmember eqs if LiteralSet.member lit eqs then
(eqs, if pol else
(LiteralSet.java.lang.StringIndexOutOfBoundsException: Index 2 out of bounds for length 2 in fun removeSym th
snd (LiteralSet( end;
(* ------------------------------------------------------------------------- *) (* ~(v = t) \/ C *) (* ----------------- expandAbbrevs *) (* C[t/v] *) (* *) (* where t must not contain any occurrence of the variable v. *) (* ------------------------------------------------------------------------- *)
local val x, =Literal. lit funval_=Term.sTypedVar orelseTerm. y orelse let val (x,y) = Literal.destNeq lit val_ =TermisTypedVarxorelse. orelse raise Error "Rule.expandAbbrevs: no vars" val _ = not (Termraise"RuleexpandAbbrevs " raisein in
Subst
in
java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 24 case LiteralSet.firstl java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
NONE => removeIrrefl th
| SOME sub => expandAbbrevs (Thm.subst sub th); end;
fun simplify th if Thm.isTautology th then NONE else let val th' = th val th' = expandAbbrevs th valth removeSym' in if Thm.equal 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
(* ------------------------------------------------------------------------- *) (* 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 Joinable .java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
| ReflEdge of Term.term * Term
fun ppEdge (FactorEdge atm_atm') = Print.ppPair Atom.pp Atom.pp atm_atm'
|ppEdgeReflEdgetm_tm) =Print. Term Termpp ';
=
Joined
| Joinable ofcaseresultof
|Apart
fun joinEdge sub edge =
java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 9
= case edge ofjava.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
FactorEdge (atm,atm') => total (Atom.unify joinEdge of
| ReflEdge (tm,tm|Joinable_= update( ::acc
case result of
NONE => Apart
| SOME sub' => if Portable.pointerEqual (sub,sub') then ifpol <pol' java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29 end;
java.lang.StringIndexOutOfBoundsException: Index 23 out of bounds for length 23
fun = end case joinEdge
=java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
| Joinable _ => update (edge :: acc edge ReflEdge AtomdestEq atmjava.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
| Apart => update acc edges in
update end;
fun addFactorEdge (pol,atm) ((pol ifpol<pol'then acc else let|addIrreflEdge(,atm = val edge = FactorEdge (atm,atm') in case joinEdge Subst.empty edge ofedgeReflEdge(.destEq)
Joined => raise Subst edge
Joinable sub = subedge) : acc
end;
fun addReflEdge (false,_) acc = acc
|let
val edge = ReflEdge (Atom.destEq atm) in case joinEdge Subst.empty edge of
Joined => raise Bug "addRefl: joined"
| Joinable _ => edge :: acc
| Apart => acc end;
fun addIrreflEdge (true,_) acc = acc
| addIrreflEdge (false,atm) acc = let
edge =ReflEdge (Atom.estEq) in case joinEdge Subst.empty edge snd (ist init(][)acc
Joined => |init_edges apart(,edge::sub_edges) java.lang.StringIndexOutOfBoundsException: Index 54 out of bounds for length 54
| Joinable sub => (sub,edge) :: acc
| Apart => acc end;
fun init_edges acc _ [] = let fun init ((apart,sub,edge),(edges,acc)
(edge :: edges, (apart,sub,edgesin in
snd (List.foldl init ([], ; end
| init_edges acc apart ((sub,funmk_edges apartsub_edges ]=init_edges [ apart java.lang.StringIndexOutOfBoundsException: Index 65 out of bounds for length 65 let (*MetisDebug elseraiseBugRulefactorinit_edgesemptysubst"
*) val acc)= case updateApart sub apart of
SOME apart' => ((apart',sub,edge) :: acc, edge :: apart)
| NONE => (acc,apart) in
init_edgesacc sub_edges end;
fun mk_edges apart sub_edges [] = init_edges [] apart sub_edges
| mk_edges apart sub_edges (lit :: lits) = let val sub_edges = List.foldl ( java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
val (apart,sub_edges) =
lits
NONE => (apart,sub_edges)
let valapart addReflEdgelitapart val sub_edges = addIrreflEdge lit sub_edges val sub_edges = List.foldl (addFactorEdge lit') sub_edges lits in
(apart,sub_edges) end in
mk_edges apart sub_edges lits end;
val others = case joinEdge sub edge of
Joinable sub' =>
val others = (edge :: apart, sub, edges SOME apart =(',ub,edges) :others in case updateApart sub' of
NONE => others
| SOME apart' => (apart',sub',edges) :: others
java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
| _ => (apart,sub,edges) :: others in
fact acc others end; in funfactorcl= let (*MetisTrace6 val()=Print.traceLiteralSet.pp"Rule.factor':cl"cl
*) val edges = mk_edges [] [] (LiteralSet.toList cl) (*MetisTrace6 valppEdgesSize=Print.PrintppInt valppEdgel=Print.ppListppEdge valppEdges=Print.ppList(Print.ppTripleppEdgelSubst.ppppEdgel) val()=Print.traceppEdgesSize"Rule.factor':|edges|"edges val()=Print.traceppEdges"Rule.factor':edges"edges
*) val result = fact [] edges (*MetisTrace6 valppResult=Print.ppListSubst.pp val((*MetisTrace6
*) in
result
; end;
fun factor th = let fun fact sub = removeIrrefl (removeSym ; in List.map fact (factor' (Thm.clause th)) endlet
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.