---
# System prepended metadata

title: TP Prolog - s02 - ISC IL 3a
tags: [prolog]

---

###### tags: `prolog`

# TP Prolog - s02 - ISC IL 3a
## Baudin Valentin et Braillard Simon

## Exercice 1
`
[a, b, c, d], [a, b|[c, d]], [a, b, c, d|[]] = [a, b, c, d]`
`[[[a, b, c, d]]]`

`[[a, b], [c, d]], [[a, b]|[[c, d]]] = [[a, b], [c, d]]`

`[[a, b]|[c, d]], [[a, b], c, d], '.'( '.'(a, '.'(b,[])), '.'(c,'.'(d,[]))) = [[a, b], c, d]`

## Exercice 2
### a)
[![](https://mermaid.ink/img/pako:eNpVkctuwyAQRX9lNCuQyA-wqNTElrrpKl0kNlY0wfghxQ8ZvKji_Hsx2GrLBoY5d7jMPFEPpUGJ9URjA1-J6sGvd6awYjmJu9CFgIsVkF-XzBZcQM3W8MYVcjgc3iAq1rUo9Dm5yTiwqwTyW2Yl5OFK4QLHKDj6J-rfJ26h8p9wL3-K-Ok_nhc7ENMJO89aG2u56rcvBPVqybu4by603y_RDVC0k0Y8DfVJhJSO_4zUZmbDQtUPlurGaOAosDNTR23pW_hcEYWuMZ1RKP2xNBXND6dQ9S-P0uyG83evUbppNgLnsSRnkpZ88zuUFT2svzVl64bpM44lTEfgSH02DDvz-gHNmXmO)](https://mermaid.live/edit#pako:eNpVkctuwyAQRX9lNCuQyA-wqNTElrrpKl0kNlY0wfghxQ8ZvKji_Hsx2GrLBoY5d7jMPFEPpUGJ9URjA1-J6sGvd6awYjmJu9CFgIsVkF-XzBZcQM3W8MYVcjgc3iAq1rUo9Dm5yTiwqwTyW2Yl5OFK4QLHKDj6J-rfJ26h8p9wL3-K-Ok_nhc7ENMJO89aG2u56rcvBPVqybu4by603y_RDVC0k0Y8DfVJhJSO_4zUZmbDQtUPlurGaOAosDNTR23pW_hcEYWuMZ1RKP2xNBXND6dQ9S-P0uyG83evUbppNgLnsSRnkpZ88zuUFT2svzVl64bpM44lTEfgSH02DDvz-gHNmXmO)

### b)
[![](https://mermaid.ink/img/pako:eNp9kcFuwjAMhl_F8qmVwgvkMGlQuO0EB-iCppCkpRJtqiY5TJR3n5MM1F3mU-T_92c7vqOy2iDHdpLjFQ6VGIDivRDYFEfH4FOyC1NnBrUrGbQpd3KlwBJWqzfI9hizQBJ5LIALA3UmzwzrbFgTry1eEoMvgkHKZPoCGUGnCEqETQZsnoBsT1qyZ7kq9kEp44gy_G7wYh0zC4p6Od38Z85tLtpSlzjVfwPtIC-9W7SMtciwN1MvO02_eY85gf5qeiOQ01ObRoabFyiGB1ll8Hb_PSjkfgqGYRi19KbqJN2hR97Im6Os0Z2300e-UDoUw1EOtbVPz-MHFWB9uQ)](https://mermaid.live/edit#pako:eNp9kcFuwjAMhl_F8qmVwgvkMGlQuO0EB-iCppCkpRJtqiY5TJR3n5MM1F3mU-T_92c7vqOy2iDHdpLjFQ6VGIDivRDYFEfH4FOyC1NnBrUrGbQpd3KlwBJWqzfI9hizQBJ5LIALA3UmzwzrbFgTry1eEoMvgkHKZPoCGUGnCEqETQZsnoBsT1qyZ7kq9kEp44gy_G7wYh0zC4p6Od38Z85tLtpSlzjVfwPtIC-9W7SMtciwN1MvO02_eY85gf5qeiOQ01ObRoabFyiGB1ll8Hb_PSjkfgqGYRi19KbqJN2hR97Im6Os0Z2300e-UDoUw1EOtbVPz-MHFWB9uQ)

## Exercice 3
### a)
``` prolog
% --- listConcat(?Xs, ?Ys, ?XsYs) : XsYs is the concatenation of Xs and Ys
listConcat([], Ys, Ys).
listConcat([X|Xs], Ys, [X|XsYs]) :-
    listConcat(Xs, Ys, XsYs).
```

### b)
```prolog
% --- listSuffix(+L, ?S) : S is a suffix of L
listSuffix(S, S).
listSuffix([L|Ls], S) :-
    listSuffix(Ls, S).
```

## Exercice 4
### a)
[![](https://mermaid.ink/img/pako:eNo1TksKwjAUvEqYVQvpBbIQlG5d1ZXGxTN5tQWTlHwQKb27UXFWwzC_FSZYhsI90jKJU6-9qNg3GuHpU3MheZN0lYJajVZ03U4cmqEYwym1kHAcHc22FqyfpEae2LGGqtTySOWRNbTfqpVKDsPLG6gcC0uUxVLmfqY67aBGeqSqsp1ziMffqe83iYX8OYS_Z3sDj8c58w)](https://mermaid.live/edit#pako:eNo1TksKwjAUvEqYVQvpBbIQlG5d1ZXGxTN5tQWTlHwQKb27UXFWwzC_FSZYhsI90jKJU6-9qNg3GuHpU3MheZN0lYJajVZ03U4cmqEYwym1kHAcHc22FqyfpEae2LGGqtTySOWRNbTfqpVKDsPLG6gcC0uUxVLmfqY67aBGeqSqsp1ziMffqe83iYX8OYS_Z3sDj8c58w)

## Exercice 5
### a)
`listSublist2` et `listSublist3`fonctionnent correctement pour Valentin Baudin, cependant, `listSublist3` ne fonctionne pas chez Simon Braillard lors des essais dans le cas où on mettrait une sous-list qui est la fin de la liste principale. 

De plus, la `listSublist1` ne fonctionne chez personne. Si `S` est bien une sous-liste de `L`, cela va répondre `yes`. Par contre, si ce n'est pas le cas, cela va générer un stack overflow.

### b)
`listSublist3`

## Exercice 6
```prolog=
unifyMany([], []).
unifyMany([A|As], [A|Bs]) :-
    unifyMany(As, Bs).
```