Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  Prolog.thy   Sprache: Isabelle

 

(*  Title:      FOL/ex/Prolog.thy
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    Copyright   1992  University of Cambridge
*)


section ‹First-Order Logic: PROLOG examples›

theory Prolog
imports FOL
begin

typedecl 'a list
instance list :: (‹term›) ‹term› ..

axiomatization
  Nil     :: ‹'a list› and
  Cons    :: ‹['a, 'a list]=> 'a list›    (infixr ‹:› 60) and
  app     :: ‹['a list, 'a list, 'a list] => o› and
  rev     :: ‹['a list, 'a list] => o›
where
  appNil:  ‹app(Nil,ys,ys)› and
  appCons: ‹app(xs,ys,zs) ==> app(x:xs, ys, x:zs)› and
  revNil:  ‹rev(Nil,Nil)› and
  revCons: ‹[| rev(xs,ys); app(ys, x:Nil, zs) |] ==> rev(x:xs, zs)›

schematic_goal ‹app(a:b:c:Nil, d:e:Nil, ?x)›
apply (rule appNil appCons)
apply (rule appNil appCons)
apply (rule appNil appCons)
apply (rule appNil appCons)
done

schematic_goal ‹app(?x, c:d:Nil, a:b:c:d:Nil)›
apply (rule appNil appCons)+
done

schematic_goal ‹app(?x, ?y, a:b:c:d:Nil)›
apply (rule appNil appCons)+
back
back
back
back
done

(*app([x1,...,xn], y, ?z) requires (n+1) inferences*)
(*rev([x1,...,xn], ?y) requires (n+1)(n+2)/2 inferences*)

lemmas rules = appNil appCons revNil revCons

schematic_goal ‹rev(a:b:c:d:Nil, ?x)›
apply (rule rules)+
done

schematic_goal ‹rev(a:b:c:d:e:f:g:h:i:j:k:l:m:n:Nil, ?w)›
apply (rule rules)+
done

schematic_goal ‹rev(?x, a:b:c:Nil)›
apply (rule rules)+  ― ‹does not solve it directly!›
back
back
done

(*backtracking version*)
ML ‹
  prolog_tac ctxt =
 DEPTH_FIRST Thm.no_prems (resolve_tac ctxt @{thms rules} 1)
 
›

schematic_goal ‹rev(?x, a:b:c:Nil)›
apply (tactic ‹prolog_tac context›)
done

schematic_goal ‹rev(a:?x:c:?y:Nil, d:?z:b:?u)›
apply (tactic ‹prolog_tac context›)
done

(*rev([a..p], ?w) requires 153 inferences *)
schematic_goal ‹rev(a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:Nil, ?w)›
apply (tactic ‹
 DEPTH_SOLVE (resolve_tac context ([@{thm refl}, @{thm conjI}] @ @{thms rules}) 1)
›)
done

(*?x has 16, ?y has 32;  rev(?y,?w) requires 561 (rather large) inferences
  total inferences = 2 + 1 + 17 + 561 = 581*)

schematic_goal ‹a:b:c:d:e:f:g:h:i:j:k:l:m:n:o:p:Nil = ?x ∧ app(?x,?x,?y) ∧ rev(?y,?w)›
apply (tactic ‹
 DEPTH_SOLVE (resolve_tac context ([@{thm refl}, @{thm conjI}] @ @{thms rules}) 1)
›)
done

end

Messung V0.5 in Prozent
C=59 H=100 G=81

¤ Dauer der Verarbeitung: 0.12 Sekunden  (vorverarbeitet am  2026-09-28) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1126864
#Domains=1897691