Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Generative Story Worlds as Linear Logic Programs

B6ff5f798c18a3367b2770aa3ada0730?s=47 Chris
June 27, 2014

Generative Story Worlds as Linear Logic Programs

Talk for the paper of the same title, available here: http://www.cs.cmu.edu/~cmartens/int7.pdf

Presented at (INT)7 (Intelligent Narrative Technologies) in Milwaukee on June 18, 2014.

B6ff5f798c18a3367b2770aa3ada0730?s=128

Chris

June 27, 2014
Tweet

More Decks by Chris

Other Decks in Programming

Transcript

  1. Generative Story Worlds as Linear Logic Programs Chris Martens, João

    Ferreira, Anne-Gwenn Bosser, and Marc Cavazza 1 Presented at Interactive Narrative Technologies June 18, 2014
  2. Generative Story Worlds as Linear Logic Programs Chris Martens, João

    Ferreira, Anne-Gwenn Bosser, and Marc Cavazza 2 Presented at Interactive Narrative Technologies June 18, 2014
  3. 3 new programming languages for digital narratives Praxis & Prompter:

  4. 4 OLD programming languages for digital narratives(?) LOGIC

  5. 5 old programming languages for digital narratives LINEAR LOGIC

  6. 6 used linear logic as a programming language (Celf) for

    specifying narrative worlds; used proof search to generate structured stories. What we did:
  7. THREE ACTS 7 I. Setup: agent simulation, linear logic, and

    logic programming II. Payoff: Stories as Proofs III. Promise and Limitations
  8. 8

  9. 9 greet insult compliment gossip flirt ... social verbs: social

    state: knowledge sentiment emotional state personality belief
  10. 10 verbs: rules causal relationships: resource dependencies

  11. RULES 11 Narrative Actions ~ Logical implication

  12. 12 the problem with standard logical implication: buy_soda : has(Alice,

    $1) ^ wants(Alice, soda) 㱺 has(Alice, soda)
  13. LINEAR LOGIC 13 A -o B

  14. 14 buy_soda : has(Alice, $1) * wants(Alice, soda) -o has(Alice,

    soda)
  15. 15 A * B A -o B !A

  16. 16 A * B A -o {B} !A

  17. Logic Programming 17 proof search as program execution

  18. 18 initial state Σ Δ0 Celf query (optional) A Δ0,

    …, Δ Δ ⊢ A? narrative actions
  19. Logic Programming 19 A -o {B} Δ, A → Δ,

    B Δ = arbitrary context of resources A1, …, An
  20. 20 Example in our paper: Shakespearean tragedy world

  21. 21 Shakespearean tragedy world state components: character location, possession, sentiment

    toward other characters, goals
  22. 22 Shakespearean tragedy world at <character> <location> has <character> <object>

    anger <character> <character> philia <character> <character> depressed <character>
  23. 23 Shakespearean tragedy world !dead <character> !killed <character> <character>

  24. 24 do/insult : at C L * at C’ L

    * anger C C’ -o {at C L * at C’ L * anger C C’ anger C’ C * depressed C’}.
  25. 25 do/compliment : at C L * at C’ L

    * philia C C’ -o {at C L * at C’ L * philia C C’ * philia C’ C}.
  26. 26 do/murder : anger C C’ * anger C C’

    * anger C C’ * anger C C’ * at C L * at C’ L * has C weapon -o {at C L * !dead C’ * !murdered C C’ * has C weapon}.
  27. 27 do/mourn : at C L * philia C C’

    * dead C’ -o {philia C C’ * at C L * depressed C * depressed C}.
  28. 28 do/becomeSuicidal : at C L * depressed C *

    depressed C * depressed C * depressed C -o {at C L * suicidal C * wants C weapon}.
  29. 29 do/loot : at C L * dead C' *

    has C' O * wants C O -o {at C L * has C O}.
  30. 30 do/comfort : at C L * at C' L

    * suicidal C' * philia C C' * philia C' C -o {at C L * at C' L * philia C C' * philia C' C * philia C' C}.
  31. 31 initial state

  32. 32 story_start : init -o { at romeo town *

    at montague mon_house * at capulet cap_house * at mercutio town * at nurse cap_house * at juliet town * at tybalt town * at apothecary town * has tybalt weapon * has romeo weapon * has apothecary weapon * ...
  33. 33 ... * anger montague capulet * anger capulet montague

    * anger tybalt romeo * anger capulet romeo * anger montague tybalt * philia mercutio romeo * philia romeo mercutio * philia montague romeo * philia capulet juliet * philia juliet nurse * philia nurse juliet * neutral nurse romeo * neutral mercutio juliet * neutral juliet mercutio * neutral apothecary nurse * neutral nurse apothecary}.
  34. 34 final state

  35. 35 ending_happy : nonfinal * actor C * actor C’

    * at C L * at C’ L * married C C’ -o {final}. ending_vengeance : nonfinal * actor C1 * actor C2 * actor C3 * killed C1 C2 * philia C3 C2 * killed C3 C1 -o {final}.
  36. 36 proofs as stories

  37. 37 query: init -o {final}

  38. Nondeterminism 38 A -o {B} Δ, B A -o {C}

    Δ, C Δ, A
  39. Nondeterminism 39 A -o {B} C -o {D}

  40. Nondeterminism 40 A -o {B} Δ, B, C C -o

    {D} Δ, A, D Δ, A, C
  41. Nondeterminism 41 A -o {B} Δ, B, C C -o

    {D} Δ, A, D Δ, A, C Δ, B, D
  42. 42 proof of init -o {final}: function (x:init) = let

    [xs] = r [ys] in …
  43. 43 ... let {[X73, [X74, [X75, [X76, X77]]]]} = do/insult/private

    [a-tybalt, [a-romeo, [X68, [X66, X72]]]] in let {[X85, [X86, X87]]} = do/becomeSuicidal [a-romeo, [X79, [X41, [X59, [X52, X77]]]]] in let {[X88, [X89, [X90, [X91, X92]]]]} = do/comfort [a-mercutio, [a-romeo, [X78, [X85, [X86, [X81, X83]]]]]] in let {[X101, [!X102, [!X103, X104]]]} = do/murder [a-romeo, [a-tybalt, [X58, [X40, [X76, [X51, [X94, [X96, X27]]]]]]]] in let {[X105, [X106, [X107, X108]]]} = do/compliment/private [a-nurse, [a-juliet, [X46, [X47, X30]]]] in let {[X109, [X110, [X111, X112]]]} = do/compliment/private [a-juliet, [a-nurse, [X106, [X105, X108]]]] in let {[X113, X114]} = do/loot [a-romeo, [a-tybalt, [X101, [X102, [X26, X87]]]]] in ...
  44. Concurrent Equality 44 r1: A -o B r2: C -o

    D “apply r1; apply r2” ~= “apply r2; apply r1” if A and C are disjoint
  45. 45 graphical representation of traces

  46. 46 init do/insult/private do/formOpinion/dislike do/compliment/witnessed do/travelTo do/compliment/private do/murder do/marry ending_1

    do/steal do/thinkVengefully do/mourn do/becomeSuicidal cleanup/1 do/eroticize do/suicide do/flirt/discrete
  47. 47 do/insult/private do/formOpinion/dislike do/compliment/witnessed do/travelTo private do/murder do/marry do/steal do/thinkVengefully

    do/mourn do/becomeSuicidal do/suicide ete
  48. 48 queries on sets of traces

  49. 49 > exists ending_1 > exists do/thinkVengefully && ̃link do/thinkVengefully

    do/murder
  50. generative exploration informative structure character perspective-agnosticism 50 what does this

    accomplish?
  51. 51 how do simulation designs fail their authors?

  52. 52 orphan verbs vs causally connected chains

  53. ACT III Potential & Limitations 53

  54. 54 combining reactive/exploratory + goal-driven behavior: A -o G vs

    A -o {B} (backward & forward chaining) Additional potential of LL
  55. 55 higher-order rules: (A -o B) -o C Additional potential

    of LL
  56. 56 higher-order rules: (A -o B) -o C “serendipity:” Forall

    L. at romeo L * at juliet L -o {eros romeo juliet * at romeo L * at juliet L}) Additional potential of LL
  57. 57 Additional potential of LL dynamic object generation: Exists x:A.

    ... makeRoom : has(C, magic door) * at C R -o {Exists r:room. !adjacent R r}
  58. 58 limitations

  59. 59 limitations (of the tool) (of the underlying formalism)

  60. 60 limitations of the tool: interactivity history tracking debugging facilities

    drama management
  61. 61 limitations of the formalism: ability to broadcast actions nondeterminism

    and control over probabilities
  62. 62 what I plan to address: interactivity debugging facilities ability

    to “broadcast” actions
  63. 63 PHASES

  64. Phases (Example) 64 deduplication phase act { … } quiesced

    act -o {phase dedup}. phase dedup { wants C O * wants C O -o {wants C O}. } quiesced dedup -o {phase act}.
  65. Phases phase p1 = {...} phase p2 = {...} quiesced

    p1 -o {some_token * phase p2}. quiesced p2 -o {phase p1}. Blocks connected by specification of quiescence behavior 65
  66. Phases (Example) interactivity phase world = { rule1 : do

    Action * … -o {…}. rule2 : do Action * … -o {…}. } phase player = { get_input : player_turn -o {read #STDIN}. } 66
  67. 67 also possible to implement: broadcast

  68. 68 also ongoing: phase invariants for each phase, constraints on

    the context… - as an invariant of the phase - at quiescence programmer-specified, machine-checked!
  69. FINALE 69

  70. 70 the point of formalism is to be able to

    run readable specifications
  71. 71 the point of formalism is to be able to

    reason about readable specifications
  72. 72

  73. 73

  74. 74 linear logic can be used as a programming language

    for specifying narrative worlds; to generate narratives & analyze their structure; potentially the basis for a richer PL. Takeaway
  75. FINALE 75 Celf: https://github.com/clf/celf Example from the paper: http://tinyurl.com/int2014-clf Me:

    Chris Martens @chrisamaphone cmartens@cs.cmu.edu Planning to graduate Summer 2015
  76. MINUS WORLD (bonus slides) 76

  77. Cut 77 Δ1 ⊢ A Δ 2, A ⊢ C

    Δ 1, Δ 2 ⊢ C
  78. Frame Property 78 If Δ1 ⊢ A then Δ1, Δ2

    ⊢ A * ⨂Δ2
  79. Frame Property (alt) 79 If Δ1 → Δ2 then Δ1,

    Δ’ → Δ2, Δ’
  80. Relationship between step and deductions 80 Δ1 → Δ2 iff

    for all C Δ2 ⊢ C implies Δ1 ⊢ C
  81. 81 LOGICS are formalisms with composable consequences

  82. 82 LOGICS are formalisms with composable consequences Δ ⊢ A

    Δ’, A ⊢ C Δ’, Δ ⊢ C
  83. Phases (Example) Broadcast phase act { do C A *

    in_room C R -o {broadcast C A R}. } quiesced act -o {phase broadcast}. phase broadcast { broadcast C A R * in_room C' R -o {notice C' C A * broadcast C A R}. } quiesced broadcast -o {phase notice}. 83
  84. Phases (Example) Broadcast 84 phase notice { broadcast C A

    R * notice C' C A -o {react C' C A * in_room C' R * broadcast C A R}. } quiesced notice * broadcast _ _ _ -o {phase react}. phase react { react C C' (murder ...) * philia C C' -o {...} } quiesced react -o {phase act}.
  85. Phases delimited subsignatures connected by specifications of quiescence behavior. 85

    quiesced P * State -o {phase P’ * State’}. arbitrarily many phases looping + branching