Exemples H-Logic v3.2
Statut documentaire : reference — voir Maturité et preuves.
Recette de tarte Tatin
Cet exemple montre une modélisation conceptuelle avec entités, relations polyadiques, étapes et flux de transformation.
namespace cuisine 'www.logicells.com/cuisine' default;
// -------------------------------------------------
// Types primitifs et concepts généraux
// -------------------------------------------------
define .:#string(me);
define .:#integer(me);
define .:#float(me);
define .:#NamedEntity(me)[name::#string];
define .:#Recipe(me)[name::#string];
define .:#Ingredient(me)[name::#string];
define .:#Dessert(me)[name::#string];
define .:#Preparation(me)[name::#string];
define .:#Unit(me)[symbol::#string];
define .:#Utensil(me)[name::#string];
define .:#StepLabel(me)[label::#string];
// -------------------------------------------------
// Spécialisations métier
// -------------------------------------------------
define .:#Fruit(me:#Ingredient);
define .:#DairyProduct(me:#Ingredient);
define .:#Pastry(me:#Ingredient);
// -------------------------------------------------
// Étapes et relations
// -------------------------------------------------
define .:#RecipeStep(me)[
order::#integer,
label:#StepLabel,
detail::#string
];
define .:#Uses(
recipe:#Recipe,
ingredient:#Ingredient
)[
quantity::#float,
unit:#Unit
];
define .:#Requires(recipe:#Recipe, utensil:#Utensil);
define .:#HasStep(recipe:#Recipe, step:#RecipeStep);
define .:#Before(firstStep:#RecipeStep, nextStep:#RecipeStep);
define .:#Consumes(step:#RecipeStep, input:#NamedEntity);
define .:#Produces(step:#RecipeStep, product:#NamedEntity);
define .:#Result(recipe:#Recipe, result:#Dessert);
// -------------------------------------------------
// Instances
// -------------------------------------------------
#tarte_tatin_recipe:#Recipe[name='Tarte Tatin'];
#tarte_tatin_dessert:#Dessert[name='Tarte Tatin'];
#apple:#Ingredient[name='Apple'];
#apple::#Fruit;
#sugar:#Ingredient[name='Sugar'];
#butter:#Ingredient[name='Butter'];
#butter::#DairyProduct;
#puff_pastry:#Ingredient[name='Puff Pastry'];
#puff_pastry::#Pastry;
#prepared_apples:#Preparation[name='Prepared Apples'];
#caramel:#Preparation[name='Caramel'];
#buttered_caramel:#Preparation[name='Buttered Caramel'];
#arranged_apples:#Preparation[name='Apples Arranged In Pan'];
#softened_apples:#Preparation[name='Softened Apples'];
#assembled_tart:#Preparation[name='Unbaked Tarte Tatin'];
#baked_tart:#Preparation[name='Baked Tarte Tatin'];
#rested_tart:#Preparation[name='Rested Tarte Tatin'];
#piece:#Unit[symbol='piece'];
#gram:#Unit[symbol='g'];
#sheet:#Unit[symbol='sheet'];
#oven:#Utensil[name='Oven'];
#pan:#Utensil[name='Pan'];
#knife:#Utensil[name='Knife'];
#peeler:#Utensil[name='Peeler'];
#spatula:#Utensil[name='Spatula'];
// -------------------------------------------------
// Composition de la recette
// -------------------------------------------------
use1:#Uses(#tarte_tatin_recipe, #apple)[quantity=8, unit=#piece];
use2:#Uses(#tarte_tatin_recipe, #sugar)[quantity=150, unit=#gram];
use3:#Uses(#tarte_tatin_recipe, #butter)[quantity=80, unit=#gram];
use4:#Uses(#tarte_tatin_recipe, #puff_pastry)[quantity=1, unit=#sheet];
req1:#Requires(#tarte_tatin_recipe, #oven);
req2:#Requires(#tarte_tatin_recipe, #pan);
req3:#Requires(#tarte_tatin_recipe, #knife);
req4:#Requires(#tarte_tatin_recipe, #peeler);
req5:#Requires(#tarte_tatin_recipe, #spatula);
// -------------------------------------------------
// Étapes
// -------------------------------------------------
#prepare_ingredients:#StepLabel[label='Prepare Ingredients'];
#preheat_oven:#StepLabel[label='Preheat Oven'];
#make_caramel:#StepLabel[label='Make Caramel'];
#add_butter:#StepLabel[label='Add Butter'];
#arrange_apples:#StepLabel[label='Arrange Apples'];
#cook_apples:#StepLabel[label='Cook Apples'];
#cover_with_pastry:#StepLabel[label='Cover With Pastry'];
#bake_tart:#StepLabel[label='Bake Tart'];
#rest_tart:#StepLabel[label='Rest Tart'];
#unmold_tart:#StepLabel[label='Unmold Tart'];
#step1:#RecipeStep[order=1, label=#prepare_ingredients, detail='Peel the apples and cut them'];
#step2:#RecipeStep[order=2, label=#preheat_oven, detail='Preheat the oven to 180 degrees Celsius'];
#step3:#RecipeStep[order=3, label=#make_caramel, detail='Melt sugar until caramel forms'];
#step4:#RecipeStep[order=4, label=#add_butter, detail='Add butter to the caramel'];
#step5:#RecipeStep[order=5, label=#arrange_apples, detail='Place apples in the caramel'];
#step6:#RecipeStep[order=6, label=#cook_apples, detail='Cook apples until softened'];
#step7:#RecipeStep[order=7, label=#cover_with_pastry, detail='Cover apples with puff pastry'];
#step8:#RecipeStep[order=8, label=#bake_tart, detail='Bake until golden'];
#step9:#RecipeStep[order=9, label=#rest_tart, detail='Let the tart rest'];
#step10:#RecipeStep[order=10, label=#unmold_tart, detail='Turn the tart upside down'];
// -------------------------------------------------
// Relations entre étapes
// -------------------------------------------------
hs1:#HasStep(#tarte_tatin_recipe, #step1);
hs2:#HasStep(#tarte_tatin_recipe, #step2);
hs3:#HasStep(#tarte_tatin_recipe, #step3);
hs4:#HasStep(#tarte_tatin_recipe, #step4);
hs5:#HasStep(#tarte_tatin_recipe, #step5);
hs6:#HasStep(#tarte_tatin_recipe, #step6);
hs7:#HasStep(#tarte_tatin_recipe, #step7);
hs8:#HasStep(#tarte_tatin_recipe, #step8);
hs9:#HasStep(#tarte_tatin_recipe, #step9);
hs10:#HasStep(#tarte_tatin_recipe, #step10);
b1:#Before(#step1, #step2);
b2:#Before(#step2, #step3);
b3:#Before(#step3, #step4);
b4:#Before(#step4, #step5);
b5:#Before(#step5, #step6);
b6:#Before(#step6, #step7);
b7:#Before(#step7, #step8);
b8:#Before(#step8, #step9);
b9:#Before(#step9, #step10);
// -------------------------------------------------
// Flux de transformation
// -------------------------------------------------
c1:#Consumes(#step1, #apple);
p1:#Produces(#step1, #prepared_apples);
c2:#Consumes(#step3, #sugar);
p2:#Produces(#step3, #caramel);
c3:#Consumes(#step4, #caramel);
c4:#Consumes(#step4, #butter);
p3:#Produces(#step4, #buttered_caramel);
c5:#Consumes(#step5, #prepared_apples);
c6:#Consumes(#step5, #buttered_caramel);
p4:#Produces(#step5, #arranged_apples);
c7:#Consumes(#step6, #arranged_apples);
p5:#Produces(#step6, #softened_apples);
c8:#Consumes(#step7, #softened_apples);
c9:#Consumes(#step7, #puff_pastry);
p6:#Produces(#step7, #assembled_tart);
c10:#Consumes(#step8, #assembled_tart);
p7:#Produces(#step8, #baked_tart);
c11:#Consumes(#step9, #baked_tart);
p8:#Produces(#step9, #rested_tart);
c12:#Consumes(#step10, #rested_tart);
p9:#Produces(#step10, #tarte_tatin_dessert);
result1:#Result(#tarte_tatin_recipe, #tarte_tatin_dessert);
Analyse poétique
namespace poesie 'www.logicells.com/poesie' default;
define .:#Entity(me)[name::#string];
define .:#Season(me:#Entity);
define .:#SoundSource(me:#Entity);
define .:#SoundQuality(me:#Entity);
define .:#Emotion(me:#Entity);
define .:#BodyPart(me:#Entity);
define .:#PoeticSubject(me:#Entity);
define .:#SymbolicImage(me:#Entity);
define .:#Poem(me:#Entity);
define .:#Verse(me)[label::#string];
define .:#HasVerse(poem:#Poem, verse:#Verse);
define .:#Evokes(source:#Entity, target:#Entity);
define .:#Qualifies(target:#Entity, quality:#Entity);
define .:#Feels(subject:#PoeticSubject, emotion:#Emotion);
define .:#BelongsTo(part:#BodyPart, subject:#PoeticSubject);
define .:#AssociatedWith(x:#Entity, y:#Entity);
define .:#Affects(
source:#Entity,
subject:#PoeticSubject,
target:#Entity
)[mode::#string];
#chanson_automne:#Poem[name='Chanson d’automne'];
#speaker:#PoeticSubject[name='Je lyrique'];
#heart:#BodyPart[name='Heart'];
#autumn:#Season[name='Autumn'];
#violins:#SoundSource[name='Violins'];
#sobbing_sound:#SymbolicImage[name='Long sobbing of violins'];
#melancholy:#Emotion[name='Melancholy'];
#languor:#Emotion[name='Languor'];
#monotony:#SoundQuality[name='Monotony'];
#wound:#SymbolicImage[name='Inner wound'];
#v1:#Verse[label='Les sanglots longs'];
#v2:#Verse[label='Des violons'];
#v3:#Verse[label='De l’automne'];
#v4:#Verse[label='Blessent mon coeur'];
#v5:#Verse[label='D’une langueur'];
#v6:#Verse[label='Monotone'];
hv1:#HasVerse(#chanson_automne, #v1);
hv2:#HasVerse(#chanson_automne, #v2);
hv3:#HasVerse(#chanson_automne, #v3);
hv4:#HasVerse(#chanson_automne, #v4);
hv5:#HasVerse(#chanson_automne, #v5);
hv6:#HasVerse(#chanson_automne, #v6);
b1:#BelongsTo(#heart, #speaker);
e1:#Evokes(#violins, #sobbing_sound);
e2:#AssociatedWith(#sobbing_sound, #autumn);
q1:#Qualifies(#sobbing_sound, #monotony);
a1:#Affects(#sobbing_sound, #speaker, #heart)[mode='wounds inwardly'];
f1:#Feels(#speaker, #languor);
f2:#AssociatedWith(#languor, #melancholy);
f3:#Qualifies(#languor, #monotony);
f4:#AssociatedWith(#heart, #wound);
Patron agentique
namespace agents 'www.logicells.com/agents' default;
define .:#Agent(me)[name::#string];
define .:#Context(me)[label::#string];
define .:#UserRequest(me, context:#Context)[text::#string];
define .:#Decision(me, context:#Context)[label::#string, confidence::#float];
define .:#ReasoningTrace(
request:#UserRequest,
context:#Context
)[decision:#Decision] as
.:#RetrieveContext(request, context)[memory]
and .:#SelectPlan(request, memory, context)[plan]
and .:#SelectTool(plan, context)[tool]
and .:#ExecuteTool(tool, request, context)[result]
and .:#EvaluateResult(result, context)[decision];