1 / 42

Semântica de Ações

This guide explains basic actions, functional notation, and their semantics. It covers basic action semantics, combinators, examples, and functional action semantics. Learn about commands in syntax, expressions, and operators for better understanding.

lmalone
Download Presentation

Semântica de Ações

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. Semântica de Ações Ações Básicas, Ações Funcionais e Notação de Dados

  2. Notação de Ações Básica • ações básicas são usadas para especificar fluxo de controle • ações básicas não estão relacionadas com nenhuma espécie de informação corrente • a execução de uma ação consiste de passos atômicos de execução, feitos por um ou mais agentes • consideraremos um único agente

  3. Ações Básicas • ações primitivas • complete : action . • escape : action . • fail : action . • diverge : action . • commit : action . • unfold : action .

  4. Ações Básicas (cont.) • combinadores de ações • unfolding _ :: action -> action . • _ or _ :: action, action -> action . • _ and _ :: action, action -> action . • _ and then _ :: action, action -> action .

  5. Exemplos de Ações Básicas • complete • complete or fail • complete and then fail • unfolding (unfold or fail)

  6. Semântica da Notação de Ações • Regras de Inferência (Semântica Natural) • antecedente1 antecedente2 ... antecedenten consequente • Ações • t, b, s |- a > o, t’, b’, s’ • Produtores • t, b, s |- y > d

  7. t, b, s |- a1 > completed, t1, b1, s1t, b, s1 |- a2 > completed, t2, b2, s2 mergeable b1 b2 t, b, s|- a1and a2 > completed, t1 ^ t2, b1 + b2, s2 t, b, s |- a1 > o1, t1, b1, s1o1 <> completed t, b, s|- a1and a2 > o1, t1, b1, s1 t, b, s |- a1 > completed, t1, b1, s1t, b, s1 |- a2 > o2, t2, b2, s2 o2 <> completed t, b, s|- a1and a2 > o2, t2, b2, s2 Semântica das Ações Básicas t, b, s |- complete > completed, (), {}, s (COMPLETE) t, b, s |- fail > failed, (), {}, s (FAIL) (AND-1) (AND-2) (AND-3)

  8. Comandos /NanoSpecimen/Abstract Syntax/Comandos grammar: (1) Comando = [[ Identificador := Expressão ]] | [[ while Expressão do Comando end ]] | [[ local Declaração in Comando end ]] | [[ Comando ; Comando ]] .

  9. /NanoSpecimen/Semantic Functions/Comandos • introduces: execute _ . • execute _ :: Comando -> action . • (1) ... • (2) execute [[ whileE:Expressão doC:Comando]] = • unfolding • | | evaluate E • | then • | | | check (it is 1) and then execute C and then unfold • | | or • | | | check not (it is 1) .

  10. (3) … (4) execute [[ C1:Comando ; C2:Comando]] = execute C1and then execute C2 .

  11. Notação de Ações Funcional • ações • give _ :: yielder -> action . • regive : action . • choose _ :: yielder -> action . • check _ :: yielder -> action . • _ then _ :: action, action -> action . • produtores • given _ :: data -> yielder . • given _ # _ :: datum, positive-integer -> yielder . • it : yielder .

  12. Exemplos de Ações Funcionais • give 5 • give sum(3,4) • choose a natural • (check true and then give 1) or (check not true and then give 0)

  13. t, b, s |- a1 > completed, t1, b1, s1t1, b, s1 |- a2 > completed, t2, b2, s2 t, b, s|- a1then a2 > completed, t2, b1 + b2, s2 t, b, s |- a1 > completed, t1, b1, s1t1, b, s1 |- a2 > o2, t2, b2, s2 o2 <> completed t, b, s|- a1then a2 > o2, t2, b2, s2 Semântica das Ações Funcionais t, b, s |- y > d (GIVE) t, b, s|- givey > completed, (d), {}, s (THEN-1) t, b, s |- a1 > o1, t1, b1, s1o1 <> completed (THEN-2) t, b, s|- a1then a2 > o1, t1, b1, s1 (THEN-3)

  14. /NanoSpecimen/Abstract Syntax/Expressões • grammar: • Expressão = Numeral-Inteiro • | Identificador • | [[ if Expressão then Expressão else Expressão ]] • | [[ Identificador ( Expressão ) ]] • | [[ Expressão Operador Expressão ]] • | [[ ( Expressão ) ]] . • Operador = + | - | * | / | = | < .

  15. /NanoSpecimen/Semantic Functions/Expressões • introduces: avalie _ . • avalie _ :: Expressão -> action . • (1) avalie N:Numeral-Inteiro = give the valor-de N . • (2) avalie I:Identificador = • | give the integer bound to token-de I • or • | give the integer stored in the cell bound to token-de I . • (3) avalie [[ I:Identificador ( E:Expressão ) ]] = • | avalie E • then • | enact (application of the abstraction bound to token-de I • to the given integer) .

  16. (4) avalie [[ifE1:Expressão thenE2:Expressão elseE3:Expressão ]] = | avalie E1 then | | (check it is true) and then avalie E2 | or | | (check not(it is true) and then avalie E3 . (5) avalie [[ E1:Expressão O:Operador E2:Expressão ]] = | avalie E1and avalie E2 then | apliqueOperador O . (6) avalie [[ (E:Expressão ) ]] = avalie E .

  17. /NanoSpecimen/Semantic Functions/Operadores • introduces:aplicaOperador _ . • aplicaOperador _ :: Operador -> action . • (1) aplicaOperador “+” = • give sum(the given integer#1, the given integer#2) . • (2) aplicaOperador “-” = • give difference(the given integer#1, the given integer#2) . • (3) aplicaOperador “*” = • give product(the given integer#1, the given integer#2) . • (4) aplicaOperador “/” = • give quotient(the given integer#1, the given integer#2) .

  18. (5) aplicaOperador “=“ = | check (the given integer#1 is the given integer#2) | and then give 1 or | check not(the given integer#1 is the given integer#2) | and then give 0 . (6) aplicaOperador “<“ = | check (the given integer#1 is less than the given integer#2) | and then give 1 or | check not(the given integer#1 is less than the given integer#2) | and then give 0 .

  19. Notação de Dados

  20. Notação de Dados General. Instant. Tuples. Truth-Values. Numbers. Characters. Lists. Strings. Syntax. Sets. Maps.

  21. Tuplas Generics component =  . Basics tuple > component. () : tuple. ( _ , _ ) :: tuple, tuple tuple (total, associative, unit is ()). _? :: tuple -> tuple . _ * :: tuple -> tuple . _ + :: tuple -> tuple . _ - :: tuple, natural -> tuple .

  22. Tuplas (cont.) Specifics • count _ :: tuple -> natural (total). • _ is _ :: tuple, tuple -> truth-value (partial).

  23. Booleanos (Truth-Values) Basics • truth-value = true | false (individual). Specifics • if _ then _ else_ :: truth-value, x, y -> x | y (linear) . • when _ then _ :: truth-value, x - > x (partial) . • there is _ :: x -> truth-value (total) . • not _ :: truth-value -> truth-value (total) . • both _ :: (truth-value,truth-value) -> truth-value . • either _ :: (truth-value,truth-value) -> truth-value .

  24. Números Naturais • Basics • natural = 0 | positive-integer (disjoint). • 0 : natural. • successor _ :: natural -> positive-integer (total, injective). • Specifics • 1, 2, 3, 4, 5, 6, 7, 8, 9 : natural. • _0, _1, _2, _3, _4, _5, _6, _7, _8, _9 : natural-> natural (total). • sum _ :: natural* -> natural • (total, associative, commutative, unit is 0). • product _ :: natural* -> natural • (total, associative, commutative, unit is 1).

  25. Números Inteiros Basics • integer = 0 | nonzero-integer (disjoint). • nonzero-integer = positive-integer | negative-integer (disjoint). • successor _ :: integer -> integer (total, injective). • predecessor _ :: integer -> integer (total, injective). Specifics • negation _ :: integer -> integer (total). • absolute _ :: integer -> integer (total). • difference _ :: (integer, integer) -> integer (total).

  26. Caracteres Basics • character = o . • character of _ :: natural -> character (partial, injective) . • code _ :: character -> natural (total, injective) . Alphanumerics • character >= digit | letter (disjoint) . • digit = ‘0’ | ‘1’ | ... | ‘9’ (individual) . • letter = lowercase letter | uppercase letter (disjoint) . • lowercase _ :: character -> character (total). • uppercase _ :: character -> character (total).

  27. Caracteres (cont.) ASCII • code _ :: character -> natural [max octal “177”] (total) . • character = graphic-character | control-character .

  28. Listas Não-aninhadas • Generics • item = o. • Basics • flat-list = list of item*. • list of _ :: item* -> flat-list (total, injective). • Specifics • _ [_] :: flat-list, item -> flat-list. • items _ :: flat-list -> items* (total, injective). • head _ :: flat-list -> item (partial). • tail _ :: flat-list -> flat-list (partial). • empty-list : flat-list. • concatenation _ :: flat-list* -> flat-list (total, associative, unit is empty-list).

  29. Listas Aninhadas • Generics • leaf = item | o . • Basics • list = list of tree* . • tree = leaf | list (disjoint) . • list of _ :: tree* -> list (total, injective) .

  30. Listas Aninhadas (cont.) • Specifics • _ [ _ ] :: list, tree -> list . • branches _ :: list -> tree* (total, injective) . • leaves _ :: • head _ :: • tail _ :: • empty-list : list . • concatenation _ :: list* -> list (total, associative, unit is empty-list) .

  31. Strings • Basics • character <= item. • string = flat-list [character]. • string of _ :: character* -> string (total, injective). • characters _ :: string -> character* (total, injective). • ““ : string. • _ ^ _ :: string, string -> string (total, associative, unit is ““). • Alphanumerics • lowercase _ :: string -> string (total). • uppercase _ :: string -> string (total). • decimal _ :: string of digit+ -> natural (total). • octal _ :: string of octal-digit+ -> natural (total). • octal-digit = ‘0’ | ‘1’ | ‘2’ | ‘3’ | ‘4’ | ‘5’ | ‘6’ | ‘7’.

  32. Sintaxe (Árvores Sintáticas) • Basics • syntax-tree = character | list [syntax-tree] (disjoint) . • Specifics • [[ ]] : syntax-tree. • [[ _ ]] :: syntax-tree* -> syntax-tree (total) . • [[ _ _ ]] :: syntax-tree*, syntax-tree* -> syntax-tree (total) . • ... • <> : syntax-tree* . • < _ > : syntax-tree* -> syntax-tree (total) . • < _ _ > : syntax-tree*, syntax-tree* -> syntax-tree (total) . • ...

  33. Conjuntos • Generics • nonset-element = o. • _ is _ :: nonset-element, nonset-element -> truth-value (total). • Basics • set = set of element*. • element = nonset-element | set (disjoint). • set of _ :: element* -> set (individual).

  34. Conjuntos (cont.) Specifics • _ [ _ ] :: set, element -> set. • elements _ :: set -> element* (strict, linear). • empty-set : set. • _ [in _ ] :: element, set -> element (partial). • _ [not in _] :: element, set -> element (partial).

  35. Mapeamentos • Generics • nonmap-range = o. • Basics • map = disjoint-union (map of element to range)*. • range = nonmap-range | map (disjoint). • map of _ to _ :: element, range -> map (total, injective). • empty-map : map. • disjoint-union _ :: map* -> map • (partial, associative, commutative, unit is empty-map) . • mapped-set _ :: map -> set (total) .

  36. Mapeamentos (cont.) Specifics • _ [ _ to _ ] :: set, element -> set . • _ at _ :: map, element -> range (partial) . • overlay _ :: map* -> map (total, associative, idempotent, unit is empty-map) . • _ restricted to _ :: map, set -> map (total) . • _ omitting _ :: map, set -> map (total) .

  37. Action Notation/Basic/Data includes: Data Notation/General . • datum <= component . • datum >= truth-value | rational | character | list | set | map | abstraction (disjoint) . • distinct-datum <= datum . • distinct-datum >= truth-value | rational | character | list [distinct-datum] | set [distinct-datum] | map [distinct-datum to distinct-datum] . includes: Data Notation/Instant/Distinction (distinct-datum for s). • data = datum* . • a _, an _, the _, of _, some _ :: data -> data (total) .

  38. Algumas Inclusões entre Sortes de Dados Padrões tuple range component map element nonmap-range truth-value tree set nonset-element rational leaf syntax-tree list approximation integer nonzero-rational item flat-list character natural positive-rational nonzero-integer negative-rational control-character graphic-character string positive-integer negative-integer 0 digit letter

  39. /NanoSpecimen/Abstract Syntax • needs: DataNotation/Characters/ASCII (letter, digit) • closed. • grammar: • Identificadores • Identificador = letter | Identificador letter | Identificador digit . • Literais • Numeral-Inteiro = digit | Numeral-Inteiro digit .

  40. /NanoSpecimen/Semantic Functions/Identificadores • introduces:token-de _ . • token-de _ :: Identificador -> token . • (1) token-de I:Identificador = I . • /NanoSpecimen/Semantic Functions/Literais • introduces:valor-de _ . • valor-de _ :: Numeral-Inteiro -> integer . • (1) valor-de [[ 0 ]] = 0 . • ... • (10) valor-de [[ 9 ]] = 9 . • (11) valor-de [[ N D ]] = sum (product (valor-de N, 10), valor-de D) .

  41. Resumo/Notação de Dados • A notação de tuplas inclui uma forma de expressões regulares. • Tuplas são usadas para prover operações com um número arbitrário de argumentos. • Vários sortes, como component, são deixados abertos para uma especialização quando necessária. • Caracteres podem ser especializados para qualquer conjunto de caracteres desejado, como ASCII, por exemplo.

  42. Resumo/Notação de Dados • Listas, conjuntos e mapeamentos podem ser aninhados, enquanto tuplas podem ser só concatenadas. • Árvores sintáticas têm unicamente caracteres como ramos. Strings são listas planas de caracteres, por isso também árvores sintáticas.

More Related