1 / 21

Unit 2: Theories and Schemas

Unit 2: Theories and Schemas. Aims and Objectives. This lecture aims to: Recall some concepts in logic: logical theories and models. Define state-based specifications as logical theories. Define basic ingredients of state-based specifications:

hadar
Download Presentation

Unit 2: Theories and Schemas

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unit 2: Theories and Schemas Aims and Objectives • This lecture aims to: • Recall some concepts in logic: logical theories and models. • Define state-based specifications as logical theories. • Define basic ingredients of state-based specifications: • » the schema notation; » the notion of schema inclusion. Unit 2: Theories and Schemas

  2. logical operators:,  , , , ,  have a fixed meaning • extra-logical symbols: • Propositional letters • Constants • Function symbols • Predicate symbols don’t have a fixed meaning; Logical theories A logical theory is a set of formulae written in a given formal language. A formal language: • Constants are elements of a given domain (or sort) • e.g.Peteris an element of a domain (sort) X = people • Functions map element(s) to an element of the domain e.g.mother: people  people mother(Peter)=Anne • Predicates are relations over elements of the domaine.g.brother  people  people  brother(Peter,John) Unit 2: Theories and Schemas

  3. Theory Signature e.g., p, q, r pq  r x. y. (P(a,y)  Q(f(y),x)) a, f, P, Q Signature The signature of a given logical theory is the collection of extra-logical symbols used in the theory. Given a domain “X” and a logical theory, defining a signature means defining: • The constants, as elements of the domain: a:X • The “arity” of each function symbol:f: X  X,g: X  X  X • The “arity” of each predicate symbol:P  X  X,R  X Unit 2: Theories and Schemas

  4. Theories Signature definition //meaning: A is a even integer Domain X = Za : Z x. (a = 2*x) //meaning: The set of even integers Domain X = ZEven Z y. (Even(y)  x. (y = 2*x) //meaning: A set of even integers Domain X = ZEven Z y. (Even(y)  x. (y = 2*x) //meaning: //All theemployees of Doc are headed by Jeff; //Every first-year student has a tutor Domain X = peopleemployee_Doc peopleheaded  people  peoplestudent peoplefirst-year  people tutor  people  people x. (employee_Doc(x)  headed(x, Jeff)) x.((student(x) first_year(x))y.tutor(y,x)) Examples of theories and signatures Unit 2: Theories and Schemas

  5. Symbols in a Signature Structure Domain: X Domain of elements: [X] Constants: a Element: [a] [X] [f]: [X]… [X]  [X] Function Function: f(x1,…,xn) Relation [P]  [X]…  [X] Predicate: P(x1,…,xm) Model Given a logical theory and its signature, a model is a structure that makes all the formulae in the theory true. Structures and Models Structure Given a signature, a structure is a formal definition of the meaning of each symbol in the signature. Unit 2: Theories and Schemas

  6. Structure x. y. (P(a,y)  Q(f(y),x)) X = N, a = 2, f(x) = x2 P = {(x,y)| x  y} Q = {(x,y)| x divides y} xN.yN. (2  y  y2 divides x) false X = Z, a = 0, f(x) = x+1 P = {(x,y)| x = y} Q = {(x,y)| x2+y2 100} xZ.yZ.(0=y  (y+1)2+x2  100) true(x = 0) X = {Tom, Mark, Harry}, a = Tom f(Tom) = Mark, f(Mark) = f(Harry) = Harry P = {(Tom,Mark),(Tom,Harry),(Mark,Harry)} Q = {(x,y)| x = y} x{T,M,H}.y{T,M,H}. (P(T,y)  f(y)=x) true(x = Harry) Evaluation in First-order Logic Once we have a structure, we can say if formulae are true or false. Unit 2: Theories and Schemas

  7. Signatures, Theories, Structures, Models • A signature (or vocabularyor language) describes the extra-logical ingredients that need to be interpreted. • A theory comprises a signature and some logical formulae (axioms) constructed using the signature’s symbols. • Signatures are interpreted using structures (in which the ingredients are interpreted set-theoretically). • Theories are interpreted using models (structures in which the axioms are true). Unit 2: Theories and Schemas

  8. In a state-based specification: • Schemas specify state variables and constraints. Schema operations are used to define operations on states. In an class-based specification: • Schemas specify the system in terms of objects (or components) and schema operations define operations on these objects that together capture the full system behaviour. Schemas: Basic Idea Formal specifications can be seen as logical theories of which the system is the “real-world” model (domains are often collections of elements in the real world, not mathematical sets). We distinguish between state-based specifications and class-based specifications. Unit 2: Theories and Schemas

  9. Theory name [carrier name] Signature (in Z: declarations) Axioms (in Z: predicate) Schemas From a logic perspective, schemas can be seen as notation for theories. A schema has two parts: signatures and axioms. • Schema notation is adapted from Z. • Our logical view of schemas is different from that of Z • but their use in practice is very similar. Unit 2: Theories and Schemas

  10. Terminology • Vocabulary, signature, extra-logical symbols and (in Z) declaration all mean more or less the same. • So do assumptions, axioms and (in Z) predicate. • “Predicate” in Z is not the same as “predicate” in predicate logic. Unit 2: Theories and Schemas

  11. Prems [X] a: X f: X  X P, Q XX x:X. y:X. (P(a,y) Q(f(y),x)) Example: a logical theory as schema • A schema can be used to describe vocabulary and assumptions. • Consider the logical theory defined by: • x. y. (P(a,y) Q(f(y),x)) The domain The schema The signature The axioms • “Prems” is just a name we’ve invented for this schema • Given a schema, we can draw inferences from it • logical consequences of the axioms using the symbols in the signature. Unit 2: Theories and Schemas

  12. Prems [X] a: X f: X  X P, Q XX x:X. y:X. (P(a,y) Q(f(y),x))) Notation • “:” means “of type” • “”means functions - so f: X  X means f is a function with one argument • “” is used for predicates • “” means Cartesian product - so P  XX means P is a predicate with two arguments • The bound variables x and y don’t need declaring in the signature. Unit 2: Theories and Schemas

  13. SchemaS S: NN S(0) = 0 "x:N. S(x+1) = S(x)+x+1 Example of a schema • N is a special purpose set with its own operators, predicates and reasoning principles already defined. • No carrier needed! • Structure needs carrier to show range of values of variables - but that is already fixed for variables of type N. • No need to declare 0 or + in the signature. Unit 2: Theories and Schemas

  14. ScrubFn [X] • scrub: X  seqX seqX • "y:X. scrub(y,[ ]) = [ ] • "y,x:X. "xs: seqX. • (yx  scrub(y, x:xs) = [x] ++ scrub(y,xs)) • "x:X. "xs: seqX. scrub(x, x:xs) = scrub(x,xs) A list example • seqX is the type of finite sequences (lists) from X • “:” is sometimes “of type”, sometimes “cons” • you can tell which by the context • ++ and […] are ordinary list notation • “scrub” means “delete all instances of an element from the list”. Unit 2: Theories and Schemas

  15. ExtPrems Prems[X] x0, y0: X y. (P(a,y)  Q(f(y),x0))) P(a,y0) Schema inclusion (an example) Consider now the extended theory: { x. y. (P(a,y)  Q(f(y),x)), y. (P(a,y)  Q(f(y),x0 ))), P(a,y0)} Unit 2: Theories and Schemas

  16. ExtPrems Prems[X] x0, y0: X y. (P(a,y)  Q(f(y),x0)) P(a,y0) ExtPrems[X] a, x0, y0: X f: X  X P, Q  XX x. y. (P(a,y)  Q(f(y),x)) y. (P(a,y)  Q(f(y),x0)) P(a,y0) Schema inclusion (definition) Prems[X] written in ExtPrems is a schema inclusion It means everything in schemaPrems is also part of schema ExtPrems. ExtPrems with Prems as inclusion. ExtPrems written out in full. • Very useful shorthand • Shows hierarchy of schemas and sub-schemas Unit 2: Theories and Schemas

  17. [people, towns] • birthplace: people towns Example of schema (Many-sorted logic) Consider this: • Needs two carriers! • Structure = pair of sets with function between them. • “people” and “towns” are two sorts in a many-sorted signature. • One sort (ordinary predicate logic). • No sorts (propositional logic). Unit 2: Theories and Schemas

  18. Many-sorted Logic Signature A set of sorts or domains Sorts are like types in a programming language A set of constant symbols, each with its own sort A set of predicate symbols, each with a given arity P is of this arity: P  X1 …  Xn, where X1, ….,Xn may be different domains. A set of function symbols, each with a given arity f is a function of this arity: f: X1 …  XnYwhere X1, ….,Xn, and Y may be different domains Formulae can be meaningless simply because they are not “well-typed”. Unit 2: Theories and Schemas

  19. All IC students graduate with a first 1) 2) All employees have salary under 20000 pounds 3) Italians read only Topolino 4) All borrowed books are not in the library 5) Students can borrow only one book Examples of many-sorted formulae s:StudentIC. (grade(s)=first) e:Employees. (salary(e) < 20000). b:books, p:people. [(italian(p)read(p,b))  b=topolino] b:Lib_books. (borrowed(b)  status(b) = out_library). t:Time, s:Students, b,b1:Lib_books. (borrowing(s,b,t)  borrowing(s,b1,t) b=b1). Unit 2: Theories and Schemas

  20. [X] a:N etc. ….. [X,N,seq X] a:N etc. ….. Sorts and types • Sorts (logic) and types (programming) are roughly the same. • Can construct lots, e.g. N, seqX, FX, etc. • The only ones that go in square brackets at the top of the schema are the “primitive sorts”, which are not special purpose sets or sets constructed out of others. right wrong Unit 2: Theories and Schemas

  21. Summary • A schema is a way of describing a logical theory. • The description has • sorts (primitive sorts, constructed sorts like N, seqX) • constants, functions, predicates, propositions • axioms. • A schema inclusion is a shorthand notation for schemas. • A schema has models. • If the schema is a specification, then a model is the real-world system that satisfies the axioms of the schema. Unit 2: Theories and Schemas

More Related